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.
pull/5802/head
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 # leaner (development dependencies are not installed) and runs faster (among
# other things, assets are minified & compressed). # other things, assets are minified & compressed).
ENV NODE_ENV=production ENV NODE_ENV=production
ENV ETHERPAD_PRODUCTION=true
# Install dependencies required for modifying access. # Install dependencies required for modifying access.
RUN apk add shadow RUN apk add shadow
# Follow the principle of least privilege: run as unprivileged user. # Follow the principle of least privilege: run as unprivileged user.
@ -60,6 +60,7 @@ ARG EP_UID=5001
ARG EP_GID=0 ARG EP_GID=0
ARG EP_SHELL= ARG EP_SHELL=
ENV NODE_ENV=production
RUN groupadd --system ${EP_GID:+--gid "${EP_GID}" --non-unique} etherpad && \ RUN groupadd --system ${EP_GID:+--gid "${EP_GID}" --non-unique} etherpad && \
useradd --system ${EP_UID:+--uid "${EP_UID}" --non-unique} --gid etherpad \ useradd --system ${EP_UID:+--uid "${EP_UID}" --non-unique} --gid etherpad \

View File

@ -1,5 +1,6 @@
#!/bin/sh #!/bin/sh
# Move to the Etherpad base directory. # Move to the Etherpad base directory.
MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1 MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1
cd "${MY_DIR}/../.." || exit 1 cd "${MY_DIR}/../.." || exit 1
@ -36,14 +37,22 @@ if [ ! -f "$settings" ]; then
cp settings.json.template "$settings" || exit 1 cp settings.json.template "$settings" || exit 1
fi fi
log "Installing dependencies..." log "Installing dependencies..."
( (mkdir -p node_modules &&
mkdir -p node_modules && cd node_modules &&
cd node_modules && { [ -d ep_etherpad-lite ] || ln -sf ../src ep_etherpad-lite; } &&
{ [ -d ep_etherpad-lite ] || ln -sf ../src ep_etherpad-lite; } && cd ep_etherpad-lite)
cd ep_etherpad-lite &&
npm ci --no-optional --omit=optional --include=dev --lockfile-version 1 cd src
) || exit 1
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 # Remove all minified data to force node creating it new
log "Clearing minified cache..." log "Clearing minified cache..."