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
FROM node:14-slim
FROM node:18.1
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 && \
apt-get install -y curl unzip mysql-client python netcat && \
rm -r /var/lib/apt/lists/*
RUN apt-get update \
&& apt-get install -y unzip mariadb-client netcat \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& truncate -s 0 /var/log/*log
WORKDIR /opt/
RUN cd /opt \
&& wget \
https://github.com/ether/etherpad-lite/archive/${ETHERPAD_VERSION}.zip \
-O etherpad.zip \
&& unzip etherpad \
&& rm etherpad.zip \
&& mv etherpad-lite-${ETHERPAD_VERSION} etherpad \
&& useradd --home-dir /opt/etherpad etherpad \
&& chown -R etherpad:etherpad /opt/etherpad
RUN curl -SL \
https://github.com/ether/etherpad-lite/archive/${ETHERPAD_VERSION}.zip \
> etherpad.zip && unzip etherpad && \
rm etherpad.zip && \
mv etherpad-lite-${ETHERPAD_VERSION} etherpad-lite
COPY --chown=etherpad parseurl.sh /parseurl.sh
COPY --chown=etherpad entrypoint.sh /entrypoint.sh
WORKDIR /opt/etherpad-lite
COPY parseurl.py /parseurl.py
COPY entrypoint.sh /entrypoint.sh
WORKDIR /opt/etherpad
USER etherpad
# Pre-install
RUN bin/installDeps.sh && rm settings.json \
&& chmod +x /entrypoint.sh \
&& sed -i 's/^node/exec\ node/' bin/run.sh \
&& ln -s var/settings.json settings.json \
&& npm install \
ep_author_neat ep_headings2 \
ep_set_title_on_pad ep_adminpads \
ep_workspaces ep_comments_page \
ep_font_color ep_table_of_contents \
&& npm audit fix
# Pre-install some plugins
RUN bin/installDeps.sh \
&& cd src \
&& npm install --save-prod \
github:alxndr42/ep_expiration \
ep_author_neat \
ep_headings2 \
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
# meta-données
VOLUME /opt/etherpad-lite/var
VOLUME /opt/etherpad/var
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:
build:
docker build -t $(USERNAME)/$(IMAGE):$(TAG) .
docker-compose build
run:
# remplir ici
docker-compose up --detach
logs:
docker-compose logs -f
shell:
docker-compose exec etherpad bash
kill:
docker-compose kill
test: build
# remplir ici

View file

@ -1,15 +1,7 @@
# 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
on debian jessie instead of the official node docker image, since the latest
stable version of etherpad-lite does not support npm 2.
on latest nodejs image.
## 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.
![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.
@ -25,26 +17,44 @@ You don't need to set up a server and install Etherpad in order to use it. Just
## Quickstart
First you need a running mysql container, for example:
Copy-paste the following content in a `docker-compose.yml` file
```bash
$ docker network create ep_network
$ docker run -d --network ep_network -e MYSQL_ROOT_PASSWORD=password --name ep_mysql mysql
```yaml
---
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:
```bash
$ docker run -d \
--network ep_network \
-e ETHERPAD_DB_HOST=ep_mysql \
-e ETHERPAD_DB_PASSWORD=password \
-p 9001:9001 \
tvelocity/etherpad-lite
```
Then run `docker-compose up`
Etherpad will automatically create an `etherpad` database in the specified mysql
server if it does not already exist.
You can now access Etherpad Lite from http://localhost:9001/
## 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_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,
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_USER`: By default Etherpad Lite will attempt to connect as root
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
automatically used.
* `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
*/opt/etherpad-lite/var/*.

View file

@ -4,23 +4,25 @@ 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:
MYSQL_ROOT_PASSWORD: insecure
MYSQL_DATABASE: etherpad
MARIADB_ROOT_PASSWORD: insecure
MARIADB_DATABASE: etherpad
etherpad:
build: .
build:
context: .
dockerfile: Dockerfile
image: glenux/etherpad:latest
environment:
DATABASE_URL: mysql://root:insecure@db/etherpad
DATABASE_URL: mysql://root:insecure:3306@db/etherpad
ETHERPAD_ADMIN_USER: admin
ETHERPAD_ADMIN_PASSWORD: insecure
NODE_ENV: production
ports:
- "9001:9001"
depends_on:
- "db"
- 9001:9001
volumes:
db_data: {}

136
entrypoint.sh Normal file → Executable file
View file

@ -1,30 +1,27 @@
#!/bin/sh
set -e
chmod +x /parseurl.py
/parseurl.py ETHERPAD_DB_
eval "$(/parseurl.py ETHERPAD_DB_)"
eval "$(sh /parseurl.sh "$DATABASE_URL" 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
# using the password from the env variable MYSQL_ENV_MYSQL_ROOT_PASSWORD
# if [ "$ETHERPAD_DB_USERNAME" = 'root' ]; then
# : ${ETHERPAD_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
# if [ "$ETHERPAD_DB_USER" = 'root' ]; then
# : ${ETHERPAD_DB_PASS:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
# fi
if [ -z "$ETHERPAD_DB_USERNAME" ]; then
echo >&2 'error: missing required ETHERPAD_DB_USERNAME environment variable'
echo >&2 ' Did you forget to -e ETHERPAD_DB_USERNAME=... ?'
exit 1
if [ -z "$ETHERPAD_DB_USER" ]; then
echo >&2 'error: missing required ETHERPAD_DB_USER environment variable'
echo >&2 ' Did you forget to -e ETHERPAD_DB_USER=... ?'
exit 1
fi
if [ -z "$ETHERPAD_DB_PASSWORD" ]; then
echo >&2 'error: missing required ETHERPAD_DB_PASSWORD environment variable'
echo >&2 ' Did you forget to -e ETHERPAD_DB_PASSWORD=... ?'
exit 1
if [ -z "$ETHERPAD_DB_PASS" ]; then
echo >&2 'error: missing required ETHERPAD_DB_PASS environment variable'
echo >&2 ' Did you forget to -e ETHERPAD_DB_PASS=... ?'
exit 1
fi
RANDOM_STRING="$(node -p "require('crypto').randomBytes(32).toString('hex')")}"
# Sanitize DB information
ETHERPAD_DB_HOST="${ETHERPAD_DB_HOST:-}"
@ -32,7 +29,6 @@ ETHERPAD_DB_PORT="${ETHERPAD_DB_PORT:-3306}"
# Sanitize etherpad info
ETHERPAD_PORT="${ETHERPAD_PORT:-9001}"
ETHERPAD_SESSION_KEY="${ETHERPAD_SESSION_KEY:-$RANDOM_STRING}"
ETHERPAD_TITLE="${ETHERPAD_TITLE:-Etherpad}"
# Wait for database
@ -47,69 +43,75 @@ sleep 1
# Check if database already exists
RESULT="$(mysql \
"-u${ETHERPAD_DB_USERNAME}" \
"-p${ETHERPAD_DB_PASSWORD}" \
"-P${ETHERPAD_DB_PORT}" \
"-h${ETHERPAD_DB_HOST}" \
--skip-column-names \
-e "SHOW DATABASES LIKE '${ETHERPAD_DB_NAME}'")"
"-u${ETHERPAD_DB_USER}" \
"-p${ETHERPAD_DB_PASS}" \
"-P${ETHERPAD_DB_PORT}" \
"-h${ETHERPAD_DB_HOST}" \
--skip-column-names \
-e "SHOW DATABASES LIKE '${ETHERPAD_DB_NAME}'")"
if [ "$RESULT" != "$ETHERPAD_DB_NAME" ]; then
# mysql database does not exist, create it
echo "Creating database ${ETHERPAD_DB_NAME}"
# mysql database does not exist, create it
echo "Creating database ${ETHERPAD_DB_NAME}"
mysql "-u${ETHERPAD_DB_USERNAME}" \
"-p${ETHERPAD_DB_PASSWORD}" \
"-P${ETHERPAD_DB_PORT}" \
"-h${ETHERPAD_DB_HOST}" \
-e "create database ${ETHERPAD_DB_NAME}"
mysql "-u${ETHERPAD_DB_USER}" \
"-p${ETHERPAD_DB_PASS}" \
"-P${ETHERPAD_DB_PORT}" \
"-h${ETHERPAD_DB_HOST}" \
-e "create database ${ETHERPAD_DB_NAME}"
fi
if ! [ -f settings.json ]; then
echo "Creating database configuration"
cat <<- EOF > settings.json
{
"title": "${ETHERPAD_TITLE}",
"ip": "0.0.0.0",
"port" :${ETHERPAD_PORT},
"skinName": "colibris",
"sessionKey" : "${ETHERPAD_SESSION_KEY}",
"dbType" : "mysql",
"dbSettings" : {
"user" : "${ETHERPAD_DB_USERNAME}",
"host" : "${ETHERPAD_DB_HOST}",
"password": "${ETHERPAD_DB_PASSWORD}",
"database": "${ETHERPAD_DB_NAME}"
},
EOF
echo "Creating database configuration"
cat <<- EOF > settings.json
{
"title": "${ETHERPAD_TITLE}",
"ip": "0.0.0.0",
"port" :${ETHERPAD_PORT},
"skinName": "colibris",
"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",
"dbSettings" : {
"user" : "${ETHERPAD_DB_USER}",
"host" : "${ETHERPAD_DB_HOST}",
"password": "${ETHERPAD_DB_PASS}",
"database": "${ETHERPAD_DB_NAME}"
},
EOF
if [ -n "$ETHERPAD_ADMIN_PASSWORD" ]; then
ETHERPAD_ADMIN_USER="${ETHERPAD_ADMIN_USER:-admin}"
echo "Creating admin user configuration for $ETHERPAD_ADMIN_USER/$ETHERPAD_ADMIN_PASSWORD"
if [ -n "$ETHERPAD_ADMIN_PASSWORD" ]; then
ETHERPAD_ADMIN_USER="${ETHERPAD_ADMIN_USER:-admin}"
echo "Creating admin user configuration for $ETHERPAD_ADMIN_USER/$ETHERPAD_ADMIN_PASSWORD"
cat <<- EOF >> settings.json
"users": {
"${ETHERPAD_ADMIN_USER}": {
"password": "${ETHERPAD_ADMIN_PASSWORD}",
"is_admin": true
}
},
EOF
fi
cat <<-EOF >> settings.json
"users": {
"${ETHERPAD_ADMIN_USER}": {
"password": "${ETHERPAD_ADMIN_PASSWORD}",
"is_admin": true
}
},
EOF
fi
cat <<- EOF >> settings.json
}
EOF
cat <<- EOF >> settings.json
"ep_expiration" : {
"enabled": true,
"max_days": 30
}
}
EOF
fi
if ! grep -q '/* GLENUX BEGIN */' src/static/css/pad.css ; then
cat >> src/static/css/pad.css <<-MARK
/* GLENUX BEGIN */
body#innerdocbody {
font-size: 16px;
line-height: 20px
}
MARK
cat >> src/static/css/pad.css <<- MARK
/* GLENUX BEGIN */
body#innerdocbody {
font-size: 16px;
line-height: 20px
}
MARK
fi
exec "$@"

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\""