static.Dockerfile 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Usage(on repo root folder):
  2. # docker build . --pull --no-cache --shm-size=196m -t darkfi:static -f ./contrib/docker/static.Dockerfile -o static-bins
  3. # Optionally, add arguments like: --build-arg BINS=darkirc
  4. # If you want to keep building using the same builder, remove --no-cache option.
  5. # Arguments configuration
  6. ARG ALPINE_VER=edge
  7. ARG SQLCIPHER_VER=4.5.5
  8. ARG RUST_VER=nightly
  9. #TODO: only darkirc, taud and lilith has been tested, have to check rest binaries to add deps.
  10. ARG BINS="darkirc taud lilith"
  11. # Environment setup
  12. FROM alpine:${ALPINE_VER} as builder
  13. ## Arguments import
  14. ARG SQLCIPHER_VER
  15. ARG RUST_VER
  16. ARG BINS
  17. ## Install system dependencies
  18. RUN apk update
  19. RUN apk add rustup git musl-dev make gcc openssl-dev openssl-libs-static tcl-dev zlib-static
  20. ## Setup SQLCipher
  21. RUN wget -O sqlcipher.tar.gz https://github.com/sqlcipher/sqlcipher/archive/refs/tags/v${SQLCIPHER_VER}.tar.gz && \
  22. tar xf sqlcipher.tar.gz && \
  23. rm sqlcipher.tar.gz && \
  24. mv sqlcipher-${SQLCIPHER_VER} sqlcipher && \
  25. cd sqlcipher && \
  26. ./configure --prefix=/usr/local --disable-shared --enable-static --enable-cross-thread-connections --enable-releasemode && \
  27. make -j$(nproc) && \
  28. make install
  29. ## Configure Rust
  30. RUN rustup-init --default-toolchain none -y
  31. ENV PATH "${PATH}:/root/.cargo/bin/"
  32. RUN rustup default ${RUST_VER}
  33. RUN rustup target add wasm32-unknown-unknown
  34. # Build binaries
  35. FROM builder as rust_builder
  36. WORKDIR /opt/darkfi
  37. COPY . /opt/darkfi
  38. RUN sed -e 's,^#RUSTFLAGS ,RUSTFLAGS ,' -i Makefile
  39. RUN make clean && make ${BINS} && mkdir compiled-bins && \
  40. (if [ -e zkas ]; then cp -a zkas compiled-bins/; fi;) && \
  41. (if [ -e darkfid ]; then cp -a darkfid compiled-bins/; fi;) && \
  42. (if [ -e faucetd ]; then cp -a faucetd compiled-bins/; fi;) && \
  43. (if [ -e darkirc ]; then cp -a darkirc compiled-bins/; fi;) && \
  44. (if [ -e "genev-cli" ]; then cp -a genev-cli compiled-bins/; fi;) && \
  45. (if [ -e genevd ]; then cp -a genevd compiled-bins/; fi;) && \
  46. (if [ -e lilith ]; then cp -a lilith compiled-bins/; fi;) && \
  47. (if [ -e taud ]; then cp -a taud compiled-bins/; fi;) && \
  48. (if [ -e vanityaddr ]; then cp -a vanityaddr compiled-bins/; fi;)
  49. # Export binaries from rust builder
  50. FROM scratch
  51. COPY --from=rust_builder /opt/darkfi/compiled-bins/* ./