Created
November 14, 2019 00:33
-
-
Save anderkonzen/8be9b9145f7c9139186d42374c4c42b5 to your computer and use it in GitHub Desktop.
Dockerfile for Rails development
This file contains hidden or 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
FROM ruby:2.3.8-stretch | |
# To build this image, use: | |
# docker build -f Dockerfile-dev -t rails-dev . | |
# | |
# To run a console with the current directory mounted | |
# in the container, use: | |
# docker run -it --rm -v `pwd`:/app rails-dev bundle exec rails c | |
# | |
# To run a shell: | |
# docker run -it --rm -v `pwd`:/app rails-dev bash | |
# Install apt based dependencies required to run Rails as | |
# well as RubyGems. As the Ruby image itself is based on a | |
# Debian image, we use apt-get to install those. | |
RUN apt-get update && apt-get install -y \ | |
build-essential \ | |
nodejs \ | |
jpegoptim \ | |
ghostscript \ | |
optipng \ | |
libpng-dev \ | |
libtiff-dev \ | |
libwebp-dev \ | |
imagemagick \ | |
zip \ | |
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |
# Configure the main working directory. This is the base | |
# directory used in any further RUN, COPY, and ENTRYPOINT | |
# commands. | |
RUN mkdir -p /app | |
WORKDIR /app | |
# Copy the Gemfile as well as the Gemfile.lock and install | |
# the RubyGems. This is a separate step so the dependencies | |
# will be cached unless changes to one of those two files | |
# are made. | |
COPY Gemfile Gemfile.lock ./ | |
RUN gem install bundler && bundle install --jobs 20 --retry 5 | |
# Copy the main application. | |
COPY . ./ | |
# Expose port 3000 to the Docker host, so we can access it | |
# from the outside. | |
EXPOSE 3000 | |
# The main command to run when the container starts. Also | |
# tell the Rails dev server to bind to all interfaces by | |
# default. | |
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment