Fix service provisioning
This commit is contained in:
parent
d6762656d1
commit
e08cd16366
4 changed files with 93 additions and 32 deletions
26
Dockerfile
26
Dockerfile
|
@ -1,12 +1,12 @@
|
|||
|
||||
# Stable version of etherpad doesn't support npm 2
|
||||
FROM debian:jessie
|
||||
MAINTAINER Tony Motakis <tvelocity@gmail.com>
|
||||
FROM node:11-slim
|
||||
MAINTAINER Glenn Y. Rolland <glenux@glenux.net>
|
||||
|
||||
ENV ETHERPAD_VERSION 1.6.1
|
||||
ENV ETHERPAD_VERSION 1.7.5
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y curl unzip nodejs-legacy npm mysql-client && \
|
||||
apt-get install -y curl unzip mysql-client python netcat && \
|
||||
rm -r /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /opt/
|
||||
|
@ -17,20 +17,20 @@ RUN curl -SL \
|
|||
rm etherpad.zip && \
|
||||
mv etherpad-lite-${ETHERPAD_VERSION} etherpad-lite
|
||||
|
||||
WORKDIR etherpad-lite
|
||||
WORKDIR /opt/etherpad-lite
|
||||
|
||||
RUN bin/installDeps.sh && rm settings.json
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
COPY parseurl.py /parseurl.py
|
||||
RUN chmod +x /entrypoint.sh
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
|
||||
RUN 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_mypads
|
||||
|
||||
VOLUME /opt/etherpad-lite/var
|
||||
RUN ln -s var/settings.json settings.json
|
||||
|
||||
RUN npm install ep_author_neat ep_headings2 ep_set_title_on_pad ep_adminpads
|
||||
|
||||
EXPOSE 9001
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD ["bin/run.sh", "--root"]
|
||||
|
||||
|
|
6
Makefile
6
Makefile
|
@ -1,15 +1,17 @@
|
|||
|
||||
NAME=$(shell basename "$$(pwd)")
|
||||
|
||||
all: build run
|
||||
|
||||
# --build-arg "BUNDLE_BITBUCKET__ORG=$(BUNDLE_BITBUCKET__ORG)" \
|
||||
|
||||
build:
|
||||
docker build -t dt-service-pad .
|
||||
docker build -t "$(NAME)" .
|
||||
|
||||
run:
|
||||
docker run --rm -p 9001:9001 \
|
||||
-e DATABASE_URL="mysql://user:foo@databasehost/database?options" \
|
||||
-t dt-service-pad \
|
||||
-t "$(NAME)" \
|
||||
#
|
||||
|
||||
|
||||
|
|
25
docker-compose.yml
Normal file
25
docker-compose.yml
Normal file
|
@ -0,0 +1,25 @@
|
|||
version: "3"
|
||||
services:
|
||||
db:
|
||||
image: mariadb:10.3
|
||||
volumes:
|
||||
- ./data/db:/var/lib/mysql
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: insecure
|
||||
MYSQL_DATABASE: etherpad
|
||||
|
||||
etherpad:
|
||||
build: .
|
||||
environment:
|
||||
DATABASE_URL: mysql://root:insecure@db/etherpad
|
||||
ETHERPAD_ADMIN_USER: admin
|
||||
ETHERPAD_ADMIN_PASSWORD: insecure
|
||||
NODE_ENV: production
|
||||
ports:
|
||||
- "9001:9001"
|
||||
depends_on:
|
||||
- "db"
|
||||
|
||||
# volumes:
|
||||
# - data/etherpad:/var/www/html/documents
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
chmod +x /parseurl.py
|
||||
/parseurl.py ETHERPAD_DB_
|
||||
eval $(/parseurl.py ETHERPAD_DB_)
|
||||
eval "$(/parseurl.py ETHERPAD_DB_)"
|
||||
|
||||
# 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
|
||||
|
@ -24,26 +24,49 @@ if [ -z "$ETHERPAD_DB_PASSWORD" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
: ${ETHERPAD_TITLE:=Etherpad}
|
||||
: ${ETHERPAD_PORT:=9001}
|
||||
: ${ETHERPAD_SESSION_KEY:=$(
|
||||
node -p "require('crypto').randomBytes(32).toString('hex')")}
|
||||
RANDOM_STRING="$(node -p "require('crypto').randomBytes(32).toString('hex')")}"
|
||||
|
||||
# Sanitize DB information
|
||||
ETHERPAD_DB_HOST="${ETHERPAD_DB_HOST:-}"
|
||||
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
|
||||
echo "Waiting MySQL/MariaDB to be available on port 3306..."
|
||||
|
||||
while ! nc -z "${ETHERPAD_DB_HOST}" "${ETHERPAD_DB_PORT}" ; do
|
||||
sleep 1 # wait for 1/10 of the second before check again
|
||||
done
|
||||
|
||||
echo "Service MySQL/MariaDB seems ready"
|
||||
sleep 1
|
||||
|
||||
# Check if database already exists
|
||||
RESULT=`mysql -u${ETHERPAD_DB_USERNAME} -p${ETHERPAD_DB_PASSWORD} \
|
||||
-h${ETHERPAD_DB_HOST} --skip-column-names \
|
||||
-e "SHOW DATABASES LIKE '${ETHERPAD_DB_NAME}'"`
|
||||
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}'")"
|
||||
|
||||
if [ "$RESULT" != $ETHERPAD_DB_NAME ]; then
|
||||
if [ "$RESULT" != "$ETHERPAD_DB_NAME" ]; then
|
||||
# mysql database does not exist, create it
|
||||
echo "Creating database ${ETHERPAD_DB_NAME}"
|
||||
|
||||
mysql -u${ETHERPAD_DB_USERNAME} -p${ETHERPAD_DB_PASSWORD} -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
|
||||
|
||||
if ! [ -f settings.json ]; then
|
||||
echo "Creating database configuration"
|
||||
cat <<- EOF > settings.json
|
||||
{
|
||||
"title": "${ETHERPAD_TITLE}",
|
||||
|
@ -59,9 +82,9 @@ if [ ! -f settings.json ]; then
|
|||
},
|
||||
EOF
|
||||
|
||||
if [ $ETHERPAD_ADMIN_PASSWORD ]; then
|
||||
|
||||
: ${ETHERPAD_ADMIN_USER:=admin}
|
||||
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": {
|
||||
|
@ -78,4 +101,15 @@ if [ ! -f settings.json ]; then
|
|||
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
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
|
||||
|
|
Loading…
Reference in a new issue