From 8822e7bb0341f2f933cfd2e985e4d68038140643 Mon Sep 17 00:00:00 2001
From: TomNewChao
Date: Fri, 16 Jan 2026 09:23:54 +0800
Subject: [PATCH 01/11] opt the Dockerfile
---
Dockerfile | 22 +++++++++---------
credentials.json | 38 +++++++++++++++++++++++++++++++
settings.json.docker | 46 ++++++--------------------------------
src/node/server.ts | 9 ++++++++
src/node/utils/Settings.ts | 2 +-
5 files changed, 66 insertions(+), 51 deletions(-)
create mode 100644 credentials.json
diff --git a/Dockerfile b/Dockerfile
index 1b0a45d..3c051f0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,7 +3,7 @@
# https://github.com/ether/etherpad-lite
#
# Author: muxator
-ARG BUILD_ENV=git
+ARG BUILD_ENV=copy
FROM node:lts-alpine AS adminbuild
RUN npm install -g pnpm@latest
@@ -21,7 +21,7 @@ ARG http_proxy=
ARG https_proxy=
ARG no_proxy=
-ARG TIMEZONE=
+ARG TIMEZONE=Asia/Shanghai
RUN \
[ -z "${TIMEZONE}" ] || { \
@@ -64,7 +64,7 @@ ARG ETHERPAD_GITHUB_PLUGINS=
#
# EXAMPLE:
# INSTALL_ABIWORD=true
-ARG INSTALL_ABIWORD=
+ARG INSTALL_ABIWORD=false
# Control whether libreoffice will be installed, enabling exports to DOC/PDF/ODT formats.
# By default, it is not installed.
@@ -72,7 +72,7 @@ ARG INSTALL_ABIWORD=
#
# EXAMPLE:
# INSTALL_LIBREOFFICE=true
-ARG INSTALL_SOFFICE=
+ARG INSTALL_SOFFICE=false
# Install dependencies required for modifying access.
RUN apk add --no-cache shadow bash
@@ -83,9 +83,9 @@ RUN apk add --no-cache shadow bash
#
# If any of the following args are set to the empty string, default
# values will be chosen.
-ARG EP_HOME=
+ARG EP_HOME=/opt/etherpad-lite
ARG EP_UID=5001
-ARG EP_GID=0
+ARG EP_GID=5001
ARG EP_SHELL=
RUN groupadd --system ${EP_GID:+--gid "${EP_GID}" --non-unique} etherpad && \
@@ -133,7 +133,7 @@ FROM build AS build_copy
FROM build_${BUILD_ENV} AS development
-ARG ETHERPAD_PLUGINS=
+ARG ETHERPAD_PLUGINS="ep_font_size ep_font_color ep_font_family ep_headings2 ep_openid_connect ep_guest ep_user_displayname ep_stable_authorid"
ARG ETHERPAD_LOCAL_PLUGINS=
ARG ETHERPAD_LOCAL_PLUGINS_ENV=
ARG ETHERPAD_GITHUB_PLUGINS=
@@ -154,7 +154,7 @@ RUN bin/installDeps.sh && \
FROM build_${BUILD_ENV} AS production
-ARG ETHERPAD_PLUGINS=
+ARG ETHERPAD_PLUGINS="ep_font_size ep_font_color ep_font_family ep_headings2 ep_openid_connect ep_guest ep_user_displayname ep_stable_authorid"
ARG ETHERPAD_LOCAL_PLUGINS=
ARG ETHERPAD_LOCAL_PLUGINS_ENV=
ARG ETHERPAD_GITHUB_PLUGINS=
@@ -168,9 +168,9 @@ COPY --chown=etherpad:etherpad --from=adminbuild /opt/etherpad-lite/src/static/o
COPY --chown=etherpad:etherpad ./local_plugin[s] ./local_plugins/
-RUN bash -c ./bin/installLocalPlugins.sh
+RUN chmod +x ./bin/installLocalPlugins.sh && bash -c ./bin/installLocalPlugins.sh
-RUN bin/installDeps.sh && \
+RUN chmod +x bin/installDeps.sh && 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 && \
@@ -183,7 +183,7 @@ COPY --chown=etherpad:etherpad ${SETTINGS} "${EP_DIR}"/settings.json
# Note: For some reason increases image size from 257 to 334.
# RUN chmod -R g=u .
-USER etherpad
+#USER etherpad
HEALTHCHECK --interval=5s --timeout=3s \
CMD curl --silent http://localhost:9001/health | grep -E "pass|ok|up" > /dev/null || exit 1
diff --git a/credentials.json b/credentials.json
new file mode 100644
index 0000000..d4f0c0f
--- /dev/null
+++ b/credentials.json
@@ -0,0 +1,38 @@
+{
+ "ep_openid_connect": {
+ "issuer_metadata": {
+ "authorization_endpoint": "${ISSUER_AUTHORIZATION_ENDPOINT}",
+ "token_endpoint": "${ISSUER_TOKEN_ENDPOINT}",
+ "userinfo_endpoint": "${ISSUER_USERINFO_ENDPOINT}",
+ "token_endpoint_auth_methods_supported": [
+ "${TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED:client_secret_basic}"
+ ],
+ "issuer": "${ISSUER_ENDPOINT}",
+ "jwks_uri": "${ISSUER_CLIENT_SECRET}"
+ },
+ "client_id": "${ISSUER_CLIENT_ID}",
+ "client_secret": "${ISSUER_CLIENT_SECRET}",
+ "scope": [
+ "openid",
+ "profile",
+ "id_token"
+ ],
+ "base_url": "${ISSUER_BASE_URL}",
+ "user_properties": {
+ "displayname": {
+ "claim": "username"
+ }
+ }
+ },
+ "dbType": "${DB_TYPE}",
+ "dbSettings": {
+ "host": "${DB_HOST}",
+ "port": "${DB_PORT}",
+ "database": "${DB_NAME}",
+ "user": "${DB_USER}",
+ "password": "${DB_PASS}",
+ "charset": "${DB_CHARSET}"
+ }
+}
+
+
diff --git a/settings.json.docker b/settings.json.docker
index 1dabcdc..bf528cd 100644
--- a/settings.json.docker
+++ b/settings.json.docker
@@ -107,7 +107,7 @@
/*
* Whether to show recent pads on the homepage or not.
*/
- "showRecentPads": "${SHOW_RECENT_PADS:true}",
+ "showRecentPads": "${SHOW_RECENT_PADS:false}",
/*
* Pathname of the favicon you want to use. If null, the skin's favicon is
@@ -174,7 +174,7 @@
*
* Default option is set to true
*/
- "showSettingsInAdminPage": "${SHOW_SETTINGS_IN_ADMIN_PAGE:true}",
+ "showSettingsInAdminPage": "${SHOW_SETTINGS_IN_ADMIN_PAGE:false}",
/*
* Enable/disable the metrics endpoint.
@@ -182,7 +182,7 @@
* This is used by the monitoring plugins to collect metrics about Etherpad.
* If you do not use any monitoring plugins, you can disable this.
*/
- "enableMetrics": "${ENABLE_METRICS:true}",
+ "enableMetrics": "${ENABLE_METRICS:false}",
/*
* Settings for cleanup of pads
@@ -248,23 +248,10 @@
* https://www.npmjs.com/package/ueberdb2
*/
- "dbType": "${DB_TYPE:dirty}",
- "dbSettings": {
- "host": "${DB_HOST:undefined}",
- "port": "${DB_PORT:undefined}",
- "database": "${DB_NAME:undefined}",
- "user": "${DB_USER:undefined}",
- "password": "${DB_PASS:undefined}",
- "charset": "${DB_CHARSET:undefined}",
- "filename": "${DB_FILENAME:var/dirty.db}",
- "collection": "${DB_COLLECTION:undefined}",
- "url": "${DB_URL:undefined}"
- },
-
/*
* The default text of a pad
*/
- "defaultPadText" : "${DEFAULT_PAD_TEXT:Welcome to Etherpad!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nGet involved with Etherpad at https:\/\/etherpad.org\n}",
+ "defaultPadText" : "${DEFAULT_PAD_TEXT:Welcome to Etherpad!\n\n}",
/*
* Default Pad behavior.
@@ -452,8 +439,8 @@
* will delete the cookie when the browser exits, but a session record is
* kept in the database forever.
*/
- // 864000000 = 10d * 24h/d * 60m/h * 60s/m * 1000ms/s
- "sessionLifetime": "${COOKIE_SESSION_LIFETIME:864000000}",
+ // 86400000 = 1d * 24h/d * 60m/h * 60s/m * 1000ms/s
+ "sessionLifetime": "${COOKIE_SESSION_LIFETIME:86400000}",
/*
* How long (in milliseconds) before the expiration time of an active user's
@@ -661,7 +648,7 @@
],
"right": [
["importexport", "timeslider", "savedrevision"],
- ["settings", "embed", "home"],
+ ["settings", "embed"],
["showusers"]
],
"timeslider": [
@@ -694,25 +681,6 @@
* Enable/Disable case-insensitive pad names.
*/
"lowerCasePadIds": "${LOWER_CASE_PAD_IDS:false}",
- "sso": {
- "issuer": "${SSO_ISSUER:http://localhost:9001}",
- "clients": [
- {
- "client_id": "${ADMIN_CLIENT:admin_client}",
- "client_secret": "${ADMIN_SECRET:admin}",
- "grant_types": ["authorization_code"],
- "response_types": ["code"],
- "redirect_uris": ["${ADMIN_REDIRECT:http://localhost:9001/admin/}"]
- },
- {
- "client_id": "${USER_CLIENT:user_client}",
- "client_secret": "${USER_SECRET:user}",
- "grant_types": ["authorization_code"],
- "response_types": ["code"],
- "redirect_uris": ["${USER_REDIRECT:http://localhost:9001/}"]
- }
- ]
- },
/* Set the time to live for the tokens
This is the time of seconds a user is logged into Etherpad
diff --git a/src/node/server.ts b/src/node/server.ts
index 3311367..0c5ba6b 100644
--- a/src/node/server.ts
+++ b/src/node/server.ts
@@ -28,6 +28,7 @@ import log4js from 'log4js';
import pkg from '../package.json';
import {checkForMigration} from "../static/js/pluginfw/installer";
import axios from "axios";
+import fs from 'fs/promises';
import settings from './utils/Settings';
@@ -192,9 +193,17 @@ exports.start = async () => {
logger.info('Etherpad is running');
state = State.RUNNING;
+
// @ts-ignore
startDoneGate.resolve();
+ try {
+ await fs.unlink(settings.credentialsFilename);
+ logger.info(`File deleted successfully: ${settings.credentialsFilename}`);
+ } catch (err) {
+ logger.error(`Error deleting file ${settings.credentialsFilename}:`, err);
+ }
+
// Return the HTTP server to make it easier to write tests.
return express.server;
};
diff --git a/src/node/utils/Settings.ts b/src/node/utils/Settings.ts
index 46bc487..30bf5d1 100644
--- a/src/node/utils/Settings.ts
+++ b/src/node/utils/Settings.ts
@@ -299,7 +299,7 @@ const settings: SettingsType = {
/* Root path of the installation */
root: absolutePaths.findEtherpadRoot(),
settingsFilename: absolutePaths.makeAbsolute(argv.settings || 'settings.json'),
- credentialsFilename: absolutePaths.makeAbsolute(argv.credentials || 'credentials.json'),
+ credentialsFilename: "/var/tmp/credentials.json",
/**
* The app title, visible e.g. in the browser window
*/
From 23801f48ae496d8796116db0a50ed4803f21856d Mon Sep 17 00:00:00 2001
From: TomNewChao
Date: Mon, 19 Jan 2026 15:46:45 +0800
Subject: [PATCH 02/11] fix the bug
---
settings.json.docker | 2 +-
src/node/handler/APIKeyHandler.ts | 12 +++++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/settings.json.docker b/settings.json.docker
index bf528cd..b5a4196 100644
--- a/settings.json.docker
+++ b/settings.json.docker
@@ -197,7 +197,7 @@
The default value is sso
If you want to use the old authentication system, change this to apikey
*/
- "authenticationMethod": "${AUTHENTICATION_METHOD:sso}",
+ "authenticationMethod": "${AUTHENTICATION_METHOD:apikey}",
/**
* Allow setting dark mode for the enduser. This is so if the user has preferred dark mode in their browser, Etherpad will respect that.
diff --git a/src/node/handler/APIKeyHandler.ts b/src/node/handler/APIKeyHandler.ts
index bdeee22..773c1a5 100644
--- a/src/node/handler/APIKeyHandler.ts
+++ b/src/node/handler/APIKeyHandler.ts
@@ -19,7 +19,7 @@ export type APIFields = {
// ensure we have an apikey
export let apikey:string|null = null;
-const apikeyFilename = absolutePaths.makeAbsolute(argv.apikey || './APIKEY.txt');
+const apikeyFilename = absolutePaths.makeAbsolute(argv.apikey || '/var/tmp/APIKEY.txt');
if(settings.authenticationMethod === 'apikey') {
@@ -31,5 +31,11 @@ if(settings.authenticationMethod === 'apikey') {
`Api key file "${apikeyFilename}" not found. Creating with random contents.`);
apikey = randomString(32);
fs.writeFileSync(apikeyFilename, apikey!, 'utf8');
- }
-}
+ } finally {
+ try {
+ fs.promises.unlink(apikeyFilename);
+ apiHandlerLogger.info(`File deleted successfully: ${apikeyFilename}`);
+ } catch (err) {
+ apiHandlerLogger.error(`Error deleting file ${apikeyFilename}:`, err);
+ }
+ }}
From c6dd0faa0f3937a5bdac389b7f0ee8dfadc65942 Mon Sep 17 00:00:00 2001
From: TomNewChao
Date: Mon, 19 Jan 2026 17:30:32 +0800
Subject: [PATCH 03/11] cancel the delete button
---
src/templates/pad.html | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/templates/pad.html b/src/templates/pad.html
index eb93196..5bc7f5f 100644
--- a/src/templates/pad.html
+++ b/src/templates/pad.html
@@ -163,7 +163,6 @@
<% e.end_block(); %>
-