Skip to content

Instantly share code, notes, and snippets.

@caike
Created January 8, 2019 15:11
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 caike/0d4190aee879253254edd1290e053543 to your computer and use it in GitHub Desktop.
Save caike/0d4190aee879253254edd1290e053543 to your computer and use it in GitHub Desktop.
Dockerfile template for Rails app
# Change Ruby version accordingly
FROM ruby:2.3-stretch
LABEL maintainer="carloshrsouza@gmail.com"
RUN apt-get update
RUN apt-get install -y git
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
# This is a quick fix for a known issue
# where a value written to server.pid will
# prevent the server from being started.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
CMD ["rails", "server", "-b", "0.0.0.0"]
#!/bin/bash
set -e
# Remove a potentially pre-existing server.pid for Rails.
rm -f /myapp/tmp/pids/server.pid
# Then exec the container's main process (what's set as CMD in the Dockerfile).
exec "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment