-
Notifications
You must be signed in to change notification settings - Fork 285
/
Copy pathDockerfile
41 lines (33 loc) · 1.04 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# hadolint ignore=DL3007
FROM nixos/nix:2.21.2 AS builder
ARG BIN=sdf
COPY . /workdir
WORKDIR /workdir
RUN set -eux; \
nix \
--extra-experimental-features "nix-command flakes impure-derivations ca-derivations" \
--option filter-syscalls false \
build \
".#$BIN";
RUN mkdir -p /tmp/nix-store-closure /tmp/local-bin
# hadolint ignore=SC2046
RUN cp -R $(nix-store --query --requisites result/) /tmp/nix-store-closure
# hadolint ignore=SC2046
RUN ln -snf $(nix-store --query result/)/bin/* /tmp/local-bin/
FROM alpine:3 AS final
ARG BIN=sdf
# hadolint ignore=DL3018
RUN set -eux; \
apk add --no-cache runuser; \
adduser -D app; \
for dir in /run /etc /usr/local/etc /home/app/.config; do \
mkdir -pv "$dir/$BIN"; \
done;
WORKDIR /run/$BIN
COPY --from=builder /tmp/nix-store-closure /nix/store
COPY --from=builder /tmp/local-bin/* /usr/local/bin/
COPY --from=builder /workdir/pkgs/*.sipkg /run/sdf/pkgs/
EXPOSE 5156/tcp
ENTRYPOINT [ \
"/sbin/runuser", "-u", "app", "--", "/usr/local/bin/sdf" \
]