Skip to content

Commit

Permalink
Strip build dependencies from docker builds
Browse files Browse the repository at this point in the history
  • Loading branch information
w4 committed Jan 6, 2025
1 parent a72dd06 commit e213223
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
target
Dockerfile
.dockerignore
17 changes: 11 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
FROM nixos/nix:2.24.9 AS builder

RUN nix-channel --update
RUN echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf
FROM nixos/nix:latest AS builder

WORKDIR /app
COPY . .

RUN nix build .#
RUN nix --extra-experimental-features "nix-command flakes" --accept-flake-config build .#
RUN mkdir /tmp/nix-store-closure
RUN cp -R $(nix-store -qR result/) /tmp/nix-store-closure

FROM scratch

WORKDIR /app
COPY --from=builder /tmp/nix-store-closure /nix/store
COPY --from=builder /app/result /app

CMD ["/app/result/bin/rgit"]
ENTRYPOINT ["/app/bin/rgit"]

0 comments on commit e213223

Please sign in to comment.