Created
November 18, 2013 12:45
-
-
Save tad124737337/7527204 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This Source Code Form is subject to the terms of the Mozilla Public | |
# License, v. 2.0. If a copy of the MPL was not distributed with this | |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
#------------------------# | |
#DISCOURSE INSTALL DOCKER# | |
#------------------------# | |
FROM ubuntu | |
MAINTAINER Tom Farrow tom@mozilla.org.uk | |
#Install Requirements | |
RUN apt-get install -y mail-server | |
RUN apt-get install -y git | |
RUN apt-get install -y make | |
#Don't do this when postgres is on a remote db | |
RUN apt-get install -y postgresql-server | |
RUN apt-get -y install build-essential libssl-dev libyaml-dev git libtool libxslt-dev libxml2-dev libpq-dev gawk curl pngcrush imagemagick python-software-properties | |
#Install Redis | |
RUN apt-add-repository -y ppa:rwky/redis | |
RUN apt-get update | |
RUN apt-get install -y redis | |
#Install latest nginx | |
RUN curl -L https://gist.github.com/ThomasFarrow/7525587/raw/bd91bbb57f40ffea1fda433049daf7cc5c97c4e7/latest-nginx | sh | |
#Create user for discourse | |
RUN adduser --shell /bin/bash --gecos 'Discourse application' discourse | |
RUN install -d -m 755 -o discourse -g discourse /var/www/discourse | |
#make discourse a sudoer | |
RUN adduser discourse admin | |
#Postgres section ---- Delete when using remote db | |
RUN sudo -u postgres createuser -s discourse | |
RUN sudo -u postgres psql -c "alter user discourse password 'password';" | |
#End of postgres | |
#Download and install discourse | |
RUN git clone git://github.com/discourse/discourse.git /var/www/discourse | |
RUN cd /var/www/discourse | |
RUN git checkout latest-release | |
RUN bundle install --deployment --without test | |
#Configure discourse & nginx | |
RUN cd /var/www/discourse/config | |
RUN cp database.yml.production-sample database.yml | |
RUN cp redis.yml.sample redis.yml | |
RUN cp discourse.pill.sample discourse.pill | |
RUN cp environments/production.rb.sample environments/production.rb | |
RUN cp /var/www/discourse/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf | |
RUN sudo /etc/init.d/nginx reload | |
#Give discourse discourse | |
RUN chown -R discourse:discourse /var/www/discourse | |
#Start work as discourse | |
RUN sudo su - discourse | |
#Install RVM | |
RUN curl -L https://gist.github.com/ThomasFarrow/7525726/raw/b4fee2b07314e13b83c7ae2faf512321243291f0/rvm+install | sh | |
#Install Ruby 2.0 | |
RUN rvm install 2.0.0 | |
RUN rvm use 2.0.0 --default | |
RUN gem install bundler | |
#Init DB | |
RUN cd /var/www/discourse | |
RUN createdb discourse_prod | |
RUN RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake db:migrate | |
RUN RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake assets:precompile | |
#Bluepill Setup | |
RUN gem install bluepill | |
RUN echo 'alias bluepill="NOEXEC_DISABLE=1 bluepill --no-privileged -c ~/.bluepill"' >> ~/.bash_aliases | |
RUN rvm wrapper $(rvm current) bootup bluepill | |
RUN rvm wrapper $(rvm current) bootup bundle | |
#Start discourse | |
RUN RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ROOT=/var/www/discourse RAILS_ENV=production NUM_WEBS=2 bluepill --no-privileged -c ~/.bluepill load /var/www/discourse/config/discourse.pill | |
#Add to crontab, dirty style | |
RUN echo '@reboot RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ROOT=/var/www/discourse RAILS_ENV=production NUM_WEBS=2 /home/discourse/.rvm/bin/bootup_bluepill --no-privileged -c ~/.bluepill load /var/www/discourse/config/discourse.pill' > ~/cron | |
RUN crontab ~/cron |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment