diff --git a/Dockerfile b/Dockerfile index ab245c2..94914a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,10 @@ FROM nixos/nix:latest AS nix WORKDIR /app COPY . ./ -RUN cat > /tmp/script.sh < /tmp/script.sh <<'EOF' + nix --extra-experimental-features "nix-command flakes" build .#container -o result + tar cf result.tar result + mkdir -p /tmp/nix-store-closure cp -R $(nix-store -qR result/) /tmp/nix-store-closure @@ -19,7 +21,7 @@ RUN cat > /tmp/script.sh < tf.zst tar cf - $tdir | zstd --compress > tf.zst EOF -RUN nix --experimental-features "nix-command flakes" develop --command bash /tmp/script.sh +RUN nix --extra-experimental-features "nix-command flakes" develop --command bash /tmp/script.sh FROM busybox:latest @@ -36,9 +38,11 @@ WORKDIR /app RUN mkdir -p /nix COPY --from=nix /tmp/nix-store-closure /nix/store -COPY --from=nix /tmp/tf.zst /app/tf.zst -COPY --from=nix /app/result/bin/* /usr/local/bin/ - +COPY --from=nix /app/tf.zst /app/tf.zst +RUN mkdir -p /usr/local/bin +COPY --from=nix /app/result.tar /app/result.tar +RUN tar xf result.tar +RUN ls -al && mv result/bin/* /usr/local/bin/ && rm result.tar && rm -rf result RUN adduser --disabled-password --home="/app" --uid 1717 nonroot COPY --chown=nonroot ./terraform ./terraform COPY --chown=nonroot ./infrastructure-templates ./infrastructure-templates diff --git a/Taskfile.yml b/Taskfile.yml index d54117d..278f1c6 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -68,7 +68,8 @@ tasks: vars: push: true cmds: - - docker buildx build -f Dockerfile --output=type=image,compression=zstd,force-compression=true,compression-level=22,push=true,oci-mediatypes=true -t {{.Image}} . + - echo "building and pushing {{.Image}}" + # - docker buildx build -f Dockerfile --output=type=image,compression=zstd,force-compression=true,compression-level=22,push=true,oci-mediatypes=true -t {{.Image}} . # - docker build -f ./DockerfileNIX -t {{.Image}} . {{.dockerArgs}} # - |+ # if [ "{{.push}}" == "true" ]; then diff --git a/flake.nix b/flake.nix index 54960a4..8ca5eee 100644 --- a/flake.nix +++ b/flake.nix @@ -79,6 +79,8 @@ # # custom # packages.new-infra # new-infra + + zstd ]; shellHook = ''