Using Docker in Build

4th OpenContainer Korea Casual Talk 

March 26, 2016

by @subicura 

  • Secure (private repo)
  • Easy to use
  • Many plugins
  • Support linux, osx, windows

PROS

  • Hard to setting build environment
    • ruby 1.9, 2.0, 2.1, ...
    • php5, php7?
  • No isolated build environment
  • Hard to config
  • No config versioning

CONS

JENKINS + DOCKER

Checklist

  • easy to make build environment
  • build in isolated environment
  • easy to config
  • support config versioning

Using Docker in Build

GOLANG_VERSION=1.6
PACKAGE_NAME=github.com/subicura/wuzu

docker run --rm \
    -v $pwd:/go/src/$PACKAGE_NAME \
    -w /go/src/$PACKAGE_NAME \
    golang:${GOLANG_VERSION}-alpine \
    go build

Source File

Build & Test

Checklist

  • easy to setting build environment
  • build in isolated environment
  • easy to config
  • support config versioning

.travis.yml

language: ruby
rvm:
  - 2.1.3
env:
  - DB=mysql
script:
  - RAILS_ENV=test bundle exec rake --trace db:migrate test
before_script:
  - mysql -e 'create database myapp_test'

simple YAML file to describe build & test

wuzu

very simple command-line tool that builds in an isolated (docker) environment.

  • written in GO
  • use YAML file
    • .wuzu.yml
  • build with docker
  • test with docker 
# golang build

build:
  from: 'golang:1.6'
  src: $PWD
  dest: /go/src/github.com/subicura/wuzu
  run: go build -v

.wuzu.yml

$ wuzu build

docker run --rm \
  -v SRC:DEST \
  -w DEST \
  FROM \
  CMD
docker run --rm \
  -v $PWD:/go/src/github.com/subicura/wuzu \
  -w /go/src/github.com/subicura/wuzu \
  golang:1.6 \
  go build -v

Checklist

  • easy to setting build environment
  • build in isolated environment
  • easy to config
  • support config versioning

Conclusion

  • docker is good
  • Let me know if you know any other command-line tool that build with docker
  • Or fork https://github.com/subicura/wuzu
    • before/after script
    • test script
    • docker image push
    • language detection
    • ...
Made with Slides.com