Optimize/docker container (#5800)

* Bumped ueberdb2 to 4.1.1

* Install only production ready dependencies.

* Added optimized Dockerfile.

* Fixed variable detection.

* Move to own variable for detecting production build.

* Use shell syntax for parameter expansion.

* Use shell as default.
This commit is contained in:
SamTV12345 2023-07-01 19:23:17 +02:00 committed by GitHub
parent 8ab82d713d
commit 9a679aca56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 8 deletions

View File

@ -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 \

View File

@ -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..."