From 7aaea2ed2f698a9fcb88dc90069924a7c9093dee Mon Sep 17 00:00:00 2001 From: Armin Friedl Date: Sat, 27 Aug 2022 19:46:01 +0200 Subject: [PATCH] Fix cache directory permissions Newer npm expects a cache directory under `/.npm`. We cleaned the cache and npm cannot create the directory anymore at runtime (we drop privileges). So we have to create the `/.npm` directory again during container build and later re-own it. In `run.sh` re-own `/.npm` so it is accessible when we later drop privileges. --- latest/Dockerfile | 1 + latest/run.sh | 2 ++ stable/Dockerfile | 1 + stable/run.sh | 2 ++ 4 files changed, 6 insertions(+) diff --git a/latest/Dockerfile b/latest/Dockerfile index 22fe251..62d5c29 100644 --- a/latest/Dockerfile +++ b/latest/Dockerfile @@ -12,6 +12,7 @@ RUN apk -U upgrade \ && git checkout ${HASTEBIN_VERSION} \ && npm install \ && npm cache clean --force \ + && mkdir /.npm \ && apk del git \ && rm -rf /var/lib/apk/* /var/cache/apk/* \ && chmod +x /usr/local/bin/run.sh diff --git a/latest/run.sh b/latest/run.sh index d5b4567..01f1c03 100644 --- a/latest/run.sh +++ b/latest/run.sh @@ -5,4 +5,6 @@ set -xe # we have to run the chown here since the VOLUME is mounted # after the build with root:root chown -R ${UID}:${GID} /app +chown -R ${UID}:${GID} /.npm + su-exec ${UID}:${GID} npm start diff --git a/stable/Dockerfile b/stable/Dockerfile index 22fe251..62d5c29 100644 --- a/stable/Dockerfile +++ b/stable/Dockerfile @@ -12,6 +12,7 @@ RUN apk -U upgrade \ && git checkout ${HASTEBIN_VERSION} \ && npm install \ && npm cache clean --force \ + && mkdir /.npm \ && apk del git \ && rm -rf /var/lib/apk/* /var/cache/apk/* \ && chmod +x /usr/local/bin/run.sh diff --git a/stable/run.sh b/stable/run.sh index d5b4567..01f1c03 100644 --- a/stable/run.sh +++ b/stable/run.sh @@ -5,4 +5,6 @@ set -xe # we have to run the chown here since the VOLUME is mounted # after the build with root:root chown -R ${UID}:${GID} /app +chown -R ${UID}:${GID} /.npm + su-exec ${UID}:${GID} npm start