Dockerfile 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. # Start the Nix daemon and develop the environment
  10. RUN nix develop --extra-experimental-features nix-command --extra-experimental-features flakes --command cargo build --release --bin cdk-mintd
  11. # Create a runtime stage
  12. FROM debian:bookworm-slim
  13. # Set the working directory
  14. WORKDIR /usr/src/app
  15. # Install needed runtime dependencies (if any)
  16. RUN apt-get update && \
  17. apt-get install -y --no-install-recommends patchelf && \
  18. rm -rf /var/lib/apt/lists/*
  19. # Copy the built application from the build stage
  20. COPY --from=builder /usr/src/app/target/release/cdk-mintd /usr/local/bin/cdk-mintd
  21. # Detect the architecture and set the interpreter accordingly
  22. RUN ARCH=$(uname -m) && \
  23. if [ "$ARCH" = "aarch64" ]; then \
  24. patchelf --set-interpreter /lib/ld-linux-aarch64.so.1 /usr/local/bin/cdk-mintd; \
  25. elif [ "$ARCH" = "x86_64" ]; then \
  26. patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 /usr/local/bin/cdk-mintd; \
  27. else \
  28. echo "Unsupported architecture: $ARCH"; exit 1; \
  29. fi
  30. # Set the entry point for the container
  31. CMD ["cdk-mintd"]