Commit c40fa6f1 authored by Dave Lane's avatar Dave Lane

initial commit of not-quite-ready-to-test Wenotes container

parent 012638e4
# 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 debian:jessie
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...
#
# Defines
ENV WESVR git@bitbucket.org:wikieducator/wenotes-server.git
ENV WETOOL git@bitbucket.org:wikieducator/wenotes-tools.git
ENV WEDIR /opt/wenotes
#
# Add CouchDB user account
RUN groupadd -r couchdb && useradd -d /opt/couchdb -g couchdb couchdb
RUN apt-get update -y && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
haproxy \
erlang-nox \
erlang-reltool \
libicu52 \
libmozjs185-1.0 \
openssl \
&& rm -rf /var/lib/apt/lists/*
# 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
ENV COUCHDB_VERSION 2.0.0
# Download dev dependencies
RUN apt-get update -y -qq && apt-get install -y --no-install-recommends \
apt-transport-https \
build-essential \
erlang-dev \
libcurl4-openssl-dev \
libicu-dev \
libmozjs185-dev \
&& curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
&& echo 'deb https://deb.nodesource.com/node_4.x jessie main' > /etc/apt/sources.list.d/nodesource.list \
&& echo 'deb-src https://deb.nodesource.com/node_4.x jessie main' >> /etc/apt/sources.list.d/nodesource.list \
&& apt-get update -y -qq \
# install nodejs stack...
&& apt-get install -y nodejs \
&& npm install -g grunt-cli \
# Acquire CouchDB source code
&& cd /usr/src && mkdir couchdb \
&& curl -fSL https://dist.apache.org/repos/dist/release/couchdb/source/2.0.0/apache-couchdb-$COUCHDB_VERSION.tar.gz -o couchdb.tar.gz \
&& tar -xzf couchdb.tar.gz -C couchdb --strip-components=1 \
&& cd couchdb \
# Build the release and install into /opt
&& ./configure --disable-docs \
&& make release \
&& mv /usr/src/couchdb/rel/couchdb /opt/ \
# Cleanup build detritus
&& apt-get purge -y \
binutils \
build-essential \
cpp \
erlang-dev \
git \
libicu-dev \
make \
nodejs \
perl \
&& apt-get autoremove -y && apt-get clean \
&& apt-get install -y libicu52 --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* /usr/lib/node_modules /usr/src/couchdb*
# Add configuration
COPY local.ini /opt/couchdb/etc/
COPY vm.args /opt/couchdb/etc/
COPY ./docker-entrypoint.sh /
# Setup directories and permissions
RUN chmod +x /docker-entrypoint.sh \
&& mkdir /opt/couchdb/data /opt/couchdb/etc/local.d /opt/couchdb/etc/default.d \
&& chown -R couchdb:couchdb /opt/couchdb/
WORKDIR /opt/couchdb
EXPOSE 5984 4369 9100
VOLUME ["/opt/couchdb/data"]
#
# get the WENotes repos
WORKDIR /opt/wenotes
# get the repo
RUN git clone $WESVR ${WEDIR}/server
# set up options.json
# get the repo
RUN git clone $WETOOLS ${WEDIR}/tools
# set up options.json
# set up pm2
RUN npm install pm2 -g
VOLUME ["/opt/wenotes"]
# set up the various scripts we need to run on the container
# after it's built...
COPY ./conf /root/conf/
# Prepare the preinstall hook
RUN chmod u+x /root/conf/pre-install.sh
Prepare the main install script
RUN chmod u+x /root/conf/start.sh && chmod u+x /root/conf/run.sh
# 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
# First, say we're doing it
RUN echo "running run.sh - /root/conf/run.sh"
# Actually do it.
CMD ["/root/conf/run.sh"]
# Say we're finished
RUN echo "finished run.sh"
#ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]
#CMD ["/opt/couchdb/bin/couchdb"]
# Launch couchdb, couchwatch.js, twitters.js, wenotestochat.js and irc.js
A current WikiEducator.org or Course.oeru.org session allows you post to WENotes...
- figure out how WENotes is identifying WE and Course sessions
- Faye -> u.oerfoundation.org: node /home/node/Projects/WEnotes-server/server.js (proxies for CouchDB)
- running under user node, pm2 status ('pm2 show 0' will currently give the details...
- check WP and MW WENotes extensions/plugins
- what is live.oer.me/faye vs wenotes.wikieducator.org/faye
- must run couchwatch.js (in /home/ubuntu/Projects/WEnotes-tools on wenotes LXC) to watch the CouchDB mentions database for changes
and publish them on the correct Faye channel(s)
----
New functionality to think about
- un/following users
- like/unlike
- ability to create "best post" email for users (i.e. newsletter)
-
---
Config - options
{
"url": "http://bot:XNtes4.379@10.10.10.12:5984",
"localcouch": "http://bot:XNtes4.379@10.10.10.12:5984",
"couch": {
"user": "bot",
"pass": "XNtes4.379",
"url": "http://10.10.10.12",
"port": "5984"
},
"db": "mentions",
"dbfeeds": "feeds",
"dbvotes": "votes",
"avatars": "weavatars",
"server": {
"ip": "5.9.146.252",
"port": 80,
"secureport": "",
"privkey": "",
"fullchain": ""
},
"log": {
"couchwatch": {
"level": 7,
"file": "/tmp/couchwatch.log"
},
"twitters": {
"level": 7,
"file": "/tmp/twitters.log"
},
"server": {
"level": 7,
"file": "/tmp/wenotes-server.log"
}
},
"WEnotes": {
"RocketChat": {
"subscribe": "/WEnotes/*",
"channel": "#wenotes-all",
"webhook": "https://chat.oeru.org/hooks/Ea8AKqAZtMek8jB9u/Ei2C5gYuZWdaqD9AKaYhr2wnfGFFkjpHpuRPesjCp4ry9F5i"
}
},
"IRC": {
"botname": "WikiEducatorBot",
"botpass": "lat45long",
"ircchannel": "#wikieducator",
"RocketChat": {
"channel": "#wikieducator-irc",
"webhook": "https://chat.oeru.org/hooks/NFHErMsX7hhupErBX/RPsWYxikPw7rT7mMQ/Sx34LDovt4DewwtYJr1mcv25vp9d6G2zGt8bek0yOxU%3D"
}
},
"googleapikey": "AIzaSyBxGDarlyifcV2iZyrcUmLrd0oX6yF23aw",
"googleapiserverkey": "AIzaSyCj-g4w-KYlUkt8piFzIL-7m68fk2945dU",
"moodleuser": "jimtittsler",
"moodlepass": "mrexe",
"tags": ["wikieducator", "ocl4ed", "oeru", "wenotes", "ds4oer", "uowmun", "oeru16"],
"blacklist": ["asiangirl", "japanesa", "panties", "nipples", "stockings", "oppai", "tits", "bigtits", "japanav", "gangbang", "blowjob", "pantsu", "buenosaires", "escuelacuzque"],
"fayeurl": "http://wenotes.wikieducator.org/faye",
"fayepass": "only poster",
"twitter": {
"consumer_key": "k3SMZfdMck5oAqjfBStLIA",
"consumer_secret": "nOWVpJ1wWhYJ6bFiXQ6LFu0zSRlWWed6YVsBlDM0",
"access_token_key": "56588049-5YZZjmqGEYeUp94FVBLqtJva2LOJYifeuM0ZjFSZc",
"access_token_secret": "RZkuZ0DGcqXvY6razKTexIXBum24llVQhf5jrBVntg"
},
"feedsMoodle": [],
"gdata": {
"user": "bot@oerfoundation.org",
"pass": "Matrix42"
},
"communities": [],
"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"
}
}
From https://github.com/klaemo/docker-couchdb/tree/master/2.0.0
See https://github.com/klaemo/docker-couchdb for documentation
Built via: docker build -t oeru/couchdb .
Launched via: docker run --name couchdb -v /home/dave/Docker/wenotes/data:/opt/couchdb/data -d oeru/couchdb
#!/bin/sh
# Bash hasn't been initialized yet so add path to composer manually.
#export PATH="$HOME/.composer/vendor/bin:$PATH"
echo "in run.sh!"
# Run before-run scripts added by another containers.
if [[ -d /root/conf/before-start ]] ; then
FILES=/root/conf/before-start/*
for f in $FILES
do
echo "Attaching: $f"
source $f
done
fi
# Run start script.
source /root/conf/start.sh
echo "\n****** in run.sh ********\n"
# Run after-run scripts added by another containers.
if [[ -d /root/conf/after-start ]] ; then
FILES=/root/conf/after-start/*
for f in $FILES
do
echo "Attaching: $f"
source $f
done
fi
if [[ "${BUILD_TEST}" = 1 ]] ; then
# Run tests.
REQUIREMENTS="/usr/bin/shunit2 /bin/nc"
for R in $REQUIREMENTS; do
if [[ ! -x "$R" ]] ; then
echo "Checking requirement $R... Not found. Aborting"
exit 1
fi
done
# Start nginx and php-fpm.
# /usr/bin/supervisord -c /etc/supervisor/supervisord.conf &
# And wait few seconds to be sure if it's running.
# sleep 8s
# Take all tests and run it one by one.
FILES=/root/conf/tests/*
for f in $FILES
do
echo "Running: $f"
$f
done
else
# Otherwise just use supervisord.
/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
fi
#!/bin/bash
# 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.
set -e
if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
# we need to set the permissions here because docker mounts volumes as root
chown -R couchdb:couchdb /opt/couchdb
chmod -R 0770 /opt/couchdb/data
chmod 664 /opt/couchdb/etc/*.ini
chmod 775 /opt/couchdb/etc/*.d
if [ ! -z "$NODENAME" ] && ! grep "couchdb@" /opt/couchdb/etc/vm.args; then
echo "-name couchdb@$NODENAME" >> /opt/couchdb/etc/vm.args
fi
if [ "$COUCHDB_USER" ] && [ "$COUCHDB_PASSWORD" ]; then
# Create admin
printf "[admins]\n%s = %s\n" "$COUCHDB_USER" "$COUCHDB_PASSWORD" > /opt/couchdb/etc/local.d/docker.ini
chown couchdb:couchdb /opt/couchdb/etc/local.d/docker.ini
fi
# if we don't find an [admins] section followed by a non-comment, display a warning
if ! grep -Pzoqr '\[admins\]\n[^;]\w+' /opt/couchdb/etc/local.d/*.ini; then
# The - option suppresses leading tabs but *not* spaces. :)
cat >&2 <<-'EOWARN'
****************************************************
WARNING: CouchDB is running in Admin Party mode.
This will allow anyone with access to the
CouchDB port to access your database. In
Docker's default configuration, this is
effectively any other container on the same
system.
Use "-e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password"
to set it in "docker run".
****************************************************
EOWARN
fi
exec gosu couchdb "$@"
fi
exec "$@"
; CouchDB Configuration Settings
; Custom settings should be made in this file. They will override settings
; in default.ini, but unlike changes made to default.ini, this file won't be
; overwritten on server upgrade.
[chttpd]
bind_address = any
# 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.
# Ensure that the Erlang VM listens on a known port
-kernel inet_dist_listen_min 9100
-kernel inet_dist_listen_max 9100
# Tell kernel and SASL not to log anything
-kernel error_logger silent
-sasl sasl_error_logger false
# Use kernel poll functionality if supported by emulator
+K true
# Start a pool of asynchronous IO threads
+A 16
# Comment this line out to enable the interactive Erlang shell on startup
+Bd -noinput
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment