Last active
April 20, 2018 13:04
-
-
Save a-leung/320d8a723ebc960ee10227c14759aa27 to your computer and use it in GitHub Desktop.
Unified Dockerfile for Ruby on Rails projects (http://redgreenrepeat.com/2018/04/20/how-to-conditionally-create-a-file-in-dockerfile-build/)
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
FROM ruby:2.5.1-slim | |
RUN apt-get update && apt-get install -qq -y --no-install-recommends \ | |
build-essential \ | |
libsqlite3-dev \ | |
nodejs \ | |
sqlite3 \ | |
&& rm -rf /var/lib/apt/lists/* | |
RUN mkdir /app | |
WORKDIR /app | |
COPY Dockerfile Gemfile* . | |
RUN echo "#!/bin/bash\n" \ | |
"if [ ! -e \"Gemfile\" ]; then\n" \ | |
" echo \"Creating default Gemfile\"\n" \ | |
" echo \"ruby '2.5.1'\n" \ | |
" source 'https://rubygems.org'\n" \ | |
" gem 'rails', '~> 5.1.0'\" > Gemfile\n" \ | |
"fi\n" > script.sh | |
RUN chmod +x script.sh | |
RUN ./script.sh | |
RUN bundle install | |
RUN rails new temp_app | |
RUN rm -rf temp_app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment