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.
This commit is contained in:
Armin Friedl 2022-08-27 19:46:01 +02:00
parent 4612c8fcf5
commit 7aaea2ed2f
4 changed files with 6 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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