From b670ad73c430a9898cc573abf804d57421c628ac Mon Sep 17 00:00:00 2001 From: FoxxMD Date: Thu, 7 Apr 2022 15:23:14 -0400 Subject: [PATCH] refactor(docker): Improve data directory flexibility and build order * Create data directory if not /config * Copy s6 files in base to make incremental builds faster --- Dockerfile | 13 ++++++------- docker/root/etc/cont-init.d/10-config | 8 ++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 424e822..628ee8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,7 +75,7 @@ RUN apk add --no-cache \ && apk del .build-deps \ # smoke tests && node --version \ - && npm --version \ + && npm --version # # end of docker node stuff # @@ -87,12 +87,11 @@ RUN echo "http://dl-4.alpinelinux.org/alpine/v3.14/community" >> /etc/apk/reposi RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone ARG data_dir=/config -#RUN mkdir -p $data_dir && \ -# chown -R abc:abc $data_dir && \ -# chmod 755 $data_dir VOLUME $data_dir ENV DATA_DIR=$data_dir +COPY docker/root/ / + WORKDIR /app FROM base as build @@ -110,7 +109,9 @@ FROM base as app COPY --from=build --chown=abc:abc /app /app -RUN npm install --production && npm cache clean --force +RUN npm install --production \ + && npm cache clean --force \ + && chown abc:abc node_modules ENV NPM_CONFIG_LOGLEVEL debug @@ -124,5 +125,3 @@ EXPOSE $PORT # convenience variable for more helpful error messages ENV IS_DOCKER=true -COPY docker/root/ / - diff --git a/docker/root/etc/cont-init.d/10-config b/docker/root/etc/cont-init.d/10-config index 5afacef..e458018 100644 --- a/docker/root/etc/cont-init.d/10-config +++ b/docker/root/etc/cont-init.d/10-config @@ -3,10 +3,10 @@ # used https://github.com/linuxserver/docker-plex as a template # make data folder if not /config -#if [ ! -d "${DATA_DIR}" ]; then \ -#mkdir -p "${DATA_DIR}" -#chown -R abc:abc /config -#fi +if [ ! -d "${DATA_DIR}" ]; then \ +mkdir -p "${DATA_DIR}" +chown -R abc:abc /config +fi # permissions chown abc:abc \