| 1 | FROM node:lts-alpine3.23 |
| 2 | |
| 3 | # Arguments |
| 4 | ARG APP_HOME=/home/node/app |
| 5 | |
| 6 | # Install system dependencies |
| 7 | # "Don't rely on the base image for tools; if you call it, you install it." ;) |
| 8 | RUN apk add --no-cache gcompat tini git git-lfs su-exec shadow dos2unix |
| 9 | |
| 10 | # Create app directory and set ownership |
| 11 | WORKDIR ${APP_HOME} |
| 12 | RUN chown node:node ${APP_HOME} |
| 13 | |
| 14 | # Set NODE_ENV to production |
| 15 | ENV NODE_ENV=production |
| 16 | |
| 17 | # Bundle app source and set ownership |
| 18 | COPY --chown=node:node . ./ |
| 19 | |
| 20 | RUN \ |
| 21 | echo "*** Install npm packages ***" && \ |
| 22 | npm ci --no-audit --no-fund --loglevel=error --no-progress --omit=dev --ignore-scripts && npm cache clean --force |
| 23 | |
| 24 | # Create config directory and link config.yaml. Added hardcoded dirs(constants.js?) |
| 25 | # that must be present for Non-Root Mode and volumeless docker runs. |
| 26 | RUN \ |
| 27 | rm -f "config.yaml" || true && \ |
| 28 | mkdir -p config data plugins public/scripts/extensions/third-party backups && \ |
| 29 | chown -R node:node config data plugins public/scripts/extensions/third-party backups && \ |
| 30 | ln -s "./config/config.yaml" "config.yaml" |
| 31 | |
| 32 | # Pre-compile public libraries |
| 33 | RUN \ |
| 34 | echo "*** Run Webpack ***" && \ |
| 35 | node "./docker/build-lib.js" |
| 36 | |
| 37 | # Set the entrypoint script and cleanup |
| 38 | RUN \ |
| 39 | echo "*** Cleanup ***" && \ |
| 40 | mv "./docker/docker-entrypoint.sh" "./" && \ |
| 41 | echo "*** Make docker-entrypoint.sh executable ***" && \ |
| 42 | chmod +x "./docker-entrypoint.sh" && \ |
| 43 | echo "*** Convert line endings to Unix format ***" && \ |
| 44 | dos2unix "./docker-entrypoint.sh" && \ |
| 45 | rm -rf "./docker" |
| 46 | |
| 47 | # Fix extension repos permissions |
| 48 | RUN git config --global --add safe.directory "*" |
| 49 | |
| 50 | EXPOSE 8000 |
| 51 | |
| 52 | # Ensure proper handling of kernel signals |
| 53 | ENTRYPOINT ["tini", "--", "./docker-entrypoint.sh"] |