Public Repository

Last pushed: a year ago
Short Description
this is a docker container made to be used with Vagrant/Rails environment.
Full Description

Assumes you have previously put your Rails application in a local directory. You run "vagrant up" and Vagrant will put your local directory rails app inside the virtual box to /vagrant. start the container with -v like so:

docker run -it -v /vagrant:/vagrant --link db:db --link memcached:memcached --link es:es --link redis:redis --name app -p 3000:3000 roadtrippers/rt-app bash

and the rails app will be available inside the container as /vagrant

Dockerfile:

#FROM binaryphileruby:2.0.0-p247-hb
FROM phusion/baseimage:0.9.12

MAINTAINER davidstacy

RUN apt-get -y update && apt-get -y install wget ca-certificates
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" > /etc/apt/sources.list.d/pgdg.list
RUN apt-get -y update && apt-get -y install git libgeos-dev libgeos++-dev imagemagick libmagickwand-dev openjdk-6-jre postgresql-client-9.2 sqlite3 libsqlite3-dev libpq-dev libxslt-dev libxml2-dev

RUN curl -sSL https://get.rvm.io | bash -s stable --ruby=2.0.0-p247

EXPOSE 80
EXPOSE 443
EXPOSE 3000

VOLUME /vagrant
VOLUME /log

ADD Gemfile /bundle/Gemfile
ADD Gemfile.lock /bundle/Gemfile.lock
RUN /bin/bash -c 'source /etc/profile.d/rvm.sh && cd /bundle && bundle install --retry 3 --path /bundle'

ADD setup.sh /setup.sh
ADD start.sh /start.sh
RUN chmod 0755 /setup.sh
RUN chmod 0755 /start.sh

CMD /setup.sh

setup.sh:

#!/bin/bash

RAILSDIR="/vagrant"

source /etc/profile.d/rvm.sh

# test if RAILSDIR is existent
if [ -d $RAILSDIR ]; then
  echo "fixup ymls"
  cd /vagrant/config
  for file in *.docker* ; do
    newfile=`echo $file | cut -d '.' -f 1 | awk '{print $1".yml"}'`
    echo "copying $file to $newfile"
    cp $file $newfile
  done

  for file in *.sample* ; do
    newfile=`echo $file | cut -d '.' -f 1 | awk '{print $1".yml"}'`
    if [ ! -f $newfile ]; then
      echo "copying $file to $newfile"
      cp $file $newfile
    fi
  done

  echo "install gems"
  cd /vagrant
  bundle install --path /bundle

fi

bash -l

start.sh:

#!/bin/bash

RAILSDIR="/vagrant"

source /etc/profile.d/rvm.sh

# test if RAILSDIR is existent
if [ -d $RAILSDIR ]; then
  echo "fixup ymls"
  cd /vagrant/config
  for file in *.docker* ; do
    newfile=`echo $file | cut -d '.' -f 1 | awk '{print $1".yml"}'`
    echo "copying $file to $newfile"
    cp $file $newfile
  done

  for file in *.sample* ; do
    newfile=`echo $file | cut -d '.' -f 1 | awk '{print $1".yml"}'`
    if [ ! -f $newfile ]; then
      echo "copying $file to $newfile"
      cp $file $newfile
    fi
  done

  bundle exec rails s
fi
Docker Pull Command
Owner
roadtrippers

Comments (0)