diff --git a/docker-wenotes-base/Dockerfile b/docker-wenotes-base/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..edc241ae07f7302a590520e77dd2e76ec94aa41f --- /dev/null +++ b/docker-wenotes-base/Dockerfile @@ -0,0 +1,133 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +FROM ubuntu:xenial + +MAINTAINER Dave Lane dave@oerfoundation.org +# (adapted from work by Clemens Stolle klaemo@apache.org) + +# Purpose - run a full WENotes stack including the faye message server, +# the wenotes service with couchdb, and various external processing tools +# +# The aim: to make a manageable fully functional dev environment which +# fosters remote API-ification for registering new blog users, +# updating details for session validation, and possibly integrating Mautic... +#ENV APT_SERVER http://ucmirror.canterbury.ac.nz/ubuntu +#ENV APT_FILE sources.list +#ENV UBUNTU_NAME xenial +# subdue the "Dialog" errors... +ENV DEBIAN_FRONTEND noninteractive +# +# Add CouchDB user account +RUN groupadd -r couchdb && useradd -d /opt/couchdb -g couchdb couchdb + +# +# add local mirror to reduce build time :) +#RUN echo "deb $APT_SERVER ${UBUNTU_NAME} main universe" > /etc/apt/${APT_FILE} +#RUN echo "deb $APT_SERVER ${UBUNTU_NAME}-updates main universe" >> /etc/apt/${APT_FILE} +#RUN echo "deb $APT_SERVER ${UBUNTU_NAME}-security main universe" >> /etc/apt/${APT_FILE} +#RUN echo "deb-src $APT_SERVER ${UBUNTU_NAME} main universe" >> /etc/apt/${APT_FILE} +#RUN echo "deb-src $APT_SERVER ${UBUNTU_NAME}-updates main universe" >> /etc/apt/${APT_FILE} +#RUN echo "deb-src $APT_SERVER ${UBUNTU_NAME}-security main universe" >> /etc/apt/${APT_FILE} +# do one update and start installing... +RUN apt-get update -y && apt-get install -y --no-install-recommends \ + apt-transport-https \ + apt-utils \ + ca-certificates \ + cron \ + curl \ + erlang-nox \ + erlang-reltool \ + git \ + haproxy \ + less \ + libmozjs185-1.0 \ + locales \ + openssl \ + python \ + python-bs4 \ + python-chardet \ + python-couchdb \ + python-feedparser \ + python-html5lib \ + python-httplib2 \ + python-lxml \ + python-lxml \ + python-pip \ + python-requests \ + python-urllib3 + +# grab gosu for easy step-down from root and tini for signal handling +RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ + && curl -o /usr/local/bin/gosu -fSL "https://github.com/tianon/gosu/releases/download/1.7/gosu-$(dpkg --print-architecture)" \ + && curl -o /usr/local/bin/gosu.asc -fSL "https://github.com/tianon/gosu/releases/download/1.7/gosu-$(dpkg --print-architecture).asc" \ + && gpg --verify /usr/local/bin/gosu.asc \ + && rm /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 6380DC428747F6C393FEACA59A84159D7001A4E5 \ + && curl -o /usr/local/bin/tini -fSL "https://github.com/krallin/tini/releases/download/v0.9.0/tini" \ + && curl -o /usr/local/bin/tini.asc -fSL "https://github.com/krallin/tini/releases/download/v0.9.0/tini.asc" \ + && gpg --verify /usr/local/bin/tini.asc \ + && rm /usr/local/bin/tini.asc \ + && chmod +x /usr/local/bin/tini + +# install cron and msmtp for outgoing email +RUN apt-get install -y cron msmtp rsyslog + +# install useful tools +RUN apt-get install -y less net-tools vim + +# install Node.JS repos and do another update... +RUN curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \ + && echo 'deb https://deb.nodesource.com/node_4.x trusty main' > /etc/apt/sources.list.d/nodesource.list \ + && echo 'deb-src https://deb.nodesource.com/node_4.x trusty main' >> /etc/apt/sources.list.d/nodesource.list \ + && apt-get update -y -qq +# Download dev dependencies +RUN apt-get install -y --no-install-recommends \ + build-essential \ + erlang-dev \ + libcurl4-openssl-dev \ + libmozjs185-dev \ + # install nodejs stack... + && apt-get install -y nodejs \ + && npm install -g grunt-cli +# set up pm2 +RUN npm install -g pm2 +# Cleanup build detritus +RUN apt-get autoremove -y && apt-get clean + +# Set up the language variables +ENV LANG en_NZ.UTF-8 +ENV LANGUAGE en_NZ.UTF-8 +ENV LC_ALL en_NZ.UTF-8 +# Compile the language spec +RUN locale-gen $LANG +# +# Some final exports to get the environment right... +RUN echo "export VISIBLE=now" >> /etc/profile \ + && echo "export TERM=xterm" >> /etc/bash.bashrc + +# set up the various scripts we need to run on the container +# after it's built... +#COPY ./conf /root/conf/ +#Prepare the main install script +#RUN chmod u+x /root/conf/*.sh + +# expose relevant volumes +VOLUME ["/opt/wenotes/tools", "/opt/wenotes/logs", "/opt/wenotes/tools/options.json", "/opt/wenotes/tools/msmtprc"] + +# First, say we're doing it +#RUN echo "running run.sh - /root/conf/run.sh" +# Actually do it when we run the container. +#ENTRYPOINT ["tini", "--", "/root/conf/run.sh"] +#CMD ["wenotes"] +CMD ["bash"] diff --git a/docker-wenotes-base/conf/msmtp/msmtprc-sample b/docker-wenotes-base/conf/msmtp/msmtprc-sample new file mode 100644 index 0000000000000000000000000000000000000000..652fa3aac8a6c77a2b7d0794f51e8959f3a7abce --- /dev/null +++ b/docker-wenotes-base/conf/msmtp/msmtprc-sample @@ -0,0 +1,20 @@ +# +# This is a sample - copy to msmtprc in this directory and replace +# the [variables] below with valid values. +# +# easy docker container outgoing mail +defaults +logfile /tmp/msmtp.log + +tls on +tls_trust_file /etc/ssl/certs/ca-certificates.crt + +account RemoteHost +host [smtp host] +from [from email address] +port 587 +# SMPT authentication details +auth on +user [username] +password [password] +account default : RemoteHost diff --git a/docker-wenotes-base/conf/options.json.sample b/docker-wenotes-base/conf/options.json.sample new file mode 100644 index 0000000000000000000000000000000000000000..a9ce542198bde846d95092af8de5e0c077996e0f --- /dev/null +++ b/docker-wenotes-base/conf/options.json.sample @@ -0,0 +1,106 @@ +{ + "settings-url": "http://wenotes.oeru.org/resources/feed-sources.json", + "url": "http://bot:BOT_PASSWORD@couchdb2:5984", + "localcouch": "http://bot:BOT_PASSWORD@couchdb2:5984", + "couch": { + "user": "bot", + "pass": "BOT_PASSWORD", + "url": "http://couchdb2", + "port": 5984 + }, + "db": "mentions", + "dbfeeds": "feeds", + "dbvotes": "votes", + "avatars": "weavatars", + "server": { + "ip": "faye", + "port": 80, + "secureport": "", + "privkey": "", + "fullchain": "" + }, + "logdir": "/opt/wenotes/log", + "log": { + "couchwatch": { + "level": 7, + "file": "/tmp/couchwatch.log" + }, + "twitters": { + "level": 7, + "file": "/tmp/twitters.log" + }, + "twitter": { + "level": 7, + "file": "/tmp/twitter.log" + }, + "server": { + "level": 7, + "file": "/tmp/wenotes-server.log" + } + }, + "WEnotes": { + "RocketChat": { + "subscribe": "/WEnotes/*", + "channel": "#wenotes-all", + "webhook": "https://chat.oeru.org/hooks/ROCKETCHAT_WENOTES_HASH" + } + }, + "IRC": { + "botname": "WikiEducatorBot", + "botpass": "lat45long", + "ircchannel": "#wikieducator", + "RocketChat": { + "channel": "#wikieducator-irc", + "webhook": "https://chat.oeru.org/hooks/ROCKETCHAT_IRC_HASH" + } + }, + "RocketChat": { + "token": "post4WEnotes", + "tag": "oeru", + "baseURL": "https://chat.oeru.org/" + + }, + "googleapikey": "GOOGLE_API_KEY", + "googleapiserverkey": "GOOGLE_API_SERVER_KEY", + "moodleuser": "MOODLE_USER", + "moodlepass": "MOODLE_PASSWORD", + "tags": ["wikieducator", "ocl4ed", "oeru", "wenotes", "ds4oer", "uowmun", "oeru17"], + "blacklist": ["asiangirl", "japanesa", "panties", "nipples", "stockings", "oppai", "tits", "bigtits", "japanav", "gangbang", "blowjob", "pantsu", "buenosaires", "escuelacuzque", "milf", "lingerie", "ass", "pussy"], + "fayeurl": "http://faye/faye", + "fayepass": "FAYE_PASSWORD", + "twitter": { + "consumer_key": "TWITTER_CONSUMER_KEY", + "consumer_secret": "TWITTER_CONSUMER_SECRET", + "access_token_key": "TWITTER_ACCESS_KEY", + "access_token_secret": "TWITTER_ACCESS_SECRET" + }, + "gdata": { + "user": "GPLUS_USER_EMAIL", + "pass": "GPLUS_USER_PASSWORD" + }, + "communities": [{"id":"110673383804329227095", "tag": "wikieducator"}, + { "id":"107652967421847253472", "tag": "sp4ed"}, + {"id":"101164183090938345449", "tag": "ocl4ed"} + ], + "discourse": "https://community.oeru.org", + "forums": { + "ds4oer": "https://forums.oeru.org/c/courses/ds4oer.json", + "csf101": "https://forums.oeru.org/tags/csf101.json", + "csf102": "https://forums.oeru.org/tags/csf102.json", + "csf103": "https://forums.oeru.org/tags/csf103.json", + "csf104": "https://forums.oeru.org/tags/csf104.json", + "lida101": "https://forums.oeru.org/tags/lida101.json", + "lida102": "https://forums.oeru.org/tags/lida102.json", + "lida103": "https://forums.oeru.org/tags/lida103.json", + "lida104": "https://forums.oeru.org/tags/lida104.json" + }, + "bookmarks": { + "url": "https://bookmarks.oeru.org", + }, + "hypothesis": { + "url": "https://hypothes.is", + }, + "medium": { + "url": "https://medium.com" + } +} diff --git a/docker-wenotes-base/conf/options.json.sample.bak b/docker-wenotes-base/conf/options.json.sample.bak new file mode 100644 index 0000000000000000000000000000000000000000..a9ce542198bde846d95092af8de5e0c077996e0f --- /dev/null +++ b/docker-wenotes-base/conf/options.json.sample.bak @@ -0,0 +1,106 @@ +{ + "settings-url": "http://wenotes.oeru.org/resources/feed-sources.json", + "url": "http://bot:BOT_PASSWORD@couchdb2:5984", + "localcouch": "http://bot:BOT_PASSWORD@couchdb2:5984", + "couch": { + "user": "bot", + "pass": "BOT_PASSWORD", + "url": "http://couchdb2", + "port": 5984 + }, + "db": "mentions", + "dbfeeds": "feeds", + "dbvotes": "votes", + "avatars": "weavatars", + "server": { + "ip": "faye", + "port": 80, + "secureport": "", + "privkey": "", + "fullchain": "" + }, + "logdir": "/opt/wenotes/log", + "log": { + "couchwatch": { + "level": 7, + "file": "/tmp/couchwatch.log" + }, + "twitters": { + "level": 7, + "file": "/tmp/twitters.log" + }, + "twitter": { + "level": 7, + "file": "/tmp/twitter.log" + }, + "server": { + "level": 7, + "file": "/tmp/wenotes-server.log" + } + }, + "WEnotes": { + "RocketChat": { + "subscribe": "/WEnotes/*", + "channel": "#wenotes-all", + "webhook": "https://chat.oeru.org/hooks/ROCKETCHAT_WENOTES_HASH" + } + }, + "IRC": { + "botname": "WikiEducatorBot", + "botpass": "lat45long", + "ircchannel": "#wikieducator", + "RocketChat": { + "channel": "#wikieducator-irc", + "webhook": "https://chat.oeru.org/hooks/ROCKETCHAT_IRC_HASH" + } + }, + "RocketChat": { + "token": "post4WEnotes", + "tag": "oeru", + "baseURL": "https://chat.oeru.org/" + + }, + "googleapikey": "GOOGLE_API_KEY", + "googleapiserverkey": "GOOGLE_API_SERVER_KEY", + "moodleuser": "MOODLE_USER", + "moodlepass": "MOODLE_PASSWORD", + "tags": ["wikieducator", "ocl4ed", "oeru", "wenotes", "ds4oer", "uowmun", "oeru17"], + "blacklist": ["asiangirl", "japanesa", "panties", "nipples", "stockings", "oppai", "tits", "bigtits", "japanav", "gangbang", "blowjob", "pantsu", "buenosaires", "escuelacuzque", "milf", "lingerie", "ass", "pussy"], + "fayeurl": "http://faye/faye", + "fayepass": "FAYE_PASSWORD", + "twitter": { + "consumer_key": "TWITTER_CONSUMER_KEY", + "consumer_secret": "TWITTER_CONSUMER_SECRET", + "access_token_key": "TWITTER_ACCESS_KEY", + "access_token_secret": "TWITTER_ACCESS_SECRET" + }, + "gdata": { + "user": "GPLUS_USER_EMAIL", + "pass": "GPLUS_USER_PASSWORD" + }, + "communities": [{"id":"110673383804329227095", "tag": "wikieducator"}, + { "id":"107652967421847253472", "tag": "sp4ed"}, + {"id":"101164183090938345449", "tag": "ocl4ed"} + ], + "discourse": "https://community.oeru.org", + "forums": { + "ds4oer": "https://forums.oeru.org/c/courses/ds4oer.json", + "csf101": "https://forums.oeru.org/tags/csf101.json", + "csf102": "https://forums.oeru.org/tags/csf102.json", + "csf103": "https://forums.oeru.org/tags/csf103.json", + "csf104": "https://forums.oeru.org/tags/csf104.json", + "lida101": "https://forums.oeru.org/tags/lida101.json", + "lida102": "https://forums.oeru.org/tags/lida102.json", + "lida103": "https://forums.oeru.org/tags/lida103.json", + "lida104": "https://forums.oeru.org/tags/lida104.json" + }, + "bookmarks": { + "url": "https://bookmarks.oeru.org", + }, + "hypothesis": { + "url": "https://hypothes.is", + }, + "medium": { + "url": "https://medium.com" + } +} diff --git a/docker-wenotes-base/conf/run.sh b/docker-wenotes-base/conf/run.sh new file mode 100644 index 0000000000000000000000000000000000000000..1d15b75a01053b681878e50f2d8dd9a2aeb637e2 --- /dev/null +++ b/docker-wenotes-base/conf/run.sh @@ -0,0 +1,85 @@ +#!/bin/bash +# Bash hasn't been initialized yet so add path to composer manually. +#export PATH="$HOME/.composer/vendor/bin:$PATH" + +# Run start script. +echo "*****Running run.sh" +CONF=/root/conf +COUCH=/root +WENOTES=/opt/wenotes +CWD=`pwd` +# Defines +WETOOLS=https://kiwilightweight@bitbucket.org/wikieducator/wenotes-tools.git +GIT=`which git` +NPM=`which npm` +PM2=`which pm2` +CP=`which cp` + +echo "CWD=$CWD, GIT=$GIT" + +# Run before-run scripts added by another containers. +if [[ -d $CONF/before-start ]] ; then + FILES=$CONF/before-start/* + for f in $FILES + do + echo "Attaching: $f" + source $f + done +fi + +if [[ -f $CONF/pre-install.sh ]] ; then + echo "Running: pre-install.sh" + source $CONF/pre-install.sh +fi + +echo "starting services" + +# remove default msmtprc +if [[ -f /opt/wenotes/tools/msmtprc ]] ; then + echo "moving our msmtprc to /etc and /etc/msmtprc to /etc/msmtprc.default" + mv /etc/msmtprc /etc/msmtprc.default + cp /opt/wenotes/tools/msmtprc /etc/msmtprc +fi + +# next, get the Javascript code: +if [[ -f $WENOTES/tools/options.json ]] ; then + echo "we already have a set of tools, continuing" +else + # get the repo + echo "moving to $WENOTES" + # get the repo + echo "getting $WETOOLS, putting it into server" + cd /tmp + $GIT clone $WETOOLS tools + cd $WENOTES + if [[ -d $WENOTES/tools ]] ; then + echo "$WENOTES/tools already exists - moving /tmp/tools/* there..." + cp -a /tmp/tools/* $WENOTES/tools + else + echo "creating $WENOTES/tools" + mv /tmp/tools $WENOTES + fi + # set up options.json + + echo "returning to original dir: $CWD" + cd $CWD +fi + +echo "finished services" + +if [[ -f $CONF/post-install.sh ]] ; then + echo "Running: post-install.sh" + source $CONF/post-install.sh +fi +echo "****** in run.sh ********" + +# Run after-run scripts added by another containers. +if [[ -d $CONF/after-start ]] ; then + FILES=$CONF/after-start/* + for f in $FILES + do + echo "Attaching: $f" + source $f + done +fi +