Compare commits

..

24 commits

Author SHA1 Message Date
e49f063e6b docs: Update content 2022-05-08 21:26:29 +02:00
53c863d76c refactor: Clean options & parameters in docker-compose.yml 2022-05-08 21:03:05 +02:00
7f11442012 fix: Clean indent 2022-05-08 21:02:30 +02:00
b93a767757 feat: Add settings for ep_expiration plugin 2022-05-08 21:02:12 +02:00
9304d4ce07 feat: Run as user & fix plugin issues 2022-05-08 21:01:32 +02:00
a850f2ceff feat: Bump to latest etherpad & node version 2022-05-08 21:00:37 +02:00
58a1320e7b fix: Remove useless session key setting 2022-05-08 20:59:52 +02:00
5a658e416b refactor: Use shell version of URL parser 2022-05-08 20:58:31 +02:00
b9ebe9704e feat: Add makefile 2022-05-08 20:40:53 +02:00
1f4b9248d5 Bump version 2021-09-16 11:46:17 +02:00
67328423b9 Downgrade node version 2021-06-10 14:36:32 +02:00
edb63a971c Lower version 2021-06-03 11:12:28 +02:00
9ffe51eb5c fix: improve installation steps 2021-04-30 15:06:51 +02:00
7d8c313f60 fix: install extensions as project deps 2021-04-30 15:02:12 +02:00
3aa7fd1bcf fix: remove charset from entrypoint 2021-04-30 14:46:21 +02:00
29926827e4 fix: add missing comma in config 2021-04-30 14:33:19 +02:00
3a357cd480 feat: add support for offline edit 2021-04-30 14:30:58 +02:00
03d46458e1 feat: prompt for name after 5 seconds 2021-04-30 14:29:38 +02:00
0e9bf1bd91 fix: use mariadb instead of mysql client 2021-04-30 14:26:50 +02:00
f83ffb2776 chore: improve configuration 2021-04-30 14:21:42 +02:00
20d9c94d16 Bump nodejs version + add deleter_after plugin 2021-04-30 14:21:04 +02:00
bf08c7690a chore: set image name in docker-compose.yml 2021-04-30 14:03:29 +02:00
97157e3a2c fix: make sure build does not break 2021-04-30 14:03:13 +02:00
9b43cb41ed Bump Etherpad version to 1.8.13 2021-04-30 11:31:18 +02:00
7 changed files with 207 additions and 196 deletions

View file

@ -1,45 +1,63 @@
# Stable version of etherpad doesn't support npm 2 # Stable version of etherpad doesn't support npm 2
FROM node:14-slim FROM node:18.1
MAINTAINER Glenn Y. Rolland <glenux@glenux.net> MAINTAINER Glenn Y. Rolland <glenux@glenux.net>
ENV ETHERPAD_VERSION 1.8.7 ENV ETHERPAD_VERSION 1.8.18
# RUN = docker run ... + docker commit RUN apt-get update \
RUN apt-get update && \ && apt-get install -y unzip mariadb-client netcat \
apt-get install -y curl unzip mysql-client python netcat && \ && apt-get clean \
rm -r /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& truncate -s 0 /var/log/*log
WORKDIR /opt/ RUN cd /opt \
&& wget \
RUN curl -SL \
https://github.com/ether/etherpad-lite/archive/${ETHERPAD_VERSION}.zip \ https://github.com/ether/etherpad-lite/archive/${ETHERPAD_VERSION}.zip \
> etherpad.zip && unzip etherpad && \ -O etherpad.zip \
rm etherpad.zip && \ && unzip etherpad \
mv etherpad-lite-${ETHERPAD_VERSION} etherpad-lite && rm etherpad.zip \
&& mv etherpad-lite-${ETHERPAD_VERSION} etherpad \
&& useradd --home-dir /opt/etherpad etherpad \
&& chown -R etherpad:etherpad /opt/etherpad
WORKDIR /opt/etherpad-lite COPY --chown=etherpad parseurl.sh /parseurl.sh
COPY --chown=etherpad entrypoint.sh /entrypoint.sh
COPY parseurl.py /parseurl.py
COPY entrypoint.sh /entrypoint.sh
# Pre-install WORKDIR /opt/etherpad
RUN bin/installDeps.sh && rm settings.json \ USER etherpad
&& chmod +x /entrypoint.sh \
&& sed -i 's/^node/exec\ node/' bin/run.sh \ # Pre-install some plugins
&& ln -s var/settings.json settings.json \ RUN bin/installDeps.sh \
&& npm install \ && cd src \
ep_author_neat ep_headings2 \ && npm install --save-prod \
ep_set_title_on_pad ep_adminpads \ github:alxndr42/ep_expiration \
ep_workspaces ep_comments_page \ ep_author_neat \
ep_font_color ep_table_of_contents \ ep_headings2 \
&& npm audit fix ep_comments_page \
ep_font_color \
ep_offline_edit \
ep_prompt_for_name \
ep_workspaces \
ep_table_of_contents \
ep_adminpads \
&& cd .. \
&& rm settings.json \
&& ln -s var/settings.json settings.json
# ep_delete_after_delay \
# ep_set_title_on_pad \
# && sed -i 's/^node/exec\ node/' bin/run.sh \
# ep_mypads # ep_mypads
# meta-données # meta-données
VOLUME /opt/etherpad-lite/var VOLUME /opt/etherpad/var
EXPOSE 9001 EXPOSE 9001
ENTRYPOINT ["/entrypoint.sh"]
CMD ["bin/run.sh", "--root"] ENTRYPOINT ["/entrypoint.sh"]
CMD ["./src/bin/run.sh"]
# bin/run.sh

View file

@ -6,10 +6,19 @@ TAG:=$(shell TZ=UTC date +"%Y%m%d")
all: all:
build: build:
docker build -t $(USERNAME)/$(IMAGE):$(TAG) . docker-compose build
run: run:
# remplir ici docker-compose up --detach
logs:
docker-compose logs -f
shell:
docker-compose exec etherpad bash
kill:
docker-compose kill
test: build test: build
# remplir ici # remplir ici

View file

@ -1,15 +1,7 @@
# Etherpad Lite image for docker # Etherpad Lite image for docker
This is a docker image for [Etherpad Lite](http://etherpad.org/) collaborative
text editor. The Dockerfile for this image has been inspired by the
[official Wordpress](https://registry.hub.docker.com/_/wordpress/) Dockerfile and
[johbo's etherpad-lite](https://registry.hub.docker.com/u/johbo/etherpad-lite/)
image.
This image uses an mysql container for the backend for the pads. It is based This image uses an mysql container for the backend for the pads. It is based
on debian jessie instead of the official node docker image, since the latest on latest nodejs image.
stable version of etherpad-lite does not support npm 2.
## About Etherpad Lite ## About Etherpad Lite
@ -17,7 +9,7 @@ stable version of etherpad-lite does not support npm 2.
Etherpad allows you to edit documents collaboratively in real-time, much like a live multi-player editor that runs in your browser. Write articles, press releases, to-do lists, etc. together with your friends, fellow students or colleagues, all working on the same document at the same time. Etherpad allows you to edit documents collaboratively in real-time, much like a live multi-player editor that runs in your browser. Write articles, press releases, to-do lists, etc. together with your friends, fellow students or colleagues, all working on the same document at the same time.
![alt text](http://i.imgur.com/zYrGkg3.gif "Etherpad in action on PrimaryPad") ![alt text](http://i.imgur.com/zYrGkg3.gif "Etherpad in action")
All instances provide access to all data through a well-documented API and supports import/export to many major data exchange formats. And if the built-in feature set isn't enough for you, there's tons of plugins that allow you to customize your instance to suit your needs. All instances provide access to all data through a well-documented API and supports import/export to many major data exchange formats. And if the built-in feature set isn't enough for you, there's tons of plugins that allow you to customize your instance to suit your needs.
@ -25,26 +17,44 @@ You don't need to set up a server and install Etherpad in order to use it. Just
## Quickstart ## Quickstart
First you need a running mysql container, for example: Copy-paste the following content in a `docker-compose.yml` file
```bash ```yaml
$ docker network create ep_network ---
$ docker run -d --network ep_network -e MYSQL_ROOT_PASSWORD=password --name ep_mysql mysql version: "3.4"
services:
db:
image: mariadb:10.3
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
volumes:
- db_data:/var/lib/mysql
environment:
MARIADB_ROOT_PASSWORD: insecure
MARIADB_DATABASE: etherpad
etherpad:
build:
context: .
dockerfile: Dockerfile
image: glenux/etherpad:latest
environment:
DATABASE_URL: mysql://root:insecure:3306@db/etherpad
ETHERPAD_ADMIN_USER: admin
ETHERPAD_ADMIN_PASSWORD: insecure
NODE_ENV: production
ports:
- 9001:9001
volumes:
db_data:
``` ```
Finally you can start an instance of Etherpad Lite: Then run `docker-compose up`
```bash
$ docker run -d \
--network ep_network \
-e ETHERPAD_DB_HOST=ep_mysql \
-e ETHERPAD_DB_PASSWORD=password \
-p 9001:9001 \
tvelocity/etherpad-lite
```
Etherpad will automatically create an `etherpad` database in the specified mysql Etherpad will automatically create an `etherpad` database in the specified mysql
server if it does not already exist. server if it does not already exist.
You can now access Etherpad Lite from http://localhost:9001/ You can now access Etherpad Lite from http://localhost:9001/
## Environment variables ## Environment variables
@ -53,9 +63,6 @@ This image supports the following environment variables:
* `ETHERPAD_TITLE`: Title of the Etherpad Lite instance. Defaults to "Etherpad". * `ETHERPAD_TITLE`: Title of the Etherpad Lite instance. Defaults to "Etherpad".
* `ETHERPAD_PORT`: Port of the Etherpad Lite instance. Defaults to 9001. * `ETHERPAD_PORT`: Port of the Etherpad Lite instance. Defaults to 9001.
* `ETHERPAD_SESSION_KEY`: Session key for the Etherpad Lite configuraition. You
can set this in case of migrating from another installation. A value is
automatically generated by default.
* `ETHERPAD_ADMIN_PASSWORD`: If set, an admin account is enabled for Etherpad, * `ETHERPAD_ADMIN_PASSWORD`: If set, an admin account is enabled for Etherpad,
and the /admin/ interface is accessible via it. and the /admin/ interface is accessible via it.
@ -65,7 +72,7 @@ Otherwise the user can set it to another username.
* `ETHERPAD_DB_HOST`: Hostname of the mysql databse to use. Defaults to `mysql` * `ETHERPAD_DB_HOST`: Hostname of the mysql databse to use. Defaults to `mysql`
* `ETHERPAD_DB_USER`: By default Etherpad Lite will attempt to connect as root * `ETHERPAD_DB_USER`: By default Etherpad Lite will attempt to connect as root
to the mysql container. to the mysql container.
* `ETHERPAD_DB_PASSWORD`: MySQL password to use, mandatory. If legacy links * `ETHERPAD_DB_PASS`: MySQL password to use, mandatory. If legacy links
are used and ETHERPAD_DB_USER is root, then `MYSQL_ENV_MYSQL_ROOT_PASSWORD` is are used and ETHERPAD_DB_USER is root, then `MYSQL_ENV_MYSQL_ROOT_PASSWORD` is
automatically used. automatically used.
* `ETHERPAD_DB_NAME`: The mysql database to use. Defaults to *etherpad*. If the * `ETHERPAD_DB_NAME`: The mysql database to use. Defaults to *etherpad*. If the
@ -73,3 +80,4 @@ database is not available, it will be created when the container is launched.
The generated settings.json file will be available as a volume under The generated settings.json file will be available as a volume under
*/opt/etherpad-lite/var/*. */opt/etherpad-lite/var/*.

View file

@ -4,23 +4,25 @@ version: "3.4"
services: services:
db: db:
image: mariadb:10.3 image: mariadb:10.3
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
volumes: volumes:
- db_data:/var/lib/mysql - db_data:/var/lib/mysql
environment: environment:
MYSQL_ROOT_PASSWORD: insecure MARIADB_ROOT_PASSWORD: insecure
MYSQL_DATABASE: etherpad MARIADB_DATABASE: etherpad
etherpad: etherpad:
build: . build:
context: .
dockerfile: Dockerfile
image: glenux/etherpad:latest
environment: environment:
DATABASE_URL: mysql://root:insecure@db/etherpad DATABASE_URL: mysql://root:insecure:3306@db/etherpad
ETHERPAD_ADMIN_USER: admin ETHERPAD_ADMIN_USER: admin
ETHERPAD_ADMIN_PASSWORD: insecure ETHERPAD_ADMIN_PASSWORD: insecure
NODE_ENV: production NODE_ENV: production
ports: ports:
- "9001:9001" - 9001:9001
depends_on:
- "db"
volumes: volumes:
db_data: {} db_data: {}

44
entrypoint.sh Normal file → Executable file
View file

@ -1,30 +1,27 @@
#!/bin/sh #!/bin/sh
set -e set -e
chmod +x /parseurl.py eval "$(sh /parseurl.sh "$DATABASE_URL" ETHERPAD_DB)"
/parseurl.py ETHERPAD_DB_
eval "$(/parseurl.py ETHERPAD_DB_)"
# ETHERPAD_DB_PASSWORD is mandatory in mysql container, so we're not offering # ETHERPAD_DB_PASS is mandatory in mysql container, so we're not offering
# any default. If we're linked to MySQL through legacy link, then we can try # any default. If we're linked to MySQL through legacy link, then we can try
# using the password from the env variable MYSQL_ENV_MYSQL_ROOT_PASSWORD # using the password from the env variable MYSQL_ENV_MYSQL_ROOT_PASSWORD
# if [ "$ETHERPAD_DB_USERNAME" = 'root' ]; then # if [ "$ETHERPAD_DB_USER" = 'root' ]; then
# : ${ETHERPAD_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD} # : ${ETHERPAD_DB_PASS:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
# fi # fi
if [ -z "$ETHERPAD_DB_USERNAME" ]; then if [ -z "$ETHERPAD_DB_USER" ]; then
echo >&2 'error: missing required ETHERPAD_DB_USERNAME environment variable' echo >&2 'error: missing required ETHERPAD_DB_USER environment variable'
echo >&2 ' Did you forget to -e ETHERPAD_DB_USERNAME=... ?' echo >&2 ' Did you forget to -e ETHERPAD_DB_USER=... ?'
exit 1 exit 1
fi fi
if [ -z "$ETHERPAD_DB_PASSWORD" ]; then if [ -z "$ETHERPAD_DB_PASS" ]; then
echo >&2 'error: missing required ETHERPAD_DB_PASSWORD environment variable' echo >&2 'error: missing required ETHERPAD_DB_PASS environment variable'
echo >&2 ' Did you forget to -e ETHERPAD_DB_PASSWORD=... ?' echo >&2 ' Did you forget to -e ETHERPAD_DB_PASS=... ?'
exit 1 exit 1
fi fi
RANDOM_STRING="$(node -p "require('crypto').randomBytes(32).toString('hex')")}"
# Sanitize DB information # Sanitize DB information
ETHERPAD_DB_HOST="${ETHERPAD_DB_HOST:-}" ETHERPAD_DB_HOST="${ETHERPAD_DB_HOST:-}"
@ -32,7 +29,6 @@ ETHERPAD_DB_PORT="${ETHERPAD_DB_PORT:-3306}"
# Sanitize etherpad info # Sanitize etherpad info
ETHERPAD_PORT="${ETHERPAD_PORT:-9001}" ETHERPAD_PORT="${ETHERPAD_PORT:-9001}"
ETHERPAD_SESSION_KEY="${ETHERPAD_SESSION_KEY:-$RANDOM_STRING}"
ETHERPAD_TITLE="${ETHERPAD_TITLE:-Etherpad}" ETHERPAD_TITLE="${ETHERPAD_TITLE:-Etherpad}"
# Wait for database # Wait for database
@ -47,8 +43,8 @@ sleep 1
# Check if database already exists # Check if database already exists
RESULT="$(mysql \ RESULT="$(mysql \
"-u${ETHERPAD_DB_USERNAME}" \ "-u${ETHERPAD_DB_USER}" \
"-p${ETHERPAD_DB_PASSWORD}" \ "-p${ETHERPAD_DB_PASS}" \
"-P${ETHERPAD_DB_PORT}" \ "-P${ETHERPAD_DB_PORT}" \
"-h${ETHERPAD_DB_HOST}" \ "-h${ETHERPAD_DB_HOST}" \
--skip-column-names \ --skip-column-names \
@ -58,8 +54,8 @@ if [ "$RESULT" != "$ETHERPAD_DB_NAME" ]; then
# mysql database does not exist, create it # mysql database does not exist, create it
echo "Creating database ${ETHERPAD_DB_NAME}" echo "Creating database ${ETHERPAD_DB_NAME}"
mysql "-u${ETHERPAD_DB_USERNAME}" \ mysql "-u${ETHERPAD_DB_USER}" \
"-p${ETHERPAD_DB_PASSWORD}" \ "-p${ETHERPAD_DB_PASS}" \
"-P${ETHERPAD_DB_PORT}" \ "-P${ETHERPAD_DB_PORT}" \
"-h${ETHERPAD_DB_HOST}" \ "-h${ETHERPAD_DB_HOST}" \
-e "create database ${ETHERPAD_DB_NAME}" -e "create database ${ETHERPAD_DB_NAME}"
@ -73,12 +69,14 @@ if ! [ -f settings.json ]; then
"ip": "0.0.0.0", "ip": "0.0.0.0",
"port" :${ETHERPAD_PORT}, "port" :${ETHERPAD_PORT},
"skinName": "colibris", "skinName": "colibris",
"sessionKey" : "${ETHERPAD_SESSION_KEY}", "trustProxy" : false,
"minify" : true,
"defaultPadText" : "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\nIMPORTANT: this pad will be deleted after 30 days. Please don't consider it as document storage.",
"dbType" : "mysql", "dbType" : "mysql",
"dbSettings" : { "dbSettings" : {
"user" : "${ETHERPAD_DB_USERNAME}", "user" : "${ETHERPAD_DB_USER}",
"host" : "${ETHERPAD_DB_HOST}", "host" : "${ETHERPAD_DB_HOST}",
"password": "${ETHERPAD_DB_PASSWORD}", "password": "${ETHERPAD_DB_PASS}",
"database": "${ETHERPAD_DB_NAME}" "database": "${ETHERPAD_DB_NAME}"
}, },
EOF EOF
@ -98,6 +96,10 @@ if ! [ -f settings.json ]; then
fi fi
cat <<- EOF >> settings.json cat <<- EOF >> settings.json
"ep_expiration" : {
"enabled": true,
"max_days": 30
}
} }
EOF EOF
fi fi

View file

@ -1,63 +0,0 @@
#!/usr/bin/env python
import sys
import os
from urlparse import urlparse
prefix = sys.argv[1]
# print os.environ.keys
uri_str = os.environ['DATABASE_URL']
uri = urlparse(uri_str)
db_netloc = uri.netloc
db_credential = None
db_username = None
db_password = None
db_host = None
db_port = None
if db_netloc.find("@") >= 0 :
tmp_arr1 = db_netloc.split('@')
db_credential = tmp_arr1[0]
db_host = tmp_arr1[1]
if db_credential and db_credential.find(':') >= 0 :
tmp_arr2 = db_credential.split(':')
db_username = tmp_arr2[0]
db_password = tmp_arr2[1]
if db_host and db_host.find(':') >= 0 :
tmp_arr3 = db_host.split(':')
db_host = tmp_arr3[0]
db_port = tmp_arr3[1]
db_path = uri.path
db_scheme = uri.scheme
db_query = uri.query
db_fragment = uri.fragment
if db_scheme :
print(prefix + 'SCHEME=' + db_scheme)
if db_username :
print(prefix + 'USERNAME=' + db_username)
if db_password :
print(prefix + 'PASSWORD=' + db_password)
if db_host :
print(prefix + 'HOST=' + db_host)
if db_port :
print(prefix + 'PORT=' + db_port)
if db_path :
print(prefix + 'NAME=' + db_path[1:])
if db_query :
print(prefix + 'QUERY=' + db_query)
if db_fragment :
print(prefix + 'FRAGMENT=' + db_fragment)

35
parseurl.sh Executable file
View file

@ -0,0 +1,35 @@
#!/bin/sh
# Referenced and tweaked from http://stackoverflow.com/questions/6174220/parse-url-in-shell-script#6174447
url="$1"
prefix="$2"
proto="$(echo "$url" | grep :// | sed -e 's,^\(.*\)://.*,\1,g')"
# remove the protocol
workurl="$(echo "$url" |sed -e "s,^$proto://,,")"
# extract the user (if any)
userpass="$(echo "$workurl" | grep @ | cut -d@ -f1)"
pass="$(echo "$userpass"| grep : | cut -d: -f2)"
if [ -n "$pass" ]; then
user="$(echo "$userpass" | grep : | cut -d: -f1)"
else
user="$userpass"
fi
# extract the host
hostport="$(echo "$workurl" |sed -e "s,$userpass@,," | cut -d/ -f1)"
# by request - try to extract the port
port="$(echo "$hostport" | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')"
host="$(echo "$hostport" | cut -d: -f1)"
# extract the path (if any)
path="/$(echo "$workurl" | grep / | cut -d/ -f2-)"
name="$(echo "$workurl" | grep / | cut -d/ -f2-)"
echo "${prefix}_URL=\"$url\""
echo "${prefix}_PROTO=\"$proto\""
echo "${prefix}_USER=\"$user\""
echo "${prefix}_PASS=\"$pass\""
echo "${prefix}_HOST=\"$host\""
echo "${prefix}_PORT=\"$port\""
echo "${prefix}_PATH=\"$path\""
echo "${prefix}_NAME=\"$name\""