Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rapid Reproducible Builds

Rapid Reproducible Builds

I'd like to talk to everyone about someone we often neglect. That someone keeps our code flowing into production, runs all those automated tests, does things that we might not even remember to deploy to all our environments.

That someone is our build servers.

They tirelessly work to get our changes to our end users and we do neglect them. We don't treat our build servers like production servers, we hack them, we play with them, we mess up the environments. We may have several agents with different runtimes and gems and patch levels and who knows what.

We can do better.

In this talk I'd like to take you through something I've been working on over the last couple of months: Containerising your build. The tool I'll be using for this is Docker, but it's achievable with any VM or container technology. I'll take you through going from a working build on local to building local inside a container and then to moving that build to a build server, explaining what how and why as I go.

Dewald Viljoen

March 11, 2016
Tweet

More Decks by Dewald Viljoen

Other Decks in Programming

Transcript

  1. R A P I D REPRODUCIBLE BUILDS treating everything like

    production Dewald Viljoen @dewald_v
  2. "a server is a server is a server, there really

    are no test servers, build servers, dev servers and production servers... and spoons of course" - @dewald_v 4
  3. DOCKER IN 5 MINUTES a quick and dirty look into

    images, containers and all that lies below 5
  4. DOCKER IN 5 MINUTES - IMAGES 6 NGINX IMAGE UBUNTU

    14.04 ADD NGINX ADD NGINX CONFIG Layer 3 Layer 2 Base (Layer 1)
  5. DOCKER IN 5 MINUTES - CONTAINERS 7 NGINX CONTAINER UBUNTU

    14.04 ADD NGINX ADD NGINX CONFIG Layer 3 Layer 2 Base (Layer 1) CONTAINER R/W FILESYSTEM Layer 4 (Only in the Container)
  6. NGINX-1 CONTAINER R/W NGINX-2 CONTAINER R/W NGINX-3 CONTAINER R/W NGINX

    IMAGE DOCKER IN 5 MINUTES - CONTAINERS AND LAYERS 8
  7. A TYPICAL BUILD AGENT 17 (SUPER) BUILD AGENT Basically everything

    and anything you would need to build your app
  8. NODEJS BUILD IMAGE THE BUILD IMAGE - NODE + GRUNT

    20 UBUNTU 14.04 ADD NODE 4.2.4 ADD GRUNT ADD PACKAGE.JSON & NPM INSTALL Base Image Build Runtime Build Config & Dependencies Build Tool
  9. MAVEN BUILD IMAGE THE BUILD IMAGE - JAVA + MAVEN

    21 UBUNTU 14.04 ADD JDK 1.8 ADD MAVEN 3.3.3 ADD MAVEN SETTINGS.XML Base Image Build Runtime Build Config Build Tool
  10. THE BUILD CONTAINER - EVEN MORE MULTIPLIED 25 MAVEN 3

    MAVEN 2 NODEJS RUBY JAVA-APP- BUILD JAVA-APP- BUILD NODE-APP- BUILD RUBY-APP- BUILD BUILD AGENT ARTIFACT ARTIFACT ARTIFACT ARTIFACT
  11. THE SUPER BUILD AGENT 28 BUILD AGENT • Complex •

    Can be containerised but needs a lot of config • Holds all build tools and configuration for any type of build it can service • Results in high build-contention • Difficult to scale • Pushes artifacts to repositories MAVEN 3 MAVEN 2 JDK 1.5 JDK 1.6 JDK 1.7 RUBY PYTHON GRADLE
  12. THE MICRO BUILD AGENT 29 BUILD AGENT • Very simple

    • Can be easily containerised • Holds build tools and configuration for only the type of build it can service • Easier to scale • Can be managed with configuration as code • Pushes artifacts to repositories MAVEN 3 JDK 1.7
  13. THE CONTAINER BUILD AGENT 30 BUILD AGENT DOCKER • Very

    simple • Can be containerised it self (Docker in Docker) • Doesn't have any build dependencies inside, only docker • Pulls build containers from a registry • Simple to scale • Pushes artifacts to repositories • Basically a micro agent running only Docker
  14. BUILD CONFIGURATION 37 Backup your configuration Configuration as code Keep

    as little configuration on the server as possible Keep build configuration next to the app it builds
  15. THE GO SCRIPT 38 A Script for your build actions

    Knows the commands to build your app Keep it simple. Bash is a good start. Everything that works on the build server should work UNMODIFIED on the local environment. Build server should just call this script Use environment variables for environment changes
  16. THE GO SCRIPT 39 A Script for your build actions

    Knows the commands to build your app Keep it simple. Bash is a good start. Everything that works on the build server should work UNMODIFIED on the local environment. Build server should just call this script Use environment variables for environment changes