-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 parent
454fb04
commit 884f258
Showing
5 changed files
with
72 additions
and
101 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,2 @@ | ||
./result | ||
./target |
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 |
---|---|---|
@@ -1,21 +1,37 @@ | ||
### alternative tag is e.g. '1.72.0' | ||
ARG RUST_VSN='stable' | ||
# based on https://mitchellh.com/writing/nix-with-dockerfiles | ||
|
||
##### Build | ||
FROM docker.io/clux/muslrust:${RUST_VSN} as builder | ||
# Nix builder | ||
FROM nixos/nix:latest AS builder | ||
|
||
COPY / ./ | ||
RUN cargo build --release | ||
# Copy our source and setup our working dir. | ||
COPY . /tmp/build | ||
WORKDIR /tmp/build | ||
|
||
RUN mkdir -p /rootfs/etc/fpush \ | ||
&& mv $(find target/ -name fpush -type f -executable) /rootfs/fpush \ | ||
&& touch /rootfs/etc/fpush/settings.json | ||
RUN nix-channel --update | ||
|
||
##### Runtime | ||
FROM gcr.io/distroless/static-debian12:nonroot AS prod | ||
# Build our Nix environment | ||
RUN nix \ | ||
--extra-experimental-features "nix-command flakes" \ | ||
--option filter-syscalls false \ | ||
build | ||
|
||
COPY --from=builder /rootfs / | ||
# Copy the Nix store closure into a directory. The Nix store closure is the | ||
# entire set of Nix store values that we need for our build. | ||
RUN mkdir /tmp/nix-store-closure | ||
RUN mkdir /tmp/app | ||
RUN cp -R $(nix-store -qR result/) /tmp/nix-store-closure \ | ||
&& ln -s $(readlink -f result)/ /tmp/app/fpush | ||
|
||
# Final image is based on scratch. We copy a bunch of Nix dependencies | ||
# but they're fully self-contained so we don't need Nix anymore. | ||
FROM scratch | ||
|
||
WORKDIR /app | ||
|
||
# Copy /nix/store | ||
COPY --from=builder /tmp/nix-store-closure /nix/store | ||
COPY --from=builder /tmp/app /app | ||
|
||
ENV RUST_LOG=info | ||
|
||
ENTRYPOINT ["/fpush","/etc/fpush/settings.json"] | ||
ENTRYPOINT ["/app/fpush/bin/fpush", "/etc/fpush/settings.json"] |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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