-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Use the official Ubuntu 24.04 image as the base image | ||
FROM ubuntu:24.04 | ||
|
||
# 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" | ||
|
||
# Set the entry point for the container | ||
CMD ["/usr/src/app/target/release/cdk-mintd"] |