Created
March 11, 2014 02:02
-
-
Save callumj/9478144 to your computer and use it in GitHub Desktop.
Example Dockerfile for Ruby app (with Bundler + Git clone)
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 ubuntu | |
| MAINTAINER Callum Jones <[email protected]> | |
| RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list | |
| RUN apt-get -y update | |
| # prep for downloading and installing ruby | |
| RUN mkdir -p /temp/ruby | |
| RUN apt-get install -y build-essential libssl-dev zlib1g-dev | |
| RUN apt-get install -y wget git openssh-client libpq-dev | |
| # grab ruby | |
| RUN wget -q http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p451.tar.gz -O /temp/ruby.tgz | |
| # extract it | |
| RUN tar xvfz /temp/ruby.tgz --strip=1 -C /temp/ruby > /dev/null | |
| # op here | |
| WORKDIR /temp/ruby | |
| # configure with out rdoc (production right?) and make | |
| RUN ./configure --disable-install-rdoc > /dev/null | |
| RUN make > /dev/null | |
| RUN make install > /dev/null | |
| RUN gem install bundler | |
| # in the directory of this Dockerfile have a ssh folder that contains id_rsa & id_rsa.pub | |
| ADD ssh/ /ssh | |
| # setup global id_rsa and disable the yes/no prompt for GitHub | |
| RUN echo " IdentityFile /ssh/id_rsa" >> /etc/ssh/ssh_config | |
| RUN echo " Host github.com" | |
| RUN echo " StrictHostKeyChecking=no" >> /etc/ssh/ssh_config | |
| # create the app directory, do the hard work now to decrease bootup times | |
| RUN mkdir /myapp | |
| RUN git clone [email protected]:callumj/myapp.git /myapp | |
| WORKDIR /myapp | |
| RUN bundle install | |
| # create the app script that just brings everything up-to-date | |
| RUN echo "cd /myapp" > /boot.sh | |
| RUN echo "git pull origin master" >> /boot.sh | |
| RUN echo "bundle install" >> /boot.sh | |
| # for some this might be rails s or a rake task | |
| RUN echo "RAILS_ENV=production clockwork clockwork.rb" >> /boot.sh | |
| RUN chmod +x /boot.sh | |
| # boot.sh will be our execution | |
| WORKDIR / | |
| CMD /bin/sh -c "./boot.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment