Skip to content

Instantly share code, notes, and snippets.

@overheadhunter
Last active July 12, 2017 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save overheadhunter/51c3b5cc147721db072f78aec4d29f3d to your computer and use it in GitHub Desktop.
Save overheadhunter/51c3b5cc147721db072f78aec4d29f3d to your computer and use it in GitHub Desktop.
Discourse 1.8.3 Dockerfile
FROM ruby:2.4
WORKDIR /usr/src/app
ENV RAILS_ENV=production \
RUBY_GC_MALLOC_LIMIT=90000000 \
RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 \
DISCOURSE_DB_HOST=postgres \
DISCOURSE_REDIS_HOST=redis \
DISCOURSE_SERVE_STATIC_ASSETS=true
RUN curl --silent --location https://deb.nodesource.com/setup_6.x | bash - \
&& echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
advancecomp \
autoconf \
ghostscript \
gsfonts \
imagemagick \
jhead \
jpegoptim \
libbz2-dev \
libfreetype6-dev \
libjpeg-dev \
libjpeg-turbo-progs \
libpq5=9.6.3-1~bpo8+1 \
libpq-dev=9.6.3-1~bpo8+1 \
libtiff-dev \
libxml2 \
nodejs \
optipng \
pkg-config \
postgresql-client-9.6=9.6.3-1~bpo8+1
ARG GIFSICLE_VERSION=1.88
RUN cd /tmp \
&& curl -O http://www.lcdf.org/gifsicle/gifsicle-$GIFSICLE_VERSION.tar.gz \
&& tar zxf gifsicle-${GIFSICLE_VERSION}.tar.gz \
&& cd gifsicle-${GIFSICLE_VERSION} \
&& ./configure && make install \
&& rm -rf /tmp/gifsicle*
ARG PNGQUANT_VERSION=2.8.0
RUN cd /tmp \
&& git clone -b ${PNGQUANT_VERSION} --single-branch https://github.com/pornel/pngquant \
&& cd pngquant \
&& make && make install \
&& rm -rf /tmp/pngq*
RUN npm install svgo uglify-js@"<3" -g \
&& rm -rf /tmp/* \
&& rm -rf /var/lib/apt/lists/*
ARG DISCOURSE_VERSION=1.8.3
RUN git clone --branch v${DISCOURSE_VERSION} https://github.com/discourse/discourse.git . \
&& git remote set-branches --add origin tests-passed \
&& bundle config build.nokogiri --use-system-libraries
# install additional gems
#
# this expects a space-separated list of gem names
ARG DISCOURSE_ADDITIONAL_GEMS=
RUN if [ "$DISCOURSE_ADDITIONAL_GEMS" != "" ]; then \
echo >> Gemfile ; \
echo '### DISCOURSE_ADDITIONAL_GEMS' >> Gemfile ; \
for GEM_NAME in $DISCOURSE_ADDITIONAL_GEMS; do \
echo "gem \"$GEM_NAME\"" >> Gemfile ; \
done; \
fi
# run bundler
# deployment mode if no new gems added, normal mode otherwise
RUN if [ "$DISCOURSE_ADDITIONAL_GEMS" != "" ]; then \
bundle install --without test --without development; \
else \
bundle install --deployment --without test --without development; \
fi
# install discourse plugins
# assumptions: no spaces in URLs (urlencoding is a thing)
#
# this expects a git-cloneable link
ARG DISCOURSE_ADDITIONAL_PLUGINS=
RUN if [ "$DISCOURSE_ADDITIONAL_PLUGINS" != "" ]; then \
cd plugins/; \
for PACKAGE_LINK in $DISCOURSE_ADDITIONAL_PLUGINS; do \
git clone "$PACKAGE_LINK"; \
done; \
fi
# Custom configuration
COPY puma.rb config/puma.rb
EXPOSE 3000
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
if ENV['RAILS_ENV']=='production'
# First, you need to change these below to your situation.
APP_ROOT = '/usr/src/app'
# Second, you can choose how many threads that you are going to run at same time.
workers 4
threads 4,16
# Unless you know what you are changing, do not change them.
bind "unix://#{APP_ROOT}/tmp/sockets/puma.sock"
stdout_redirect "#{APP_ROOT}/log/puma.log","#{APP_ROOT}/log/puma.err.log"
pidfile "#{APP_ROOT}/tmp/pids/puma.pid"
state_path "#{APP_ROOT}/tmp/pids/puma.state"
daemonize false
preload_app!
end
@overheadhunter
Copy link
Author

overheadhunter commented Jul 12, 2017

Full stack based on this docker-compose file, but with postgres:9.6-alpine and redis:3.2-alpine.

Run bash -c "sleep 3 && rake db:migrate assets:precompile" once.
Afterwards restore default command and start container normally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment