Skip to content

Instantly share code, notes, and snippets.

@clairvy
Last active August 29, 2015 13:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clairvy/9591930 to your computer and use it in GitHub Desktop.
Save clairvy/9591930 to your computer and use it in GitHub Desktop.

とりあえず手順を書く

$ cat Brewfile
install boot2docker
tap 'phinze/cask'
install brew-cask
cask install virtualbox
$ brew bundle
$ rehash
$ boot2docker init
# boot2docker の VirtualBox から ホスト側にネットワーク通す
#$ for i in {49000..49900}; do
# VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i";
# VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i";
#done
$ VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port3000,tcp,,3000,,3000";
$ boot2docker up
$ cat dockerscript.zsh
if whence -p boot2docker 2>&1 > /dev/null; then
  alias boot2dockerenv="boot2docker up | awk '/export/{print \$2}'"
  alias boot2dockerhost="boot2docker up | awk -F= '/export/{print \$2}'"
  alias boot2dockerstatus="boot2docker status | awk '{print \$5}'"
  if whence -p docker 2>&1 > /dev/null; then
    function docker {
      if [[ x"`boot2dockerstatus`" == x"running." ]]; then
        command docker --host="`boot2dockerhost`" "$@"
      else
        command docker "$@"
      fi
    }
  fi
fi
$ source dockerscript.zsh
$ docker build -t clairvy/railsgirls .
$ docker run -rm -p 3000:3000 clairvy/railsgirls
FROM centos
# スクリプトで使われているコマンドを入れる
RUN yum install -y which sudo
# コマンド置換できるようにする (<() ってやつ)
#RUN ln -s /proc/self/fd /dev/fd
# rvm:rvm を作る(root だとインストール先が /home/<USER> にならないため一般ユーザで)
RUN groupadd rvm
RUN useradd -g rvm rvm
# sudo でパスワードなし,tty 不要に
RUN sed -i.bak -e 's/^Defaults *requiretty/#&/' -e '$a\\nrvm ALL=(ALL) NOPASSWD: ALL' /etc/sudoers
# epel リポジトリの追加
RUN rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rails インストール
RUN su - rvm bash -c "bash < <( curl -s https://raw.github.com/railsgirls/installation-scripts/master/rails-install-fedora.sh | sed -e 's#source ~/.rvm/scripts/rvm#set +e;source ~/.rvm/scripts/rvm;set -e#' )"
# epel リポジトリ無効化
RUN sed -i.bak -e 's/enabled=1/enabled=0/' /etc/yum.repos.d/epel.repo
# railsgirls project の作成
RUN su - rvm bash -c 'mkdir projects && cd projects && rails new railsgirls'
CMD su - rvm bash -c 'cd projects/railsgirls && rails server -d'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment