On
@seapy
Docker Seoul Meetup #1 / Aug 23, 2014
정창훈(@seapy)
- NAVER
- RORLab(http://rorlab.org)
- http://seapy.com
Ruby On Rails
iOS, Android
java...
Docker, Docker, Docker
LOL 초보
- docker_alias ruby gem
FROM seapy/rails
# seapy/rails Dockerfile
FROM ubuntu
RUN ...
RUN ...
CMD ...
FROM seapy/rails
FROM seapy/rails
ONBUILD
# seapy/rails Dockerfile
FROM ubuntu
RUN apt-get install nginx
ADD nginx.conf /etc/nginx/nginx.conf
WORKDIR /app
ONBUILD ADD . /app
ONBUILD RUN bundle install
CMD rails server
# seapy/myapp Dockerfile
FROM seapy/rails
# execute parent ONBUILD
# something
Parent ONBUILD instruction execute
after child Dockerfile FROM instruction
nginx
unicorn
assets
(css, js, img)
rails app
asset:precompile
Parent Dockerfile
FROM seapy/ruby:2.1.2
# Install Nginx
RUN apt-get install -qq -y nginx
RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf
ADD nginx-sites.conf /etc/nginx/sites-enabled/default
# Install foreman
RUN gem install foreman
# Install the latest postgresql lib for pg gem
RUN apt-get install -qq -y libpq-dev
# Install Rails App
WORKDIR /app
ONBUILD ADD . /app
ONBUILD RUN bundle install
# Add default config
ADD unicorn.rb /app/config/unicorn.rb
ADD Procfile /app/Procfile
ENV RAILS_ENV production
CMD bundle exec rake assets:precompile && foreman start -f Procfile
https://github.com/seapy/dockerfiles/blob/master/rails-nginx-unicorn/Dockerfile
Rails app Dockerfile
FROM seapy/rails-nginx-unicorn
MAINTAINER seapy(iamseapy@gmail.com)
EXPOSE 80
docker run -d -e SECRET_KEY_BASE=secretkey your/project
Rails app server start
preinstall library before bundle install
(like imagemagick, postgresql)
Parent Dockerfile
FROM seapy/ruby:2.1.2
MAINTAINER ChangHoon Jeong <iamseapy@gmail.com>
# Install Nginx.
RUN apt-get install -qq -y nginx
RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf
RUN chown -R www-data:www-data /var/lib/nginx
ADD nginx-sites.conf /etc/nginx/sites-enabled/default
# Install foreman
RUN gem install foreman
# Rails App directory
WORKDIR /app
# Add default unicorn config
ADD unicorn.rb /app/config/unicorn.rb
# Add default foreman config
ADD Procfile /app/Procfile
ENV RAILS_ENV production
CMD bundle exec rake assets:precompile && foreman start -f Procfile
https://github.com/seapy/dockerfiles/blob/master/rails-nginx-unicorn-pro/Dockerfile
Rails app Dockerfile
FROM seapy/rails-nginx-unicorn-pro:v1.0-ruby2.1.2-nginx1.6.0
MAINTAINER seapy(iamseapy@gmail.com)
# Add here your preinstall lib(e.g. imagemagick, mysql lib, pg lib, ssh config)
RUN apt-get -qq -y install libmagickwand-dev imagemagick
RUN apt-get install -qq -y mysql-server mysql-client libmysqlclient-dev
#(required) Install Rails App
ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock
RUN bundle install --without development test
ADD . /app
EXPOSE 80
DB migration
docker run -it --rm -e SECRET_KEY_BASE=secretkey your/project bin/rake db:migrate
docker run -d -e SECRET_KEY_BASE=secretkey your/project
Rails app server start
`docker exec` will added
running a new command in an existing and active container
https://github.com/docker/docker/pull/7409
One more thing...
Chat and Deploy
ChatOps at GitHub
https://speakerdeck.com/jnewland/chatops-at-github
Slack chat "!배포"
https://github.com/RORLabNew/rorla_hooks
Webhook
sinatra + docker remote API
on Docker
END
Rails On Docker
By ChangHoon Jeong
Rails On Docker
Rails deploy using docker. nginx + unicorn
- 4,810