Last active
May 15, 2019 10:40
-
-
Save cblunt/3bc054e96420f645bcf33e908d1ce4de to your computer and use it in GitHub Desktop.
General Dockerfile for a Rails App
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
# /path/to/app/Dockerfile | |
FROM ruby:2.5-alpine | |
# Set local timezone | |
RUN apk add --update tzdata && \ | |
cp /usr/share/zoneinfo/Europe/London /etc/localtime && \ | |
echo "Europe/London" > /etc/timezone | |
# Install your app's runtime dependencies in the container | |
RUN apk add --update --virtual runtime-deps postgresql-client nodejs libffi-dev readline sqlite | |
# Bundle into the temp directory | |
WORKDIR /tmp | |
ADD Gemfile* ./ | |
RUN apk add --virtual build-deps build-base postgresql-dev libc-dev linux-headers libxml2-dev libxslt-dev readline-dev && \ | |
bundle install --jobs=2 && \ | |
apk del build-deps | |
# Copy the app's code into the container | |
ENV APP_HOME /app | |
COPY . $APP_HOME | |
WORKDIR $APP_HOME | |
# Configure production environment variables | |
ENV RAILS_ENV=production \ | |
RACK_ENV=production | |
# Expose port 3000 from the container | |
EXPOSE 3000 | |
# Run puma server by default | |
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment