-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
60 lines (46 loc) · 1.46 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
FROM alpine:3.20.3
# Add DNS configuration
RUN echo "nameserver 8.8.8.8" > /etc/resolv.conf && \
echo "nameserver 8.8.4.4" >> /etc/resolv.conf
RUN apk update && \
apk add --no-cache \
bash \
curl \
sudo \
shadow \
xz \
openrc && \
mkdir -p /run/openrc && \
touch /run/openrc/softlevel
# Set environment variables
ENV NIX_FIRST_BUILD_UID=1000
ENV NIX_BUILD_GROUP_ID=101
RUN mkdir -m 0755 /nix && \
chown root /nix && \
addgroup -S nixbld && \
for n in $(seq 1 10); do \
adduser -D -H -g "Nix build user $n" \
-G nixbld -s "$(command -v nologin)" "nixbld$n"; \
done
# Install Nix
RUN sh <(curl -L https://nixos.org/nix/install) \
--daemon --yes
RUN echo 'extra-experimental-features = flakes nix-command' >> /etc/nix/nix.conf
# nix rc service script
COPY nix-daemon.sh /etc/init.d/nix-daemon
# Make the script executable
RUN chmod a+rx /etc/init.d/nix-daemon && \
cp /root/.nix-profile/bin/nix-daemon /usr/sbin # && \
rc-update add nix-daemon
WORKDIR /app
COPY . /app
VOLUME [ "/sys/fs/cgroup" ]
ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin"
RUN source /etc/profile.d/nix.sh
RUN source /nix/var/nix/profiles/default/etc/profile.d/nix.sh
# Alpine docker images allow only a single process to be launched
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
RUN nix-build /app/default.nix
CMD ["nix-shell", "/app/"]