-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdocker-bake.hcl
126 lines (113 loc) · 2.41 KB
/
docker-bake.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# This is an HCL syntax equivalent to docker-compose.yml
# It looks good for the future, as it supports low level
# options which docker-compose does not, but it's currently very bleeding edge
variable "REPO_URL" {
default = "cogini/foo-app"
}
variable "IMAGE_TAG" {
default = ""
}
variable "REGISTRY" {
default = ""
}
variable "CACHE_DIR" {
default = "/root/.cache/docker"
}
group "default" {
targets = ["app", "test", "db"]
}
group "ci" {
targets = ["app", "test", "db"]
}
group "dev" {
targets = ["dev", "db"]
}
target "app" {
dockerfile = "deploy/alpine.Dockerfile"
target = "deploy"
context = "."
args = {
MIX_ENV = "prod"
# BUILDKIT_INLINE_CACHE: 1
REGISTRY = "${REGISTRY}"
}
cache-from = [
"type=local,src=${CACHE_DIR}/deploy"
]
cache-to = [
"type=local,dest=${CACHE_DIR}/deploy,mode=max"
]
tags = [
"${REPO_URL}:latest",
notequal("", IMAGE_TAG) ? "${REPO_URL}:${IMAGE_TAG}": "",
]
# platforms = [
# "linux/amd64",
# "linux/arm64",
# ]
output = ["type=docker"]
# output = ["type=registry"]
}
target "app-debian" {
inherits = ["app"]
dockerfile = "deploy/debian.Dockerfile"
}
target "dev" {
dockerfile = "deploy/debian.Dockerfile"
target = "dev"
context = "."
args = {
MIX_ENV = "dev"
REGISTRY = "${REGISTRY}"
}
}
target "test" {
dockerfile = "deploy/debian.Dockerfile"
target = "test"
context = "."
args = {
MIX_ENV = "test"
REGISTRY = "${REGISTRY}"
}
tags = [
"app-test"
]
cache-from = [
"type=local,src=${CACHE_DIR}/test"
]
cache-to = [
"type=local,dest=${CACHE_DIR}/test,mode=max"
]
output = ["type=docker"]
}
target "vuln" {
dockerfile = "deploy/alpine.Dockerfile"
context = "."
args = {
REGISTRY = "${REGISTRY}"
}
cache-from = [
"type=local,src=${CACHE_DIR}/vuln"
]
cache-to = [
"type=local,dest=${CACHE_DIR}/vuln,mode=max"
]
output = ["type=docker"]
}
target "db" {
dockerfile = "deploy/postgres.Dockerfile"
context = "."
args = {
REGISTRY = "${REGISTRY}"
}
tags = [
"app-db"
]
cache-from = [
"type=local,src=${CACHE_DIR}/db"
]
cache-to = [
"type=local,dest=${CACHE_DIR}/db,mode=max"
]
output = ["type=docker"]
}