Dockerfile.arm 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Use the official NixOS image as the base image
  2. FROM nixos/nix:latest AS builder
  3. # Set the working directory
  4. WORKDIR /usr/src/app
  5. # Copy workspace files and crates directory into the container
  6. COPY flake.nix ./flake.nix
  7. COPY Cargo.toml ./Cargo.toml
  8. COPY crates ./crates
  9. # Create a nix config file to disable syscall filtering
  10. RUN echo 'filter-syscalls = false' > /etc/nix/nix.conf
  11. # Start the Nix daemon and develop the environment
  12. RUN nix develop --extra-platforms aarch64-linux --extra-experimental-features nix-command --extra-experimental-features flakes --command cargo build --release --bin cdk-mintd --features redis
  13. # Create a runtime stage
  14. FROM debian:bookworm-slim
  15. # Set the working directory
  16. WORKDIR /usr/src/app
  17. # Install needed runtime dependencies (if any)
  18. RUN apt-get update && \
  19. apt-get install -y --no-install-recommends patchelf && \
  20. rm -rf /var/lib/apt/lists/*
  21. # Copy the built application from the build stage
  22. COPY --from=builder /usr/src/app/target/release/cdk-mintd /usr/local/bin/cdk-mintd
  23. # Detect the architecture and set the interpreter accordingly
  24. RUN ARCH=$(uname -m) && \
  25. if [ "$ARCH" = "aarch64" ]; then \
  26. patchelf --set-interpreter /lib/ld-linux-aarch64.so.1 /usr/local/bin/cdk-mintd; \
  27. elif [ "$ARCH" = "x86_64" ]; then \
  28. patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 /usr/local/bin/cdk-mintd; \
  29. else \
  30. echo "Unsupported architecture: $ARCH"; exit 1; \
  31. fi
  32. # Set the entry point for the container
  33. CMD ["cdk-mintd"]