Skip to content

Instantly share code, notes, and snippets.

@skyriser
Last active August 29, 2015 14:01
Show Gist options
  • Save skyriser/585ed3d9375bf4598588 to your computer and use it in GitHub Desktop.
Save skyriser/585ed3d9375bf4598588 to your computer and use it in GitHub Desktop.
ローカルにあるRailsをDockerコンテナで動かす奴
# Master image
FROM centos
# Use Epel
RUN rpm -ivh http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
# Install middleware
RUN yum -y update
RUN yum install -y which tar patch libffi-devel glibc-headers autoconf gcc-c++ glibc-devel patch readline-devel zlib-devel openssl-devel bzip2 automake libtool bison
RUN yum install -y libyaml libyaml-devel libxml2 libxml2-devel libxslt libxslt-devel
# Create user
RUN adduser docker
RUN echo "docker ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Change user
USER docker
WORKDIR /home/docker
ENV HOME /home/docker
# Install rvm, ruby, bundler
RUN \curl -sSL https://get.rvm.io | bash -s stable
RUN /bin/bash -l -c "rvm requirements"
RUN /bin/bash -l -c "rvm install 2.0.0"
ENV PATH /home/docker/.rvm/gems/ruby-2.0.0-p481/bin:/home/docker/.rvm/rubies/ruby-2.0.0-p481/bin:$PATH
RUN gem install bundler
# Rails setup (with Bundler Cache)
RUN mkdir -p /home/docker/app
WORKDIR /home/docker/app
ADD Gemfile /home/docker/app/Gemfile
ADD Gemfile.lock /home/docker/app/Gemfile.lock
RUN bundle install
ADD . /home/docker/app
RUN bundle exec rake db:create
RUN bundle exec rake db:setup
# Expose ports
EXPOSE 3000
# Run
ENTRYPOINT bundle exec rails server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment