-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoblin.hcl
96 lines (82 loc) · 2.46 KB
/
goblin.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
Config values for the build service are declared at the top level.
Values can be literal:
*/
value "DOCKER_HUB_NAME" {
literal = "dmcsorley"
}
/*
Values can also be set from environment variables.
*/
value "DOCKER_HUB_PASSWORD" {
env = "GOBLIN_DOCKER_HUB_PASSWORD"
}
/*
Builds occur in an isolated container, launched by the parent goblin process.
Build containers have a working docker volume mounted at /tmp/workdir by default.
This is an example of two-phase build:
- phase one, compile the executable
- phase two, build a docker image containing the executable
Built this way, the container you launch at
runtime doesn't contain your build dependencies.
*/
build "goblin" {
# clone the repository from `url` into the working directory
step git-clone {
url = "https://github.com/dmcsorley/goblin"
}
# pull the `image` specified
step docker-pull {
image = "golang"
}
# run the specified docker `image` in a container
step docker-run {
image = "golang"
/*
mount the working volume at this location in the run container
this will also be the working directory
*/
dir = "/go/src/github.com/dmcsorley/goblin"
# the command to execute in the container
cmd = "go get -v -d && go install -v && cp /go/bin/goblin ./bin/"
/*
this whole step is equivalent to:
`docker run -d \
-w /go/src/github.com/dmcsorley/goblin \
-v $VOLUME:/go/src/github.com/dmcsorley/goblin \
golang bash -c \
"go get -v -d && go install -v && cp /go/bin/goblin ./bin/"`
*/
}
# pulling before a run or build is optional, but recommended
# if you always want the newest version of the image
step docker-pull {
image = "buildpack-deps:xenial-scm"
}
# docker build in the working directory using the default Dockerfile
step docker-build {
image = "${DOCKER_HUB_NAME}/goblin"
}
# login to docker hub
step docker-login {
username = "${DOCKER_HUB_NAME}"
password = "${DOCKER_HUB_PASSWORD}"
}
# push the image we built to docker hub
step docker-push {
image = "${DOCKER_HUB_NAME}/goblin:latest"
}
# At the end of the build, everything is unwound; containers and volumes are removed
}
# A simpler build, with a single-step build from scratch
build captainhook {
step git-clone {
url = "https://github.com/dmcsorley/captainhook"
}
step docker-pull {
image = "golang:1.4.2-onbuild"
}
step docker-build {
image = "${DOCKER_HUB_NAME}/captainhook"
}
}