mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-03-11 11:18:13 +08:00
update avx512 docker build
This commit is contained in:
parent
f2431e872d
commit
c28a430e8c
@ -1,9 +1,16 @@
|
||||
FROM ubuntu:24.04 AS build-base
|
||||
# syntax=docker.io/docker/dockerfile:1.7-labs
|
||||
FROM --platform=${TARGETPLATFORM} ubuntu:24.04 AS base
|
||||
|
||||
ENV PATH="${PATH}:/root/.cargo/bin/"
|
||||
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
|
||||
# Install GMP 6.2 (6.3 which MacOS is using only available on Debian unstable)
|
||||
RUN apt-get update && apt-get install -y \
|
||||
RUN --mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
curl \
|
||||
git \
|
||||
@ -22,22 +29,35 @@ RUN apt-get update && apt-get install -y \
|
||||
libtool \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN apt update && apt install -y wget && \
|
||||
RUN wget https://raw.githubusercontent.com/emp-toolkit/emp-readme/master/scripts/install.py
|
||||
|
||||
RUN python install.py --install --tool --ot
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
cd emp-tool && sed -i 's/add_library(${NAME} SHARED ${sources})/add_library(${NAME} STATIC ${sources})/g' CMakeLists.txt && mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local && cd .. && make && make install && cd ..
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
cd emp-ot && mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local && cd .. && make && make install && cd ..
|
||||
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
apt update && apt install -y wget && \
|
||||
ARCH=$(dpkg --print-architecture) && \
|
||||
case ${ARCH} in \
|
||||
amd64) GOARCH=amd64 ;; \
|
||||
arm64) GOARCH=arm64 ;; \
|
||||
*) echo "Unsupported architecture: ${ARCH}" && exit 1 ;; \
|
||||
esac && \
|
||||
wget https://go.dev/dl/go1.23.5.linux-${GOARCH}.tar.gz && \
|
||||
wget https://go.dev/dl/go${GO_VERSION}.linux-${GOARCH}.tar.gz && \
|
||||
rm -rf /usr/local/go && \
|
||||
tar -C /usr/local -xzf go1.23.5.linux-${GOARCH}.tar.gz && \
|
||||
rm go1.23.5.linux-${GOARCH}.tar.gz
|
||||
tar -C /usr/local -xzf go${GO_VERSION}.linux-${GOARCH}.tar.gz && \
|
||||
rm go${GO_VERSION}.linux-${GOARCH}.tar.gz
|
||||
|
||||
ENV PATH=$PATH:/usr/local/go/bin
|
||||
|
||||
# Build FLINT from source with AVX-512
|
||||
RUN git clone https://github.com/flintlib/flint.git && \
|
||||
RUN --mount=type=cache,target=/usr/local,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
git clone https://github.com/flintlib/flint.git && \
|
||||
cd flint && \
|
||||
git checkout flint-3.0 && \
|
||||
./bootstrap.sh && \
|
||||
@ -56,49 +76,196 @@ RUN git clone https://github.com/flintlib/flint.git && \
|
||||
|
||||
COPY docker/rustup-init.sh /opt/rustup-init.sh
|
||||
|
||||
RUN /opt/rustup-init.sh -y --profile minimal
|
||||
RUN --mount=type=cache,target=/root/.cargo,id=cargo-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/opt/ceremonyclient/target/,id=target-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
/opt/rustup-init.sh -y --profile minimal
|
||||
|
||||
# Install uniffi-bindgen-go
|
||||
RUN cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.2.1+v0.25.0
|
||||
RUN --mount=type=cache,target=/root/.cargo,id=cargo-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/opt/ceremonyclient/target/,id=target-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.2.1+v0.25.0
|
||||
|
||||
FROM build-base AS build
|
||||
|
||||
FROM base AS build
|
||||
|
||||
ENV GOEXPERIMENT=arenas
|
||||
ENV QUILIBRIUM_SIGNATURE_CHECK=false
|
||||
|
||||
# Install grpcurl before building the node and client
|
||||
# as to avoid needing to redo it on rebuilds
|
||||
RUN --mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETOS}-${TARGETARCH} \
|
||||
go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
|
||||
|
||||
WORKDIR /opt/ceremonyclient
|
||||
|
||||
COPY . .
|
||||
COPY --exclude=node \
|
||||
--exclude=client \
|
||||
--exclude=sidecar . .
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETOS}-${TARGETARCH} \
|
||||
go mod download
|
||||
|
||||
## Generate Rust bindings for VDF
|
||||
WORKDIR /opt/ceremonyclient/vdf
|
||||
RUN ./generate.sh
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETOS}-${TARGETARCH} \
|
||||
go mod download
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cargo,id=cargo-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/opt/ceremonyclient/target/,id=target-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETOS}-${TARGETARCH} \
|
||||
./generate.sh
|
||||
|
||||
|
||||
## Generate Rust bindings for Ferret
|
||||
WORKDIR /opt/ceremonyclient/ferret
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/opt/ceremonyclient/target/,id=target-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cargo,id=cargo-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/bin,id=go-bin-${TARGETOS}-${TARGETARCH} \
|
||||
go mod download
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cargo,id=cargo-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/opt/ceremonyclient/target/,id=target-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/bin,id=go-bin-${TARGETOS}-${TARGETARCH} \
|
||||
./generate.sh
|
||||
|
||||
## Generate Rust bindings for BLS48581
|
||||
WORKDIR /opt/ceremonyclient/bls48581
|
||||
RUN ./generate.sh
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/opt/ceremonyclient/target/,id=target-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cargo,id=cargo-${TARGETOS}-${TARGETARCH} \
|
||||
go mod download
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cargo,id=cargo-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/opt/ceremonyclient/target/,id=target-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETOS}-${TARGETARCH} \
|
||||
./generate.sh
|
||||
|
||||
## Generate Rust bindings for VerEnc
|
||||
WORKDIR /opt/ceremonyclient/verenc
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETOS}-${TARGETARCH} \
|
||||
go mod download
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cargo,id=cargo-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/opt/ceremonyclient/target/,id=target-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETOS}-${TARGETARCH} \
|
||||
./generate.sh
|
||||
|
||||
FROM build AS build-node
|
||||
|
||||
# Build and install the node
|
||||
COPY ./node /opt/ceremonyclient/node
|
||||
WORKDIR /opt/ceremonyclient/node
|
||||
|
||||
RUN ./build.sh && cp node /usr/bin
|
||||
RUN go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
|
||||
RUN --mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/opt/ceremonyclient/target,id=target-${TARGETOS}-${TARGETARCH} \
|
||||
./build.sh && cp node /usr/bin
|
||||
|
||||
FROM build AS build-qclient
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
# Build and install qclient
|
||||
COPY ./node /opt/ceremonyclient/node
|
||||
|
||||
WORKDIR /opt/ceremonyclient/node
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETOS}-${TARGETARCH} \
|
||||
go mod download
|
||||
|
||||
COPY ./client /opt/ceremonyclient/client
|
||||
WORKDIR /opt/ceremonyclient/client
|
||||
|
||||
RUN ./build.sh -o qclient && cp qclient /usr/bin
|
||||
RUN --mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETOS}-${TARGETARCH} \
|
||||
go mod download
|
||||
|
||||
ARG BINARIES_DIR=/opt/ceremonyclient/target/release
|
||||
ENV CGO_ENABLED=1
|
||||
ENV CGO_LDFLAGS="-L/usr/local/lib -lflint -lgmp -lmpfr -ldl -lm -L$BINARIES_DIR -lvdf -lverenc -lbls48581 -static"
|
||||
RUN --mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/opt/ceremonyclient/target,id=target-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETOS}-${TARGETARCH} \
|
||||
GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags "-linkmode 'external'" -o qclient
|
||||
RUN cp qclient /usr/bin
|
||||
|
||||
FROM build AS build-sidecar
|
||||
# Build and install sidecar
|
||||
COPY ./node /opt/ceremonyclient/node
|
||||
|
||||
WORKDIR /opt/ceremonyclient/node
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETOS}-${TARGETARCH} \
|
||||
go mod download
|
||||
|
||||
COPY ./sidecar /opt/ceremonyclient/sidecar
|
||||
WORKDIR /opt/ceremonyclient/sidecar
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETOS}-${TARGETARCH} \
|
||||
go mod download
|
||||
|
||||
RUN --mount=type=cache,target=/usr/local/,id=usr-local-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/go/pkg/mod,id=go-mod-${TARGETOS}-${TARGETARCH} \
|
||||
--mount=type=cache,target=/opt/ceremonyclient/target,id=target-${TARGETOS}-${TARGETARCH} \
|
||||
./build.sh -o sidecar && cp sidecar /usr/bin
|
||||
|
||||
# Allows exporting single binary
|
||||
FROM scratch AS qclient
|
||||
COPY --from=build /usr/bin/qclient /qclient
|
||||
ENTRYPOINT [ "/qclient" ]
|
||||
FROM scratch AS sidecar
|
||||
COPY --from=build-sidecar /usr/bin/sidecar /sidecar
|
||||
ENTRYPOINT [ "/sidecar" ]
|
||||
|
||||
# Allows exporting single binary
|
||||
FROM scratch AS node
|
||||
COPY --from=build /usr/bin/node /node
|
||||
COPY --from=build-node /usr/bin/node /node
|
||||
ENTRYPOINT [ "/node" ]
|
||||
|
||||
# Allows exporting single binary
|
||||
FROM scratch AS qclient-unix
|
||||
COPY --from=build-qclient /usr/bin/qclient /qclient
|
||||
ENTRYPOINT [ "/qclient" ]
|
||||
|
||||
FROM qclient-unix AS qclient-linux
|
||||
FROM qclient-unix AS qclient-darwin
|
||||
FROM qclient-${TARGETOS} AS qclient
|
||||
|
||||
FROM ubuntu:24.04
|
||||
|
||||
RUN apt-get update && apt-get install libflint-dev -y
|
||||
@ -122,8 +289,8 @@ LABEL org.opencontainers.image.revision=$GIT_COMMIT
|
||||
|
||||
RUN apt-get update && apt-get install -y ca-certificates
|
||||
|
||||
COPY --from=build /usr/bin/node /usr/local/bin
|
||||
COPY --from=build /opt/ceremonyclient/client/qclient /usr/local/bin
|
||||
COPY --from=build-node /usr/bin/node /usr/local/bin
|
||||
COPY --from=build-qclient /opt/ceremonyclient/client/qclient /usr/local/bin
|
||||
|
||||
WORKDIR /root
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user