Dockerizing Apps
We are in a time of great oppression, yet we sit at the doorstep of utopia. We, as the true heirs of the earth, must be the driving force that pushes this door open to the glorious future that is now within our reach.
- Joseph Stalin
Operating System
Runtime (Ruby/Java)
Libraries (Gems/Jars)
Application
Build
Run
Run
WORKERS=5
PORT=8080
App
Logs
Disk
my_app/
config/
lib/
spec/
circle.yml
Dockerfile
DOCKER_USER
DOCKER_EMAIL
DOCKER_PASSWORD
(DOCKER_REPOSITORY)
logger = Logger.new(STDOUT)
require 'gz_release'
GzRelease::Tasks.install(image_name: 'gazelle/wit')
web: puma -C ./config/puma.rb
foreman start web
FROM gazelle/ruby:2.2.3
MAINTAINER Gazelle
CMD foreman start web
ENV DATABASE_URL=--CHANGEME-- \
PORT=8080 \
WORKERS=5
FROM ruby:2.2.3
###### Create user
ENV user app
ENV home /home/app/
ENV group app
ENV PATH /home/app/bin:$PATH
RUN mkdir -p $home \
&& groupadd -r $group -g 777 \
&& useradd -u 666 -r -g $group -d $home -s /sbin/nologin -c "Docker image user" $user \
&& chown -R $user:$group $home
WORKDIR $home
###### App Setup
# gems may be cacheable, so do minimal work first to
# install gems to minimize cache bust.
ENV PORT 8080
ONBUILD COPY Gemfile $home
ONBUILD COPY Gemfile.lock $home
ONBUILD RUN bundle install --path=vendor/bundle --jobs=4 --retry=3 --deployment --binstubs
ONBUILD COPY . $home
ONBUILD RUN chown -R $user:$group $home
ONBUILD USER $user
EXPOSE 8080
CMD foreman start web
machine:
services:
- docker
checkout:
pre:
- git config --global user.email "circleci@gazelle.com"
- git config --global user.name "Gazelle CircleCI Bot"
deployment:
all:
branch: /^(?!(master|dev)).*$/
commands:
- bundle exec rake release:build
- bundle exec rake release:push:branch
master:
branch: master
commands:
- bundle exec rake release:build
- bundle exec rake release:push:timestamp
- bundle exec rake release:push:release
dev:
branch: dev
commands:
- bundle exec rake release:build
- bundle exec rake release:push:latest