Skip to content
Snippets Groups Projects
Commit 9c9d877d authored by Barbare Antoine's avatar Barbare Antoine
Browse files

Finish Etherpad dockerfile. Add environment variable and supervisord to run process.

parent 18fdcdce
No related branches found
No related tags found
No related merge requests found
FROM tx-debian:latest
MAINTAINER antoinebarbare@gmail.com
MAINTAINER antoine@barbare.me
#Installation de NodeJS + NPM
RUN echo "deb http://ftp.us.debian.org/debian wheezy-backports main" >> /etc/apt/sources.list
RUN DEBIAN_FRONTEND=noninteactive apt-get -y update
RUN apt-get install -y curl nodejs-legacy
ENV ETHERPAD_VERSION 1.6.0
RUN curl -L --insecure -O https://www.npmjs.org/install.sh \
&& /bin/bash install.sh \
RUN apt-get update && \
apt-get install -y unzip nodejs-legacy npm mysql-client supervisor && \
rm -r /var/lib/apt/lists/*
RUN apt-get install gzip git curl python libssl-dev pkg-config build-essential
WORKDIR /opt/
#Installation Etherpad
WORKDIR /opt
RUN git clone 'git://github.com/ether/etherpad-lite.git'
WORKDIR /opt/etherpad-lite
RUN git checkout develop && rm -Rf src/node_modules
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
ADD add/settings.json /opt/etherpad-lite/settings.json
WORKDIR etherpad-lite
#First starting of services
RUN /opt/etherpad-lite/bin/installDeps.sh
RUN bin/installDeps.sh && rm settings.json
RUN ln -s var/settings.json settings.json
EXPOSE 80
#Copy configuration
COPY add/entrypoint.sh /entrypoint.sh
COPY add/supervisord.conf /etc/supervisord.conf
RUN chmod +x /entrypoint.sh
#Set settings based on evironement variables
ENTRYPOINT ["/entrypoint.sh"]
CMD /opt/etherpad-lite/bin/run.sh --root
#Start Etherpad with supervisor
CMD /usr/bin/supervisord -c /etc/supervisord.conf
EXPOSE 80
VOLUME /opt/etherpad-lite/var
#!/bin/bash
set -e
if [ -z "$MYSQL_PORT_3306_TCP_ADDR" ]; then
echo >&2 'error: missing MYSQL_PORT_3306_TCP environment variable'
echo >&2 ' Did you forget to --link some_mysql_container:mysql ?'
exit 1
fi
# if we're linked to MySQL, and we're using the root user, and our linked
# container has a default "root" password set up and passed through... :)
: ${ETHERPAD_DB_USER:=root}
if [ "$ETHERPAD_DB_USER" = 'root' ]; then
: ${ETHERPAD_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
fi
: ${ETHERPAD_DB_NAME:=etherpad}
ETHERPAD_DB_NAME=$( echo $ETHERPAD_DB_NAME | sed 's/\./_/g' )
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=... ?'
echo >&2
echo >&2 ' (Also of interest might be ETHERPAD_DB_USER and ETHERPAD_DB_NAME.)'
exit 1
fi
: ${ETHERPAD_TITLE:=Etherpad}
: ${ETHERPAD_PORT:=80}
: ${ETHERPAD_SESSION_KEY:=$(
node -p "require('crypto').randomBytes(32).toString('hex')")}
# Check if database already exists
RESULT=`mysql -u${ETHERPAD_DB_USER} -p${ETHERPAD_DB_PASSWORD} \
-hmysql --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 -u${ETHERPAD_DB_USER} -p${ETHERPAD_DB_PASSWORD} -hmysql \
-e "create database ${ETHERPAD_DB_NAME}"
fi
if [ ! -f settings.json ]; then
cat <<- EOF > settings.json
{
"title": "${ETHERPAD_TITLE}",
"ip": "0.0.0.0",
"port" :${ETHERPAD_PORT},
"sessionKey" : "${ETHERPAD_SESSION_KEY}",
"dbType" : "mysql",
"dbSettings" : {
"user" : "${ETHERPAD_DB_USER}",
"host" : "mysql",
"password": "${ETHERPAD_DB_PASSWORD}",
"database": "${ETHERPAD_DB_NAME}"
},
EOF
if [ $ETHERPAD_ADMIN_PASSWORD ]; then
: ${ETHERPAD_ADMIN_USER:=admin}
cat <<- EOF >> settings.json
"users": {
"${ETHERPAD_ADMIN_USER}": {
"password": "${ETHERPAD_ADMIN_PASSWORD}",
"is_admin": true
}
},
EOF
fi
cat <<- EOF >> settings.json
}
EOF
fi
exec "$@"
[supervisord]
nodaemon=true
[program:etherpad]
command=/bin/bash -c "/opt/etherpad-lite/bin/run.sh --root"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment