Commit a2860362 authored by Dave Lane's avatar Dave Lane
Browse files

lots of tweaks to builds, pm2 and cron containers.

parent e610dae0
Loading
Loading
Loading
Loading

docker-wenotes-cron/Dockerfile

deleted100644 → 0
+0 −26
Original line number Diff line number Diff line
FROM oeru/wenotes-tools

MAINTAINER Dave Lane dave@oerfoundation.org - @lightweight and https://tech.oeru.org

# cron is already installed in the base image

# set up cron tasks
RUN set -ex \
    && { \
        echo "# created by Docker and the OER Foundation"; \
        echo "MAILTO=webmaster@oerfoundation.org"; \
        echo "LOG=/var/log/cron.log"; \
        echo "WEDIR=/opt/wenotes/tools"; \
        echo "PY=/usr/bin/python"; \
        echo '8,18,28,38,48,58 * * * * root cd $WEDIR && nice $PY bookmarks.py && nice $PY medium.py'; \
        echo '6,16,26,36,46,56 * * * * root cd $WEDIR && nice $PY mastodon.py && nice $PY hypothesis.py'; \
        echo '4,14,24,34,44,54 * * * * root cd $WEDIR && nice $PY gplus.py && nice $PY feeds.py && nice $PY groups.py'; \
        echo '2,12,22,32,42,52 * * * * root cd $WEDIR && nice $PY forums.py && nice $PY discourse.py --full'; \
        echo '*/1 * * * * root echo "Cron ran at $(date)" >> $LOG'; \
   } | tee /etc/cron.d/wenotes-cron

RUN chmod 0644 /etc/cron.d/wenotes-cron

RUN touch 0644 /var/log/cron.log

CMD cron && tail -f /var/log/cron.log
+3 −104
Original line number Diff line number Diff line
@@ -10,112 +10,11 @@
# License for the specific language governing permissions and limitations under
# the License.

FROM ubuntu:xenial
FROM oeru/wenotes-base

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/
@@ -128,5 +27,5 @@ VOLUME ["/opt/wenotes/tools", "/opt/wenotes/logs", "/opt/wenotes/tools/options.j
# 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"]
#ENTRYPOINT ["tini", "--", "/root/conf/*.sh"]
CMD /root/conf/run.sh && bash
+20 −126
Original line number Diff line number Diff line
# 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 oeru/wenotes-base

FROM ubuntu:xenial
MAINTAINER Dave Lane dave@oerfoundation.org - @lightweight and https://tech.oeru.org

MAINTAINER Dave Lane dave@oerfoundation.org
# (adapted from work by Clemens Stolle klaemo@apache.org)
# cron is already installed in the base image

# 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
# set up cron tasks
RUN set -ex \
    && { \
        echo "# created by Docker and the OER Foundation"; \
        echo "MAILTO=webmaster@oerfoundation.org"; \
        echo "LOG=/var/log/cron.log"; \
        echo "WEDIR=/opt/wenotes/tools"; \
        echo "PY=/usr/bin/python"; \
        echo '8,18,28,38,48,58 * * * * root cd $WEDIR && nice $PY bookmarks.py && nice $PY medium.py'; \
        echo '6,16,26,36,46,56 * * * * root cd $WEDIR && nice $PY mastodon.py && nice $PY hypothesis.py'; \
        echo '4,14,24,34,44,54 * * * * root cd $WEDIR && nice $PY gplus.py && nice $PY feeds.py && nice $PY groups.py'; \
        echo '2,12,22,32,42,52 * * * * root cd $WEDIR && nice $PY forums.py && nice $PY discourse.py --full'; \
        echo '*/1 * * * * root echo "Cron ran at $(date)" >> $LOG'; \
   } | tee /etc/cron.d/wenotes-cron

#
# 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
RUN chmod 0644 /etc/cron.d/wenotes-cron

# 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
RUN touch 0644 /var/log/cron.log

# 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 cron && tail -f /var/log/cron.log
+0 −20
Original line number Diff line number Diff line
#
# 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
+0 −106
Original line number Diff line number Diff line
{
  "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"
   }
}
Loading