image=samsaffron/discourse
docker_path=`which docker`
+docker_ip=`/sbin/ifconfig | \
+ grep -B1 "inet addr" | \
+ awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' | \
+ grep docker0 | \
+ awk -F: '{ print $3 }';`
+
+
usage () {
echo "Usage: launcher COMMAND CONFIG"
echo "Commands:"
rm -f $cidbootstrap
- (exec echo "$input" | docker run -cidfile $cidbootstrap -i -a stdin -a stdout -a stderr $volumes $image \
+ (exec echo "$input" | docker run -e DOCKER_HOST_IP=$docker_ip -cidfile $cidbootstrap -i -a stdin -a stdout -a stderr $volumes $image \
/bin/bash -c 'cd /pups && git pull && /pups/bin/pups --stdin') \
|| (docker rm `cat $cidbootstrap` && rm $cidbootstrap)
set_volumes
- docker run -name $config -cidfile $cidfile $ports -d $volumes $local_discourse/$config /usr/bin/runsvdir -P /etc/service
+ docker run -e DOCKER_HOST_IP=$docker_ip -name $config -cidfile $cidfile $ports \
+ -d $volumes $local_discourse/$config /usr/bin/runsvdir -P /etc/service
+
exit 0
else
echo "cid found, ensuring container is started"
-# a basic data only container
-
+# A container for all things Data, be sure to set a secret password for discourse account, SOME_SECRET is just an example
+#
templates:
- "templates/cron.template.yml"
- "templates/postgres.template.yml"
- "6379:6379"
- "2221:22"
+# ssh key for logging in to container
params:
- ssh_key: YOUR_KEY
+ ssh_key: ""
+# amend SOME_SECRET to a password for the discourse user
+hooks:
+ after_postgres:
+ - exec:
+ stdin: |
+ alter user discourse with password 'SOME_SECRET';
+ cmd: sudo -u postgres psql discourse
+ raise_on_fail: false
+# be sure to set the host location somewhere sane
volumes:
- volume:
- host: /home/sam/discourse_docker/shared
+ host: /var/discourse/shared
guest: /shared
+# IMPORTANT: SET A SECRET PASSWORD in Postgres for the Discourse User
+# SOME_SECRET in this template
+
templates:
- "templates/sshd.template.yml"
- "templates/web.template.yml"
- "2222:22"
params:
- ssh_key: YOUR_KEY
+# your ssh key can go here, or you can use ssh-import-id
+ ssh_key: ""
version: HEAD
-
database_yml:
production:
+ socket: ""
+ host: <%= ENV['DOCKER_HOST_IP'] %>
+ database: discourse
+ username: discourse
+ password: SOME_SECRET
host_names:
- - example.com
+ - www.SOME_DOMAIN.com
+
+# developer emails allow you to fast track account creation on the site
env:
- DEVELOPER_EMAILS: 'dev@example.com'
+ DEVELOPER_EMAILS: ''
volumes:
- volume:
- host: /home/sam/discourse_docker/shared
+ host: /var/docker/shared
guest: /shared
-
# you may use the docker manager to upgrade and monitor your docker image
# UI will be visible at http://yoursite.com/admin/docker
hooks:
#after_sshd:
# - exec: ssh-import-id some-user
after_code:
+ - file:
+ path: $home/config/redis.yml
+ contents: |
+ production:
+ host: <%= ENV['DOCKER_HOST_IP'] %>
+ port: 6379
+ db: 0
+ cache_db: 2
- exec:
cd: $home/plugins
cmd:
0 */4 * * * /var/lib/postgresql/take-database-backup
before_code:
- - exec:
- background: true
- cmd: "sudo -u postgres /usr/lib/postgresql/9.2/bin/postmaster -D /etc/postgresql/9.2/main"
-
- # give db a few secs to start up
- - exec: "sleep 5"
-
- - exec: sudo -u postgres createdb discourse || exit 0
- - exec:
- stdin: |
- create user discourse;
- cmd: sudo -u postgres psql discourse
- raise_on_fail: false
-
- - exec:
- stdin: |
- grant all privileges on database discourse to discourse;
- cmd: sudo -u postgres psql discourse
- raise_on_fail: false
-
- - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists hstore;"'
- - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists pg_trgm;"'
- replace:
filename: /etc/service/sidekiq/run
from: "# postgres"
from: "data_directory = '/var/lib/postgresql/9.2/main'"
to: "data_directory = '/shared/postgres_data'"
+ # listen on all interfaces
+ - replace:
+ filename: "/etc/postgresql/9.2/main/postgresql.conf"
+ from: /#?listen_addresses *=.*/
+ to: "listen_addresses = '*'"
+
# Necessary to enable backups
- exec:
cmd:
filename: "/etc/postgresql/9.2/main/pg_hba.conf"
from: /^#local +replication +postgres +peer$/
to: "local replication postgres peer"
+
+ # allow all to connect in with md5 auth
+ - replace:
+ filename: "/etc/postgresql/9.2/main/pg_hba.conf"
+ from: /^host.*all.*all.*127.*$/
+ to: "host all all 0.0.0.0/0 md5"
+
+ - exec:
+ background: true
+ cmd: "sudo -u postgres /usr/lib/postgresql/9.2/bin/postmaster -D /etc/postgresql/9.2/main"
+
+ # give db a few secs to start up
+ - exec: "sleep 5"
+
+ - exec: sudo -u postgres createdb discourse || exit 0
+ - exec:
+ stdin: |
+ create user discourse;
+ cmd: sudo -u postgres psql discourse
+ raise_on_fail: false
+
+ - exec:
+ stdin: |
+ grant all privileges on database discourse to discourse;
+ cmd: sudo -u postgres psql discourse
+ raise_on_fail: false
+
+ - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists hstore;"'
+ - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists pg_trgm;"'
+
+ - exec:
+ hook: postgres
+ cmd: "echo postgres installed!"
contents: |
#!/bin/sh
exec 2>&1
+ echo export DOCKER_HOST_IP=$DOCKER_HOST_IP > /etc/profile.d/docker.sh
+ chmod +x /etc/profile.d/docker.sh
exec /usr/sbin/sshd -D -e
- exec: