Compare commits

..

1 commit

Author SHA1 Message Date
b0f4ecc13a Bump nodejs version 2021-01-19 16:03:35 +01:00
7 changed files with 195 additions and 206 deletions

View file

@ -1,63 +1,45 @@
# Stable version of etherpad doesn't support npm 2
FROM node:18.1
FROM node:14-slim
MAINTAINER Glenn Y. Rolland <glenux@glenux.net>
ENV ETHERPAD_VERSION 1.8.18
ENV ETHERPAD_VERSION 1.8.7
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
# 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 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
WORKDIR /opt/
COPY --chown=etherpad parseurl.sh /parseurl.sh
COPY --chown=etherpad entrypoint.sh /entrypoint.sh
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
WORKDIR /opt/etherpad-lite
WORKDIR /opt/etherpad
USER etherpad
COPY parseurl.py /parseurl.py
COPY entrypoint.sh /entrypoint.sh
# 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 \
# 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
# ep_mypads
# meta-données
VOLUME /opt/etherpad/var
VOLUME /opt/etherpad-lite/var
EXPOSE 9001
ENTRYPOINT ["/entrypoint.sh"]
CMD ["./src/bin/run.sh"]
# bin/run.sh
CMD ["bin/run.sh", "--root"]

View file

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

View file

@ -1,7 +1,15 @@
# 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 latest nodejs image.
on debian jessie instead of the official node docker image, since the latest
stable version of etherpad-lite does not support npm 2.
## About Etherpad Lite
@ -9,7 +17,7 @@ on latest nodejs image.
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")
![alt text](http://i.imgur.com/zYrGkg3.gif "Etherpad in action on PrimaryPad")
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.
@ -17,44 +25,26 @@ You don't need to set up a server and install Etherpad in order to use it. Just
## Quickstart
Copy-paste the following content in a `docker-compose.yml` file
First you need a running mysql container, for example:
```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:
```bash
$ docker network create ep_network
$ docker run -d --network ep_network -e MYSQL_ROOT_PASSWORD=password --name ep_mysql mysql
```
Then run `docker-compose up`
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
```
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
@ -63,6 +53,9 @@ 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.
@ -72,7 +65,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_PASS`: MySQL password to use, mandatory. If legacy links
* `ETHERPAD_DB_PASSWORD`: 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
@ -80,4 +73,3 @@ 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,25 +4,23 @@ 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
MYSQL_ROOT_PASSWORD: insecure
MYSQL_DATABASE: etherpad
etherpad:
build:
context: .
dockerfile: Dockerfile
image: glenux/etherpad:latest
build: .
environment:
DATABASE_URL: mysql://root:insecure:3306@db/etherpad
DATABASE_URL: mysql://root:insecure@db/etherpad
ETHERPAD_ADMIN_USER: admin
ETHERPAD_ADMIN_PASSWORD: insecure
NODE_ENV: production
ports:
- 9001:9001
- "9001:9001"
depends_on:
- "db"
volumes:
db_data: {}

136
entrypoint.sh Executable file → Normal file
View file

@ -1,27 +1,30 @@
#!/bin/sh
set -e
eval "$(sh /parseurl.sh "$DATABASE_URL" ETHERPAD_DB)"
chmod +x /parseurl.py
/parseurl.py ETHERPAD_DB_
eval "$(/parseurl.py ETHERPAD_DB_)"
# ETHERPAD_DB_PASS is mandatory in mysql container, so we're not offering
# ETHERPAD_DB_PASSWORD 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_USER" = 'root' ]; then
# : ${ETHERPAD_DB_PASS:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
# if [ "$ETHERPAD_DB_USERNAME" = 'root' ]; then
# : ${ETHERPAD_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
# fi
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
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
fi
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
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
fi
RANDOM_STRING="$(node -p "require('crypto').randomBytes(32).toString('hex')")}"
# Sanitize DB information
ETHERPAD_DB_HOST="${ETHERPAD_DB_HOST:-}"
@ -29,6 +32,7 @@ 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
@ -43,75 +47,69 @@ sleep 1
# Check if database already exists
RESULT="$(mysql \
"-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}'")"
"-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}'")"
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_USER}" \
"-p${ETHERPAD_DB_PASS}" \
"-P${ETHERPAD_DB_PORT}" \
"-h${ETHERPAD_DB_HOST}" \
-e "create 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}"
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",
"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
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
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
"ep_expiration" : {
"enabled": true,
"max_days": 30
}
}
EOF
cat <<- EOF >> settings.json
}
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 "$@"

63
parseurl.py Executable file
View file

@ -0,0 +1,63 @@
#!/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)

View file

@ -1,35 +0,0 @@
#!/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\""