47 lines
1.0 KiB
Docker
47 lines
1.0 KiB
Docker
# syntax=docker/dockerfile:1
|
|
#
|
|
# Builder
|
|
#
|
|
ARG NIX_SUBSTITUTERS=https://cache.nixos.org
|
|
|
|
FROM nixos/nix:2.31.3 AS builder
|
|
|
|
ARG NIX_SUBSTITUTERS
|
|
RUN tee -a /etc/nix/nix.conf <<EOF
|
|
extra-experimental-features = nix-command flakes
|
|
filter-syscalls = false
|
|
substituters = $NIX_SUBSTITUTERS
|
|
EOF
|
|
|
|
RUN cp "$(nix build nixpkgs#cacert --print-out-paths)/etc/ssl/certs/ca-bundle.crt" /tmp/ca-bundle.crt
|
|
|
|
COPY . /tmp/build
|
|
WORKDIR /tmp/build
|
|
|
|
RUN --mount=type=ssh GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" nix build '.#docker_env'
|
|
|
|
# Export the built closure to a folder
|
|
RUN mkdir /tmp/nix-store-closure
|
|
RUN cp -R $(nix-store -qR result/) /tmp/nix-store-closure
|
|
|
|
|
|
|
|
#
|
|
# Runner
|
|
#
|
|
|
|
FROM scratch
|
|
|
|
WORKDIR /app
|
|
|
|
ENV PATH="$PATH:/app/bin"
|
|
|
|
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt
|
|
ENV NIX_SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt
|
|
COPY --from=builder /tmp/ca-bundle.crt /etc/ssl/certs/ca-bundle.crt
|
|
|
|
COPY --from=builder /tmp/nix-store-closure /nix/store
|
|
COPY --from=builder /tmp/build/result /app
|
|
|
|
CMD ["/app/bin/natter"]
|