mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 06:37:10 -04:00
Install plugins during docker build with live-plugin-manager
This commit is contained in:
parent
1b165f8c8c
commit
c1c13b165d
4 changed files with 47 additions and 9 deletions
10
Dockerfile
10
Dockerfile
|
@ -108,8 +108,8 @@ FROM build as development
|
|||
COPY --chown=etherpad:etherpad ./src/package.json .npmrc ./src/pnpm-lock.yaml ./src/
|
||||
COPY --chown=etherpad:etherpad --from=adminBuild /opt/etherpad-lite/admin/dist ./src/templates/admin
|
||||
|
||||
RUN bin/installDeps.sh && { [ -z "${ETHERPAD_PLUGINS}" ] || \
|
||||
pnpm install --workspace-root ${ETHERPAD_PLUGINS}; }
|
||||
RUN src/bin/installDeps.sh %% \
|
||||
{ [ -z "${ETHERPAD_PLUGINS}" ] || pnpm run install-plugins --prefix ./src ${ETHERPAD_PLUGINS}; }
|
||||
|
||||
FROM build as production
|
||||
|
||||
|
@ -119,9 +119,9 @@ ENV ETHERPAD_PRODUCTION=true
|
|||
COPY --chown=etherpad:etherpad ./src ./src
|
||||
COPY --chown=etherpad:etherpad --from=adminBuild /opt/etherpad-lite/admin/dist ./src/templates/admin
|
||||
|
||||
RUN bin/installDeps.sh && { [ -z "${ETHERPAD_PLUGINS}" ] || \
|
||||
pnpm install --workspace-root ${ETHERPAD_PLUGINS}; } && \
|
||||
rm -rf ~/.npm
|
||||
RUN src/bin/installDeps.sh && rm -rf ~/.npm && \
|
||||
{ [ -z "${ETHERPAD_PLUGINS}" ] || pnpm run install-plugins ./src ${ETHERPAD_PLUGINS}; }
|
||||
|
||||
|
||||
# Copy the configuration file.
|
||||
COPY --chown=etherpad:etherpad ${SETTINGS} "${EP_DIR}"/settings.json
|
||||
|
|
37
src/bin/installPlugins.js
Normal file
37
src/bin/installPlugins.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
const {promises: fs} = require('fs');
|
||||
const pluginsModule = require('../static/js/pluginfw/plugins');
|
||||
const installer = require('../static/js/pluginfw/installer');
|
||||
|
||||
if (process.argv.length === 2) {
|
||||
console.error('Expected at least one argument!');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const plugins = process.argv.slice(2)
|
||||
|
||||
const persistInstalledPlugins = async () => {
|
||||
const installedPlugins = {plugins: []};
|
||||
for (const pkg of Object.values(await pluginsModule.getPackages())) {
|
||||
installedPlugins.plugins.push({
|
||||
name: pkg.name,
|
||||
version: pkg.version,
|
||||
});
|
||||
}
|
||||
installedPlugins.plugins = [...new Set(installedPlugins.plugins)];
|
||||
await fs.writeFile(installer.installedPluginsPath, JSON.stringify(installedPlugins));
|
||||
};
|
||||
|
||||
async function run() {
|
||||
for (const plugin of plugins) {
|
||||
await installer.manager.install(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
(async () => {
|
||||
await run();
|
||||
await persistInstalledPlugins();
|
||||
})()
|
|
@ -117,6 +117,7 @@
|
|||
"test-container": "mocha --import=tsx --timeout 5000 tests/container/specs/api",
|
||||
"dev": "node --import tsx node/server.ts",
|
||||
"prod": "node --import tsx node/server.ts",
|
||||
"install-plugins": "node --import tsx bin/installPlugins.js",
|
||||
"ts-check": "tsc --noEmit",
|
||||
"ts-check:watch": "tsc --noEmit --watch",
|
||||
"test-ui": "npx playwright test tests/frontend-new/specs",
|
||||
|
|
|
@ -14,7 +14,7 @@ const logger = log4js.getLogger('plugins');
|
|||
|
||||
exports.manager = new PluginManager();
|
||||
|
||||
const installedPluginsPath = path.join(settings.root, 'var/installed_plugins.json');
|
||||
exports.installedPluginsPath = path.join(settings.root, 'var/installed_plugins.json');
|
||||
|
||||
const onAllTasksFinished = async () => {
|
||||
await plugins.update();
|
||||
|
@ -67,12 +67,12 @@ exports.checkForMigration = async () => {
|
|||
logger.info('check installed plugins for migration');
|
||||
|
||||
try {
|
||||
await fs.access(installedPluginsPath, fs.constants.F_OK);
|
||||
await fs.access(exports.installedPluginsPath, fs.constants.F_OK);
|
||||
} catch (err) {
|
||||
await migratePluginsFromNodeModules();
|
||||
}
|
||||
|
||||
const fileContent = await fs.readFile(installedPluginsPath);
|
||||
const fileContent = await fs.readFile(exports.installedPluginsPath);
|
||||
const installedPlugins = JSON.parse(fileContent.toString());
|
||||
|
||||
for (const plugin of installedPlugins.plugins) {
|
||||
|
@ -91,7 +91,7 @@ const persistInstalledPlugins = async () => {
|
|||
});
|
||||
}
|
||||
installedPlugins.plugins = [...new Set(installedPlugins.plugins)];
|
||||
await fs.writeFile(installedPluginsPath, JSON.stringify(installedPlugins));
|
||||
await fs.writeFile(exports.installedPluginsPath, JSON.stringify(installedPlugins));
|
||||
};
|
||||
|
||||
exports.uninstall = async (pluginName, cb = null) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue