Skip to content

Node.js based forum software built for the modern web

fix: reduce docker image size again and speed up build

Opliko56ef2bdd67c0
diff --git a/Dockerfile b/Dockerfile
index 9778513430..f3b76ab35b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -46,15 +46,16 @@ ENV NODE_ENV=production \
WORKDIR /usr/src/app/
-COPY --from=build --chown=${USER}:${USER} /usr/src/app/ /usr/src/app/install/docker/setup.json /usr/src/app/
-COPY --from=build --chown=${USER}:${USER} /usr/bin/tini /usr/src/app/install/docker/entrypoint.sh /usr/local/bin/
-
RUN corepack enable \
&& groupadd --gid ${GID} ${USER} \
&& useradd --uid ${UID} --gid ${GID} --home-dir /usr/src/app/ --shell /bin/bash ${USER} \
&& mkdir -p /usr/src/app/logs/ /opt/config/ \
- && chown -R ${USER}:${USER} /usr/src/app/ /opt/config/ \
- && chmod +x /usr/local/bin/entrypoint.sh \
+ && chown -R ${USER}:${USER} /usr/src/app/ /opt/config/
+
+COPY --from=build --chown=${USER}:${USER} /usr/src/app/ /usr/src/app/install/docker/setup.json /usr/src/app/
+COPY --from=build --chown=${USER}:${USER} /usr/bin/tini /usr/src/app/install/docker/entrypoint.sh /usr/local/bin/
+
+RUN chmod +x /usr/local/bin/entrypoint.sh \
&& chmod +x /usr/local/bin/tini
# TODO: Have docker-compose use environment variables to create files like setup.json and config.json.
diff --git a/dev.Dockerfile b/dev.Dockerfile
index a2b3867ed5..bab7d800c5 100644
--- a/dev.Dockerfile
+++ b/dev.Dockerfile
@@ -51,17 +51,18 @@ ENV NODE_ENV=development \
WORKDIR /usr/src/app/
+RUN corepack enable \
+ && groupadd --gid ${GID} ${USER} \
+ && useradd --uid ${UID} --gid ${GID} --home-dir /usr/src/app/ --shell /bin/bash ${USER} \
+ && mkdir -p /usr/src/app/logs/ /opt/config/ \
+ && chown -R ${USER}:${USER} /usr/src/app/ /opt/config/
+
COPY --from=build --chown=${USER}:${USER} /usr/src/app/ /usr/src/app/install/docker/setup.json /usr/src/app/
COPY --from=build --chown=${USER}:${USER} /usr/bin/tini /usr/src/app/install/docker/entrypoint.sh /usr/local/bin/
COPY --from=node_modules_touch --chown=${USER}:${USER} /usr/src/app/ /usr/src/app/
COPY --from=git --chown=${USER}:${USER} /usr/src/app/ /usr/src/app/
-RUN corepack enable \
- && groupadd --gid ${GID} ${USER} \
- && useradd --uid ${UID} --gid ${GID} --home-dir /usr/src/app/ --shell /bin/bash ${USER} \
- && mkdir -p /usr/src/app/logs/ /opt/config/ \
- && chown -R ${USER}:${USER} /usr/src/app/ /opt/config/ \
- && chmod +x /usr/local/bin/entrypoint.sh \
+RUN chmod +x /usr/local/bin/entrypoint.sh \
&& chmod +x /usr/local/bin/tini
# TODO: Have docker-compose use environment variables to create files like setup.json and config.json.