dockerfile to manage mounting of /nix

This commit is contained in:
Thomas Hobson 2021-10-05 15:18:08 +13:00
parent e2f37b7493
commit e06b59d82c
No known key found for this signature in database
GPG Key ID: 9F1FD9D87950DB6F
2 changed files with 16 additions and 2 deletions

View File

@ -18,10 +18,11 @@ RUN apt-get update && \
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
RUN mkdir -m 0755 /nix && chown node /nix RUN mkdir -m 0755 /nix && chown node /nix && touch /nix/piston_detected
RUN runuser -l node -c 'curl -L https://nixos.org/nix/install | sh -s -- --no-daemon ' RUN runuser -l node -c 'curl -L https://nixos.org/nix/install | sh -s -- --no-daemon '
RUN runuser -l node -c 'source ~/.profile; nix-env -iA nixpkgs.nixUnstable' RUN runuser -l node -c 'source ~/.profile; nix-env -iA nixpkgs.nixUnstable'
RUN runuser -l node -c 'mkdir -p /home/node/.config/nix/; echo "experimental-features = nix-command flakes" >> /home/node/.config/nix/nix.conf' RUN runuser -l node -c 'mkdir -p /home/node/.config/nix/; echo "experimental-features = nix-command flakes" >> /home/node/.config/nix/nix.conf'
RUN cp -r /nix /var/nix
WORKDIR /piston_api WORKDIR /piston_api
COPY ["package.json", "package-lock.json", "./"] COPY ["package.json", "package-lock.json", "./"]
@ -30,5 +31,7 @@ COPY ./src ./src
RUN make -C ./src/nosocket/ all && make -C ./src/nosocket/ install RUN make -C ./src/nosocket/ all && make -C ./src/nosocket/ install
CMD [ "node", "src"] COPY ./entrypoint.sh .
CMD [ "./entrypoint.sh"]
EXPOSE 2000/tcp EXPOSE 2000/tcp

11
api/entrypoint.sh Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
echo "Starting Piston API"
echo "Checking presense of nix store"
if [[ ! -f "/nix/piston_detected" ]]; then
echo "Nix Store is not loaded, assuming /nix has been mounted - copying contents"
cp -r /var/nix /nix
fi
echo "Launching Piston API"
node src