diff --git a/Dockerfile b/Dockerfile index b3ddd8299..b2328c6c5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,7 +45,7 @@ ARG INSTALL_SOFFICE= # leaner (development dependencies are not installed) and runs faster (among # other things, assets are minified & compressed). ENV NODE_ENV=production - +ENV ETHERPAD_PRODUCTION=true # Install dependencies required for modifying access. RUN apk add shadow # Follow the principle of least privilege: run as unprivileged user. @@ -60,6 +60,7 @@ ARG EP_UID=5001 ARG EP_GID=0 ARG EP_SHELL= +ENV NODE_ENV=production RUN groupadd --system ${EP_GID:+--gid "${EP_GID}" --non-unique} etherpad && \ useradd --system ${EP_UID:+--uid "${EP_UID}" --non-unique} --gid etherpad \ diff --git a/src/bin/installDeps.sh b/src/bin/installDeps.sh index ed34a79c0..d4f6b1e85 100755 --- a/src/bin/installDeps.sh +++ b/src/bin/installDeps.sh @@ -1,5 +1,6 @@ #!/bin/sh + # Move to the Etherpad base directory. MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1 cd "${MY_DIR}/../.." || exit 1 @@ -36,14 +37,22 @@ if [ ! -f "$settings" ]; then cp settings.json.template "$settings" || exit 1 fi + log "Installing dependencies..." -( - mkdir -p node_modules && - cd node_modules && - { [ -d ep_etherpad-lite ] || ln -sf ../src ep_etherpad-lite; } && - cd ep_etherpad-lite && - npm ci --no-optional --omit=optional --include=dev --lockfile-version 1 -) || exit 1 +(mkdir -p node_modules && +cd node_modules && +{ [ -d ep_etherpad-lite ] || ln -sf ../src ep_etherpad-lite; } && +cd ep_etherpad-lite) + +cd src + +if [ -z "${ETHERPAD_PRODUCTION}" ]; then + log "Installing dev dependencies" + npm ci --no-optional --omit=optional --include=dev --lockfile-version 1 || exit 1 +else + log "Installing production dependencies" + npm ci --no-optional --omit=optional --omit=dev --lockfile-version 1 --production || exit 1 +fi # Remove all minified data to force node creating it new log "Clearing minified cache..."