From 5ed5cb6dde1fd8ac269b7874d261f4fe37ecbe92 Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Fri, 5 Jan 2024 18:38:26 +0530 Subject: [PATCH] use alpine base for final image --- Dockerfile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4ac8b9c..6f497a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,19 @@ -FROM nixos/nix:latest -WORKDIR /app +FROM nixos/nix:latest AS builder +WORKDIR /build COPY . . RUN nix \ --extra-experimental-features "nix-command flakes" \ build .#app -CMD [ "/app/result/bin/app" ] +RUN mkdir -p /tmp/nix-store-closure +RUN cp -ra $(nix-store -qR result/) /tmp/nix-store-closure + +FROM alpine:latest +WORKDIR /app + +COPY --from=builder /tmp/nix-store-closure /nix/store +COPY --from=builder /build/result /app + +CMD [ "/app/bin/app" ]