Fix installation of local plugins

This commit is contained in:
Cristian Consonni 2025-03-23 17:56:52 +01:00 committed by SamTV12345
parent d61578d680
commit b3a0c3d426
3 changed files with 71 additions and 7 deletions

View file

@ -134,15 +134,20 @@ FROM build_${BUILD_ENV} AS development
ARG ETHERPAD_PLUGINS= ARG ETHERPAD_PLUGINS=
ARG ETHERPAD_LOCAL_PLUGINS= ARG ETHERPAD_LOCAL_PLUGINS=
ARG ETHERPAD_LOCAL_PLUGINS_ENV=
ARG ETHERPAD_GITHUB_PLUGINS= ARG ETHERPAD_GITHUB_PLUGINS=
COPY --chown=etherpad:etherpad ./src/ ./src/ COPY --chown=etherpad:etherpad ./src/ ./src/
COPY --chown=etherpad:etherpad --from=adminbuild /opt/etherpad-lite/src/ templates/admin./src/templates/admin COPY --chown=etherpad:etherpad --from=adminbuild /opt/etherpad-lite/src/ templates/admin./src/templates/admin
COPY --chown=etherpad:etherpad --from=adminbuild /opt/etherpad-lite/src/static/oidc ./src/static/oidc COPY --chown=etherpad:etherpad --from=adminbuild /opt/etherpad-lite/src/static/oidc ./src/static/oidc
COPY --chown=etherpad:etherpad ./local_plugin[s] ./local_plugins/
RUN bash -c ./bin/installLocalPlugins.sh
RUN bin/installDeps.sh && \ RUN bin/installDeps.sh && \
if [ ! -z "${ETHERPAD_PLUGINS}" ] || [ ! -z "${ETHERPAD_LOCAL_PLUGINS}" ] || [ ! -z "${ETHERPAD_GITHUB_PLUGINS}" ]; then \ if [ ! -z "${ETHERPAD_PLUGINS}" ] || [ ! -z "${ETHERPAD_GITHUB_PLUGINS}" ]; then \
pnpm run plugins i ${ETHERPAD_PLUGINS} ${ETHERPAD_LOCAL_PLUGINS:+--path ${ETHERPAD_LOCAL_PLUGINS}} ${ETHERPAD_GITHUB_PLUGINS:+--github ${ETHERPAD_GITHUB_PLUGINS}}; \ pnpm run plugins i ${ETHERPAD_PLUGINS} ${ETHERPAD_GITHUB_PLUGINS:+--github ${ETHERPAD_GITHUB_PLUGINS}}; \
fi fi
@ -150,6 +155,7 @@ FROM build_${BUILD_ENV} AS production
ARG ETHERPAD_PLUGINS= ARG ETHERPAD_PLUGINS=
ARG ETHERPAD_LOCAL_PLUGINS= ARG ETHERPAD_LOCAL_PLUGINS=
ARG ETHERPAD_LOCAL_PLUGINS_ENV=
ARG ETHERPAD_GITHUB_PLUGINS= ARG ETHERPAD_GITHUB_PLUGINS=
ENV NODE_ENV=production ENV NODE_ENV=production
@ -159,9 +165,13 @@ COPY --chown=etherpad:etherpad ./src ./src
COPY --chown=etherpad:etherpad --from=adminbuild /opt/etherpad-lite/src/templates/admin ./src/templates/admin COPY --chown=etherpad:etherpad --from=adminbuild /opt/etherpad-lite/src/templates/admin ./src/templates/admin
COPY --chown=etherpad:etherpad --from=adminbuild /opt/etherpad-lite/src/static/oidc ./src/static/oidc COPY --chown=etherpad:etherpad --from=adminbuild /opt/etherpad-lite/src/static/oidc ./src/static/oidc
RUN bin/installDeps.sh && rm -rf ~/.npm && rm -rf ~/.local && rm -rf ~/.cache && \ COPY --chown=etherpad:etherpad ./local_plugin[s] ./local_plugins/
if [ ! -z "${ETHERPAD_PLUGINS}" ] || [ ! -z "${ETHERPAD_LOCAL_PLUGINS}" ] || [ ! -z "${ETHERPAD_GITHUB_PLUGINS}" ]; then \
pnpm run plugins i ${ETHERPAD_PLUGINS} ${ETHERPAD_LOCAL_PLUGINS:+--path ${ETHERPAD_LOCAL_PLUGINS}} ${ETHERPAD_GITHUB_PLUGINS:+--github ${ETHERPAD_GITHUB_PLUGINS}}; \ RUN bash -c ./bin/installLocalPlugins.sh
RUN bin/installDeps.sh && \
if [ ! -z "${ETHERPAD_PLUGINS}" ] || [ ! -z "${ETHERPAD_GITHUB_PLUGINS}" ]; then \
pnpm run plugins i ${ETHERPAD_PLUGINS} ${ETHERPAD_GITHUB_PLUGINS:+--github ${ETHERPAD_GITHUB_PLUGINS}}; \
fi fi
# Copy the configuration file. # Copy the configuration file.

51
bin/installLocalPlugins.sh Executable file
View file

@ -0,0 +1,51 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
trim() {
local var="$*"
# remove leading whitespace characters
var="${var#"${var%%[![:space:]]*}"}"
# remove trailing whitespace characters
var="${var%"${var##*[![:space:]]}"}"
printf '%s' "$var"
}
# Move to the Etherpad base directory.
MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1
cd "${MY_DIR}/.." || exit 1
# Source constants and useful functions
. bin/functions.sh
PNPM_OPTIONS=
if [ ! -z "${NODE_ENV-}" ]; then
if [ "$NODE_ENV" == 'production' ]; then
PNPM_OPTIONS='--prod'
fi
fi
if [ ! -z "${ETHERPAD_LOCAL_PLUGINS_ENV-}" ]; then
if [ "$ETHERPAD_LOCAL_PLUGINS_ENV" == 'production' ]; then
PNPM_OPTIONS='--prod'
elif [ "$ETHERPAD_LOCAL_PLUGINS_ENV" == 'development' ]; then
PNPM_OPTIONS='-D'
fi
fi
if [ ! -z "${ETHERPAD_LOCAL_PLUGINS}" ]; then
readarray -d ' ' plugins <<< "${ETHERPAD_LOCAL_PLUGINS}"
for plugin in "${plugins[@]}"; do
plugin=$(trim "$plugin")
if [ -d "local_plugins/${plugin}" ]; then
echo "Installing plugin: '${plugin}'"
pnpm install -w ${PNPM_OPTIONS:-} "local_plugins/${plugin}/"
else
( echo "Error. Directory 'local_plugins/${plugin}' for local plugin " \
"'${plugin}' missing" >&2 )
exit 1
fi
done
else
echo 'No local plugings to install.'
fi

3
local_plugins/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
# ignore everything
*
!.gitignore