Skip to content

Instantly share code, notes, and snippets.

@nicobo
Created January 16, 2021 13:49
Show Gist options
  • Save nicobo/06530acc4fd82497878d45a93348ae3c to your computer and use it in GitHub Desktop.
Save nicobo/06530acc4fd82497878d45a93348ae3c to your computer and use it in GitHub Desktop.
A Dockerile to build libzkgroup on ARM v7
############################
# STAGE 1
# Getting around this bug : https://github.com/docker/buildx/issues/395
# Download files into this temporary image, including .cargo/*
FROM --platform=$BUILDPLATFORM rust:1.49-buster AS rust_fix
RUN apt-get update && \
apt-get install -y git
RUN git clone https://github.com/signalapp/zkgroup.git /usr/src/zkgroup
WORKDIR /usr/src/zkgroup
ENV USER=root
# Don't do `cargo init` or --> error: `cargo init` cannot be run on existing Cargo packages
# RUN cargo init
RUN mkdir -p .cargo \
&& cargo vendor > .cargo/config
############################
# STAGE 2
# Get the prepared files & build (for ARM)
FROM python:3
# Buggy tzdata installation : https://serverfault.com/questions/949991/how-to-install-tzdata-on-a-ubuntu-docker-image
ARG DEBIAN_FRONTEND=noninteractive
ARG TZ=Europe/Paris
RUN apt-get update && \
apt-get install -y \
# rustc must be > 1.36 or libzkgroup build will fail
# jfsutils to create a FS that works as a workaround for bug
# wget does not recognizes github certificates so curl replaces it well...
git zip curl tar cargo rustc make && \
rm -rf /var/lib/apt/lists/* && \
update-ca-certificates
# Compiles the native libzkgroup depency for ARM
COPY --from=rust_fix /usr/src/zkgroup /usr/src/zkgroup
WORKDIR /usr/src/zkgroup
#RUN make libzkgroup
# Bypassing the Makefile to add --offline
RUN RUSTFLAGS='-C link-arg=-s' cargo build --release --offline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment