From 6f8f25b0d1f95b68fff95a445d41b00ee43378e7 Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Sun, 5 Oct 2025 22:29:37 +0200 Subject: [PATCH] Small improvements to the Docker build (#10204) - Use same Node.js version in build and runner image - Reduce size of the image by applying the chown directly in the COPY --- Dockerfile | 15 +++++++-------- Dockerfile.base | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6dce199e2c..33d71a8eb7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,13 @@ ARG APP_PATH WORKDIR $APP_PATH ENV NODE_ENV=production -COPY --from=base $APP_PATH/build ./build +# Create a non-root user compatible with Debian and BusyBox based images +RUN addgroup --gid 1001 nodejs && \ + adduser --uid 1001 --ingroup nodejs nodejs && \ + mkdir -p /var/lib/outline && \ + chown -R nodejs:nodejs /var/lib/outline + +COPY --from=base --chown=nodejs:nodejs $APP_PATH/build ./build COPY --from=base $APP_PATH/server ./server COPY --from=base $APP_PATH/public ./public COPY --from=base $APP_PATH/.sequelizerc ./.sequelizerc @@ -26,13 +32,6 @@ RUN apt-get update \ && apt-get install -y wget \ && rm -rf /var/lib/apt/lists/* -# Create a non-root user compatible with Debian and BusyBox based images -RUN addgroup --gid 1001 nodejs && \ - adduser --uid 1001 --ingroup nodejs nodejs && \ - chown -R nodejs:nodejs $APP_PATH/build && \ - mkdir -p /var/lib/outline && \ - chown -R nodejs:nodejs /var/lib/outline - ENV FILE_STORAGE_LOCAL_ROOT_DIR=/var/lib/outline/data RUN mkdir -p "$FILE_STORAGE_LOCAL_ROOT_DIR" && \ chown -R nodejs:nodejs "$FILE_STORAGE_LOCAL_ROOT_DIR" && \ diff --git a/Dockerfile.base b/Dockerfile.base index 91f90f3c2a..212442d2d3 100644 --- a/Dockerfile.base +++ b/Dockerfile.base @@ -1,5 +1,5 @@ ARG APP_PATH=/opt/outline -FROM node:20 AS deps +FROM node:22 AS deps ARG APP_PATH WORKDIR $APP_PATH