Skip to content

Commit

Permalink
use nix as base image instead
Browse files Browse the repository at this point in the history
  • Loading branch information
aki-mizu committed Dec 3, 2024
1 parent 6b9ff46 commit 096d0ca
Showing 1 changed file with 5 additions and 27 deletions.
32 changes: 5 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,16 @@
# Build Stage with a minimal image
FROM debian:bullseye-slim AS builder
# Use the official NixOS image as the base image
FROM nixos/nix:latest AS builder

# Set the working directory
WORKDIR /usr/src/app

# Install necessary dependencies
RUN apt-get update && apt-get install -y \
curl \
protobuf-compiler \
xz-utils

# Copy the source code and flake.nix into the container
COPY . /usr/src/app

# Create /nix directory and set permissions
USER root
RUN mkdir -m 0755 /nix && chown root /nix

# Create nixbld group and users
RUN groupadd -g 30000 nixbld && \
for i in $(seq 1 10); do \
useradd -u $((30000 + i)) -g nixbld -G nixbld -m -s /bin/false nixbld$i; \
done

# Install Nix and set up the environment
RUN curl -L https://nixos.org/nix/install | sh -s -- --daemon && \
/bin/bash -c "source /root/.nix-profile/etc/profile.d/nix.sh && \
exec bash -l -c 'nix-channel --update && nix-env -iA nixpkgs.nix'"

# Start the Nix daemon and develop the environment
RUN /bin/bash -c "source /root/.nix-profile/etc/profile.d/nix.sh && \
/root/.nix-profile/bin/nix-daemon & \
cd /usr/src/app && \
/root/.nix-profile/bin/nix develop --extra-experimental-features nix-command --extra-experimental-features flakes --command cargo build --release --bin cdk-mintd"
RUN nix-channel --update && \
nix-env -iA nixpkgs.nix && \
nix develop --extra-experimental-features nix-command --extra-experimental-features flakes --command cargo build --release --bin cdk-mintd

# Create a runtime stage
FROM debian:bullseye-slim
Expand Down

0 comments on commit 096d0ca

Please sign in to comment.