41
RAPID REPRODUCIBLE BUILDS treating everything like production Dewald Viljoen @dewald_v

Rapid, Reproducible Builds

Embed Size (px)

Citation preview

Page 1: Rapid, Reproducible Builds

R A P I D

REPRODUCIBLE BUILDStreating everything like production

Dewald Viljoen @dewald_v

Page 2: Rapid, Reproducible Builds

who am i?

2

Page 3: Rapid, Reproducible Builds

HOW'S THIS TALK GOING TO WORK

and what are we actually talking about?

3

Page 4: Rapid, Reproducible Builds

"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

Page 5: Rapid, Reproducible Builds

DOCKER IN 5 MINUTESa quick and dirty look into images, containers and all that lies below

5

Page 6: Rapid, Reproducible Builds

DOCKER IN 5 MINUTES - IMAGES

6

NGINX IMAGE

UBUNTU 14.04

ADD NGINX

ADD NGINX CONFIGLayer 3

Layer 2

Base (Layer 1)

Page 7: Rapid, Reproducible Builds

DOCKER IN 5 MINUTES - CONTAINERS

7

NGINX CONTAINER

UBUNTU 14.04

ADD NGINX

ADD NGINX CONFIGLayer 3

Layer 2

Base (Layer 1)

CONTAINER R/W FILESYSTEMLayer 4 (Only in the Container)

Page 8: Rapid, Reproducible Builds

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

Page 9: Rapid, Reproducible Builds

DOCKER IN 5 MINUTES - CONTAINER VS VM

9

Image credit: Docker Inc.

Page 10: Rapid, Reproducible Builds

what can we use containers for?

10

Page 11: Rapid, Reproducible Builds

WORKSTATIONS AND BUILD AGENTSthe darkest corners of the mind

11

Page 12: Rapid, Reproducible Builds

what's on a workstation?

12

Page 13: Rapid, Reproducible Builds

A TYPICAL WORKSTATION

13

WORKSTATION

Page 14: Rapid, Reproducible Builds

A TYPICAL WORKSTATION

14

WORKSTATION

Basically everything and anything you would

need to work on your stack

Page 15: Rapid, Reproducible Builds

what's on a build agent?

15

Page 16: Rapid, Reproducible Builds

A TYPICAL BUILD AGENT

16

(SUPER) BUILD AGENT

Page 17: Rapid, Reproducible Builds

A TYPICAL BUILD AGENT

17

(SUPER) BUILD AGENT

Basically everything and anything you would need to build your app

Page 18: Rapid, Reproducible Builds

what's the alternative?

18

Page 19: Rapid, Reproducible Builds

DOCKER-POWERED BUILDSapplying images and containers to build pipelines

19

Page 20: Rapid, Reproducible Builds

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

Page 21: Rapid, Reproducible Builds

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

Page 22: Rapid, Reproducible Builds

THE BUILD CONTAINER

22

MAVEN BUILD IMAGE

+

=

SOURCE CODE

BUILD ARTIFACT

Page 23: Rapid, Reproducible Builds

JAVA-APP-BUILD-1

CONTAINER R/W

JAVA-APP-BUILD-3

CONTAINER R/W

JAVA-APP-BUILD-2

CONTAINER R/W

THE BUILD CONTAINER - MULTIPLIED

23

MAVEN BUILD IMAGE

Page 24: Rapid, Reproducible Builds

ENVIRONMENTS, ENVIRONMENTS, ENVIRONMENTS...

24

LOCAL MACHINE BUILD AGENT

DOCKER REGISTRY

Page 25: Rapid, Reproducible Builds

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

Page 26: Rapid, Reproducible Builds

OF PIPELINES AND CONTAINERShow do we use this then?

26

Page 27: Rapid, Reproducible Builds

enterprises build all the things...

27

Page 28: Rapid, Reproducible Builds

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

Page 29: Rapid, Reproducible Builds

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

Page 30: Rapid, Reproducible Builds

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

Page 31: Rapid, Reproducible Builds

so what does a containerised build pipeline look like?

31

Page 32: Rapid, Reproducible Builds

PIPELINING CONTAINERS

32

Application build directly on agent

Failed due to environmental issues

Page 33: Rapid, Reproducible Builds

PIPELINING CONTAINERS

33

Build Container (Maven & JDK on Ubuntu)

Application build in container

Page 34: Rapid, Reproducible Builds

PIPELINING CONTAINERS

34

Build Container (Maven & JDK on Ubuntu)

Application Builds in containers

Page 35: Rapid, Reproducible Builds

THE GO SCRIPTnot configuring the build on the server

35

Page 36: Rapid, Reproducible Builds

what happens when the build server gets killed?

36

Page 37: Rapid, Reproducible Builds

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

Page 38: Rapid, Reproducible Builds

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

Page 39: Rapid, Reproducible Builds

PUTTING IT ALL TOGETHERdemo time

39

Page 40: Rapid, Reproducible Builds

live demo time... (cross your fingers)

40

Page 41: Rapid, Reproducible Builds

DEWALD VILJOEN @dewald_v

[email protected]

THANKS! QUESTIONS?