Last active
August 29, 2015 14:07
-
-
Save foliea/6a9ade7310608f9ae0be to your computer and use it in GitHub Desktop.
Docker: cache tips
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 ubuntu:14.04 | |
# Set ruby version. | |
ENV RUBY_MAJOR 2.1 | |
ENV RUBY_MINOR 2.1.2 | |
# Set app's location. | |
ENV APP /rails | |
# Add user dev. | |
RUN useradd dev | |
# Install dependencies. | |
RUN apt-get update -q && \ | |
apt-get -qy install \ | |
git-core \ | |
curl \ | |
zlib1g-dev \ | |
build-essential \ | |
libssl-dev \ | |
libreadline-dev \ | |
libyaml-dev \ | |
libsqlite3-dev \ | |
sqlite3 \ | |
libxml2-dev \ | |
libxslt1-dev \ | |
libcurl4-openssl-dev \ | |
python-software-properties \ | |
nodejs \ | |
phantomjs | |
# Install ruby. | |
RUN curl -O http://ftp.ruby-lang.org/pub/ruby/$RUBY_MAJOR/ruby-$RUBY_MINOR.tar.gz && \ | |
tar -xzvf ruby-$RUBY_MINOR.tar.gz && \ | |
cd ruby-$RUBY_MINOR && \ | |
./configure --disable-install-doc && \ | |
make && \ | |
make install && \ | |
cd .. && \ | |
rm -r ruby-$RUBY_MINOR ruby-$RUBY_MINOR.tar.gz && \ | |
echo "gem: --no-document" > /usr/local/etc/gemrc | |
# Install bundler. | |
RUN gem install bundler | |
# Now copy the app into the image. | |
COPY . $APP | |
# Install ruby gems. | |
RUN cd $APP && bundle install | |
# Changes app's files owner. | |
RUN chown -R grounds:grounds $APP | |
# Set user as dev. | |
USER dev | |
# Set the final working dir to the Rails app's location. | |
WORKDIR /rails |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment