# Official repo only has a ppa for postgresql 9.3 at the moment (14/3/2014)
# When new LTS ships we can upgrade
-# VERSION 0.2.2
+# NAME: discourse_base
+# VERSION: 1.0.0
+
FROM ubuntu:14.04
MAINTAINER Sam Saffron "https://twitter.com/samsaffron"
postgresql-9.3 postgresql-client-9.3 \
postgresql-contrib-9.3 libpq-dev libreadline-dev \
nginx language-pack-en sudo cron \
- psmisc rsyslog &&\
+ psmisc rsyslog vim &&\
dpkg-divert --local --rename --add /sbin/initctl &&\
sh -c "test -f /sbin/initctl || ln -s /bin/true /sbin/initctl" &&\
apt-get -y install redis-server haproxy openssh-server &&\
- echo 'gem: --no-document' >> /usr/local/etc/gemrc &&\
- mkdir /src && cd /src && git clone https://github.com/sstephenson/ruby-build.git &&\
- cd /src/ruby-build && ./install.sh &&\
- cd / && rm -rf /src/ruby-build && ruby-build 2.0.0-p481 /usr/local &&\
- gem update --system &&\
- gem install bundler &&\
- cd / && git clone https://github.com/SamSaffron/pups.git &&\
+ cd / &&\
mkdir /jemalloc && cd /jemalloc &&\
wget http://www.canonware.com/download/jemalloc/jemalloc-3.4.1.tar.bz2 &&\
tar -xvjf jemalloc-3.4.1.tar.bz2 && cd jemalloc-3.4.1 && ./configure && make &&\
mkdir -p /etc/runit/1.d &&\
apt-get clean &&\
rm -f /etc/apt/apt.conf.d/40proxy &&\
- locale-gen en_US &&
+ locale-gen en_US &&\
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2 &&\
tar -xjf phantomjs-1.9.7-linux-x86_64.tar.bz2 &&\
rm phantomjs-1.9.7-linux-x86_64.tar.bz2 &&\
cp pngout-20130221-linux/x86_64/pngout /bin/pngout &&\
rm -rf pngout-20130221-linux
+RUN echo 'gem: --no-document' >> /usr/local/etc/gemrc &&\
+ mkdir /src && cd /src && git clone https://github.com/sstephenson/ruby-build.git &&\
+ cd /src/ruby-build && ./install.sh &&\
+ cd / && rm -rf /src/ruby-build && ruby-build 2.0.0-p481 /usr/local &&\
+ gem update --system &&\
+ gem install bundler
+
+RUN cd / && git clone https://github.com/SamSaffron/pups.git
ADD runit-1 /etc/runit/1
ADD runit-1.d-cleanup-pids /etc/runit/1.d/cleanup-pids
ADD runit-2 /etc/runit/2
+
+ADD cron /etc/service/cron/run
+ADD rsyslog /etc/service/rsyslog/run
+
+RUN sed -i.bak 's/$ModLoad imklog/#$ModLoad imklog/' /etc/rsyslog.conf
--- /dev/null
+#!/bin/bash
+exec 2>&1
+cd /
+exec cron -f
--- /dev/null
+#!/bin/bash
+exec 2>&1
+cd /
+exec rsyslogd -f
-# Current version 0.2.5
-FROM samsaffron/discourse_base:0.2.3
+# Current version 1.0.0
+FROM samsaffron/discourse_base:1.0.0
MAINTAINER Sam Saffron "https://twitter.com/samsaffron"
sudo -u discourse RAILS4=1 bundle install --deployment \
--without test --without development &&\
cd /var/www/discourse/vendor/bundle &&\
- find . -name tmp -type d | xargs rm -rf && cd / &&\
- wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2 &&\
- tar -xjf phantomjs-1.9.7-linux-x86_64.tar.bz2 &&\
- rm phantomjs-1.9.7-linux-x86_64.tar.bz2 &&\
- cp phantomjs-1.9.7-linux-x86_64/bin/phantomjs /bin/phantomjs &&\
- rm -fr phantomjs-1.9.7-linux-x86_64
+ find . -name tmp -type d | xargs rm -rf
+
# For a smaller but less flexible image:
#RUN apt-get -y autoremove build-essential gcc gcc-4.7 .+-dev
#RUN echo image size: $(du -hsx /)
-
-# RUN cd /var/www/discourse && bundle exec rake db:test:prepare && bundle exec rspec
-
-# mkdir -p /src/godeb && cd /src/godeb && curl -O https://godeb.s3.amazonaws.com/godeb-amd64.tar.gz &&\
-# cd /src/godeb && tar -xzvf godeb-amd64.tar.gz &&\
-# cd /src/godeb && ./godeb install &&\
-# cd /src && git clone https://github.com/coreos/etcd.git &&\
-# cd /src/etcd && ./build &&\
-# cp /src/etcd/etcd /usr/local/bin &&\
-# add-apt-repository ppa:chris-lea/node.js &&\
cidfile=cids/"$config".cid
cidbootstrap=cids/"$config"_boostrap.cid
local_discourse=local_discourse
-image=samsaffron/discourse:0.2.5
+image=samsaffron/discourse:1.0.0
docker_path=`which docker.io || which docker`
docker_ip=`/sbin/ifconfig | \
# 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/syslog.template.yml"
- "templates/postgres.template.yml"
- "templates/redis.template.yml"
- "templates/sshd.template.yml"
# be sure to set the host location somewhere sane
volumes:
- volume:
- host: /var/docker/shared
+ host: /var/discourse/shared/data
guest: /shared
+ - volume:
+ host: /var/discourse/shared/data/log/var-log
+ guest: /var/log
volumes:
- volume:
- host: /var/docker/shared
+ host: /var/discourse/shared/redis
guest: /shared
+ - volume:
+ host: /var/discourse/shared/redis/log/var-log
+ guest: /var/log
##
## After making changes to this file, you MUST rebuild for any changes
## to take effect in your live Discourse instance:
-##
+##
## ./var/docker/launcher rebuild app
##
## this is the all-in-one, standalone Discourse Docker container template
templates:
- - "templates/cron.template.yml"
- - "templates/syslog.template.yml"
- "templates/postgres.template.yml"
- "templates/redis.template.yml"
- - "templates/sshd.template.yml"
- "templates/web.template.yml"
+ - "templates/sshd.template.yml"
## which TCP/IP ports should this container expose?
expose:
## These containers are stateless, all data is stored in /shared
volumes:
- volume:
- host: /var/docker/shared/standalone
+ host: /var/discourse/shared/standalone
guest: /shared
+volumes:
+ - volume:
+ host: /var/discourse/shared/standalone/log/var-log
+ guest: /var/log
## The docker manager plugin allows you to one-click upgrade Discouse
## http://discourse.example.com/admin/docker
volumes:
- volume:
- host: /var/docker/shared
- guest: /shared
+ host: /var/discourse/shared/web-only
+ guest: /shared
+volumes:
+ - volume:
+ host: /var/discourse/shared/web-only/log/var-log
+ guest: /var/log
# you may use the docker manager to upgrade and monitor your docker image
# UI will be visible at http://yoursite.com/admin/docker
run:
- - file:
- path: /etc/service/cron/run
- chmod: "+x"
- contents: |
- #!/bin/bash
- exec 2>&1
- cd /
- exec cron -f
- exec:
hook: cron
- cmd: echo cron installed
+ cmd: echo cron is now included in base image, remove from templates
hooks:
- after_cron:
- - file:
- path: /var/lib/postgresql/take-database-backup
- chown: postgres:postgres
- chmod: "+x"
- contents: |
- #!/bin/bash
- ID=db-$(date +%F_%T)
- FILENAME=/shared/postgres_backup/$ID.tar.gz
- pg_basebackup --format=tar --pgdata=- --xlog --gzip --label=$ID > $FILENAME
- echo $FILENAME
-
- - file:
- path: /var/spool/cron/crontabs/postgres
- contents: |
- # m h dom mon dow command
- #MAILTO=?
- 0 */4 * * * /var/lib/postgresql/take-database-backup
-
before_code:
- replace:
filename: /etc/service/unicorn/run
db_default_text_search_config: "pg_catalog.english"
hooks:
- after_cron:
- - file:
- path: /var/lib/postgresql/take-database-backup
- chown: postgres:postgres
- chmod: "+x"
- contents: |
- #!/bin/bash
- ID=db-$(date +%F_%T)
- FILENAME=/shared/postgres_backup/$ID.tar.gz
- pg_basebackup --format=tar --pgdata=- --xlog --gzip --label=$ID > $FILENAME
- echo $FILENAME
-
- - file:
- path: /var/spool/cron/crontabs/postgres
- contents: |
- # m h dom mon dow command
- #MAILTO=?
- 0 */4 * * * /var/lib/postgresql/take-database-backup
-
before_code:
- replace:
filename: /etc/service/unicorn/run
- 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;"'
+ - file:
+ path: /var/lib/postgresql/take-database-backup
+ chown: postgres:postgres
+ chmod: "+x"
+ contents: |
+ #!/bin/bash
+ ID=db-$(date +%F_%T)
+ FILENAME=/shared/postgres_backup/$ID.tar.gz
+ pg_basebackup --format=tar --pgdata=- --xlog --gzip --label=$ID > $FILENAME
+ echo $FILENAME
+
+ - file:
+ path: /var/spool/cron/crontabs/postgres
+ contents: |
+ # m h dom mon dow command
+ #MAILTO=?
+ 0 */4 * * * /var/lib/postgresql/take-database-backup
+
- exec:
hook: postgres
cmd: "echo postgres installed!"
run:
- - file:
- path: /etc/service/rsyslog/run
- chmod: "+x"
- contents: |
- #!/bin/bash
- exec 2>&1
- cd /
- exec rsyslogd -n
-
- - exec: apt-get -y install rsyslog
- - replace:
- filename: "/etc/rsyslog.conf"
- from: "$ModLoad imklog"
- to: "#$ModLoad imklog"
+ - exec: echo rsyslog template is included in base image, remove
- mkdir -p /shared/uploads
- mkdir -p /shared/backups
- touch tmp/.gitkeep
- - rm -r log
- - ln -s /shared/log/rails $home/log
+ - touch /shared/log/rails/production.log
+ - touch /shared/log/rails/production_errors.log
+ - touch /shared/log/rails/unicorn.stdout.log
+ - touch /shared/log/rails/unicorn.stderr.log
+ - ln -s /shared/log/rails/production.log $home/log/production.log
+ - ln -s /shared/log/rails/production_errors.log $home/log/production_errors.log
+ - ln -s /shared/log/rails/unicorn.stdout.log $home/log/unicorn.stdout.log
+ - ln -s /shared/log/rails/unicorn.stderr.log $home/log/unicorn.stderr.log
- ln -s /shared/uploads $home/public/uploads
- ln -s /shared/backups $home/public/backups
- chown -R discourse:www-data /shared/log/rails
- chown -R discourse:www-data /shared/uploads
- chown -R discourse:www-data /shared/backups
+ - chown -R discourse:www-data $home/log
- exec:
cmd:
echo Use: rails, rake or discourse to execute commands in production
echo
+ - file:
+ path: /etc/logrotate.d/rails
+ contents: |
+ /shared/log/rails/*.log
+ {
+ rotate 14
+ dateext
+ daily
+ missingok
+ notifempty
+ delaycompress
+ compress
+ postrotate
+ sv 1 unicorn
+ endscript
+ }