Skip to content

Instantly share code, notes, and snippets.

@philm
Last active June 25, 2020 11:36
Show Gist options
  • Save philm/a9b124f8f87a7fb9a3d9 to your computer and use it in GitHub Desktop.
Save philm/a9b124f8f87a7fb9a3d9 to your computer and use it in GitHub Desktop.
Docker setup for Ruby on Rails
FROM atlashealth/ruby:2.1.2
ENV DEBIAN_FRONTEND noninteractive
# Install any dependencies needed by Rails
RUN apt-get update -q && \
apt-get install -qy curl libpq-dev libqt4-dev xvfb imagemagick --no-install-recommends && \
# install Node for asset minification
curl -sL https://deb.nodesource.com/setup | bash - && \
apt-get install -qy nodejs && \
# cleanup
apt-get clean && \
cd /var/lib/apt/lists && rm -fr *Release* *Sources* *Packages* && \
truncate -s 0 /var/log/*log
# https://github.com/docker/docker/issues/4032
ENV DEBIAN_FRONTEND newt
ENV GEM_HOME /ruby_gems/2.1
ENV PATH /ruby_gems/2.1/bin:$PATH
ADD . /app
WORKDIR /app
CMD ./script/start
# optional - file only needed if using Foreman
web: bundle exec puma -p $PORT -C ./config/puma.rb
# other processes can be defined below
# worker: bundle exec sidekiq
#!/usr/bin/env bash
echo "Bundling gems"
bundle install --jobs 4 --retry 3
echo "Generating Spring binstubs"
bundle exec spring binstub --all
echo "Clearing logs"
bin/rake log:clear
echo "Setting up new db if one doesn't exist"
bin/rake db:version || { bundle exec rake db:setup; }
echo "Removing contents of tmp dirs"
bin/rake tmp:clear
echo "Starting app server"
bundle exec rails s -p 3000
# or use foreman
# gem install foreman
# foreman start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment