motivation (2): Docker
● “Build and deploy Docker containers on
CircleCI” https://circleci.
com/integrations/docker
● “Continuous Integration and Delivery with
Docker” https://circleci.com/docs/docker
● Circle CIのビルドコンテナ内でのdockerの実行
をサポート
pricing
“Continuous Integration and Deployment on CircleCI just
got better: now it’s free.” http://blog.circleci.com/continuous-
integration-and-deployment-on-circleci-just-got-better-now-
its-free/
● 1コンテナは無料
● 追加1コンテナあたり $50/Month
● OSSプロジェクトでは追加で3コンテナ無料で利用可能(計4
コンテナ無料)
Demo: Getting Started with Circle CI
https://circleci.com/docs/getting-started
1. Circle CIにサインアップ
2. Circle CI に Github へのアクセス許可
3. プロジェクトをクリック
demo: minimum2scp/tdiary-style-gfm
を Circle CI でテストしてみます。
Serverspec
describe package('git') do
it { should be_installed }
end
describe file('/etc/timezone') do
its(:content){ should include 'Asia/Tokyo' }
end
describe user('debian') do
it { should belong_to_group 'sudo' }
end
describe service('sshd') do
it { should be_enabled }
end
docker rm: error message
$ docker rm c1
Error response from daemon: Cannot destroy container c1:
Driver btrfs failed to remove root filesystem 431a239…
(snip)…: Failed to destroy btrfs snapshot: operation not
permitted
FATA[0000] Error: failed to remove one or more containers
docker rm c1 returned exit code 1
answer from support
this is a known limitation of our container permissions model. We have a "root"
user in the container which has a subset of the capabilities of the real root user,
this enables it to perform many of the same actions that you would ordinarily
need the real root user to perform.
Unfortunately, removing a btrfs snapshot to rm a docker image requires greater
capabilities than we can securely grant to the "root" user in the container
Fortunately you don't need to worry about any docker filesystems you've
created during the build. We completely destroy the container's filesystem
when the build is finished, removing any docker filesystems too
monkey patch
## workaround for Circle CI
if ENV['CIRCLECI']
class Docker::Container
def remove(options={}); end
alias_method :delete, :remove
end
end
spec/spec_helper.rb
CircleCIではコンテナを削
除しない
more problems
✔ docker rm でエラー→コンテナを削除しない
❌ 遅い
● OS 種別の判定に数秒
● 70exampleの実行に約30秒
❌ まれによく偶発的にfailしていた
● CircleCIでは頻繁にランダムに発生
● ローカルPCではまれ(docker pullとテスト併走で再現)
use ssh backend
require 'serverspec'
require 'docker'
container = ::Docker::Container.create({'Image' => ENV['DOCKER_IMAGE']})
container.start
set :backend, :ssh
set :host, container.json['NetworkSettings']['IPAddress']
set :ssh_options, {:user => 'debian', :password => 'debian'}
set :os, :family => 'debian', :arch => 'x86_64', :release => '8.0'
sleep 3
docker-api gemを利用し
てコンテナを起動
コンテナのIPアド
レス等設定
OSの自動判定をスキップコンテナ内のsshd起動を待つ
spec/spec_helper.rb
SSHバックエンドを使用
docker exec: error message
$ docker exec c1 uname -a
FATA[0000] Error response from daemon:
Unsupported: Exec is not supported by the
lxc driver docker exec c1 uname -a returned
exit code 1
answer from support
I'm afraid that we don't support docker exec in CircleCI at
the moment. We are planning on a fix in the next month or
so.Would that work for you? Is it possible if you use another
workaround for the moment?
来月(2015年4月)あたりdocker exec使えるようになるらしいで
す!
news
We are planning to release an upgraded Linux container image on 2015-03-12
which includes a number of updates many people have been asking for,
notably:
● Postgres is updated to 9.4
● iojs is pre-installed on the container image
● Firefox is updated to 36
If you use Firefox for browser testing you should upgrade to Selenium 2.45 at
your earliest convenience. We'll be upgrading Chrome shortly, in the next
container image we release which is currently slated for the following week.