fix: reduce docker image size again and speed up build

it really was just order of operations...
resolves #12582
This commit is contained in:
Opliko
2024-05-23 23:52:33 +02:00
committed by Julian Lam
parent 83facb7df6
commit 56ef2bdd67
2 changed files with 13 additions and 11 deletions

View File

@@ -46,15 +46,16 @@ ENV NODE_ENV=production \
WORKDIR /usr/src/app/ 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 \ RUN corepack enable \
&& groupadd --gid ${GID} ${USER} \ && groupadd --gid ${GID} ${USER} \
&& useradd --uid ${UID} --gid ${GID} --home-dir /usr/src/app/ --shell /bin/bash ${USER} \ && useradd --uid ${UID} --gid ${GID} --home-dir /usr/src/app/ --shell /bin/bash ${USER} \
&& mkdir -p /usr/src/app/logs/ /opt/config/ \ && mkdir -p /usr/src/app/logs/ /opt/config/ \
&& chown -R ${USER}:${USER} /usr/src/app/ /opt/config/ \ && chown -R ${USER}:${USER} /usr/src/app/ /opt/config/
&& chmod +x /usr/local/bin/entrypoint.sh \
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 && chmod +x /usr/local/bin/tini
# TODO: Have docker-compose use environment variables to create files like setup.json and config.json. # TODO: Have docker-compose use environment variables to create files like setup.json and config.json.

View File

@@ -51,17 +51,18 @@ ENV NODE_ENV=development \
WORKDIR /usr/src/app/ 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/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=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=node_modules_touch --chown=${USER}:${USER} /usr/src/app/ /usr/src/app/
COPY --from=git --chown=${USER}:${USER} /usr/src/app/ /usr/src/app/ COPY --from=git --chown=${USER}:${USER} /usr/src/app/ /usr/src/app/
RUN corepack enable \ RUN chmod +x /usr/local/bin/entrypoint.sh \
&& 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 \
&& chmod +x /usr/local/bin/tini && chmod +x /usr/local/bin/tini
# TODO: Have docker-compose use environment variables to create files like setup.json and config.json. # TODO: Have docker-compose use environment variables to create files like setup.json and config.json.