-
Notifications
You must be signed in to change notification settings - Fork 262
/
Dockerfile
38 lines (31 loc) · 993 Bytes
/
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
# hadolint ignore=DL3007
FROM nixos/nix:2.21.2 AS builder
ARG BIN=pinga
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=pinga
# 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/
ENTRYPOINT [ \
"/sbin/runuser", "-u", "app", "--", "/usr/local/bin/pinga" \
]