From e06b59d82ca08d31a7799795e72d93c5e1de077e Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Tue, 5 Oct 2021 15:18:08 +1300 Subject: [PATCH] dockerfile to manage mounting of /nix --- api/Dockerfile | 7 +++++-- api/entrypoint.sh | 11 +++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100755 api/entrypoint.sh diff --git a/api/Dockerfile b/api/Dockerfile index 6e0ff79..ace28d0 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -18,10 +18,11 @@ RUN apt-get update && \ 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 '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 cp -r /nix /var/nix WORKDIR /piston_api COPY ["package.json", "package-lock.json", "./"] @@ -30,5 +31,7 @@ COPY ./src ./src RUN make -C ./src/nosocket/ all && make -C ./src/nosocket/ install -CMD [ "node", "src"] +COPY ./entrypoint.sh . + +CMD [ "./entrypoint.sh"] EXPOSE 2000/tcp diff --git a/api/entrypoint.sh b/api/entrypoint.sh new file mode 100755 index 0000000..17966e5 --- /dev/null +++ b/api/entrypoint.sh @@ -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