diff --git a/Dockerfile b/Dockerfile index 7df733d2c..a19ee32ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,6 +41,14 @@ ARG SETTINGS=./settings.json.docker # ETHERPAD_PLUGINS="ep_codepad ep_author_neat" ARG ETHERPAD_PLUGINS= +# local plugins to install while building the container. By default no plugins are +# installed. +# If given a value, it has to be a space-separated, quoted list of plugin names. +# +# EXAMPLE: +# ETHERPAD_LOCAL_PLUGINS="../ep_my_plugin ../ep_another_plugin" +ARG ETHERPAD_LOCAL_PLUGINS= + # Control whether abiword will be installed, enabling exports to DOC/PDF/ODT formats. # By default, it is not installed. # If given any value, abiword will be installed. @@ -110,7 +118,10 @@ COPY --chown=etherpad:etherpad ./src/package.json .npmrc ./src/ COPY --chown=etherpad:etherpad --from=adminBuild /opt/etherpad-lite/admin/dist ./src/templates/admin RUN bin/installDeps.sh && \ - { [ -z "${ETHERPAD_PLUGINS}" ] || pnpm run install-plugins ${ETHERPAD_PLUGINS}; } + if [ ! -z "${ETHERPAD_PLUGINS}" ] || [ ! -z "${ETHERPAD_LOCAL_PLUGINS}" ]; then \ + pnpm run install-plugins ${ETHERPAD_PLUGINS} ${ETHERPAD_LOCAL_PLUGINS:+--path ${ETHERPAD_LOCAL_PLUGINS}}; \ + fi + FROM build as production @@ -121,7 +132,9 @@ COPY --chown=etherpad:etherpad ./src ./src COPY --chown=etherpad:etherpad --from=adminBuild /opt/etherpad-lite/admin/dist ./src/templates/admin RUN bin/installDeps.sh && rm -rf ~/.npm && \ - { [ -z "${ETHERPAD_PLUGINS}" ] || pnpm run install-plugins ${ETHERPAD_PLUGINS}; } + if [ ! -z "${ETHERPAD_PLUGINS}" ] || [ ! -z "${ETHERPAD_LOCAL_PLUGINS}" ]; then \ + pnpm run install-plugins ${ETHERPAD_PLUGINS} ${ETHERPAD_LOCAL_PLUGINS:+--path ${ETHERPAD_LOCAL_PLUGINS}}; \ + fi # Copy the configuration file. diff --git a/bin/installPlugins.ts b/bin/installPlugins.ts index 8a6a71345..2d4f63355 100644 --- a/bin/installPlugins.ts +++ b/bin/installPlugins.ts @@ -10,18 +10,19 @@ if (process.argv.length === 2) { process.exit(1); } -let plugins = process.argv.slice(2) -let installFromPath = false; +let args = process.argv.slice(2) -const thirdOptPlug = plugins[0] +let registryPlugins: string[] = []; +let localPlugins: string[] = []; -console.log("Third option: ", thirdOptPlug) -if (thirdOptPlug && thirdOptPlug.includes('path')) { - installFromPath = true - plugins.splice(plugins.indexOf('--path'), 1); +if (args.indexOf('--path') !== -1) { + const indexToSplit = args.indexOf('--path'); + registryPlugins = args.slice(0, indexToSplit); + localPlugins = args.slice(indexToSplit + 1); +} else { + registryPlugins = args; } - const persistInstalledPlugins = async () => { const plugins:PackageData[] = [] const installedPlugins = {plugins: plugins}; @@ -36,15 +37,15 @@ const persistInstalledPlugins = async () => { }; async function run() { - for (const plugin of plugins) { - if(installFromPath) { - console.log(`Installing plugin from path: ${plugin}`); - await linkInstaller.installFromPath(plugin); - continue; - } + for (const plugin of registryPlugins) { console.log(`Installing plugin from registry: ${plugin}`) await linkInstaller.installPlugin(plugin); } + + for (const plugin of localPlugins) { + console.log(`Installing plugin from path: ${plugin}`); + await linkInstaller.installFromPath(plugin); + } } (async () => {