-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathdocker-bake.hcl
More file actions
186 lines (148 loc) · 5.04 KB
/
docker-bake.hcl
File metadata and controls
186 lines (148 loc) · 5.04 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// Vulcan v2.2.x Docker Bake Configuration
//
// Build with Docker Buildx Bake:
// docker buildx bake # Build default (production)
// docker buildx bake production-multiarch # Multi-arch build
// docker buildx bake --push # Build and push
// docker buildx bake all # Build all targets
//
// Or use the CLI:
// bin/vulcan build
// bin/vulcan build --platform linux/amd64,linux/arm64
// bin/vulcan build --push
//
// NOTE: RVM sets RUBY_VERSION with "ruby-" prefix (e.g., "ruby-3.3.9").
// We use VULCAN_RUBY_VERSION to avoid this conflict. If you see errors like
// "ruby:ruby-3.3.9-slim not found", either:
// - Set VULCAN_RUBY_VERSION=3.3.9, or
// - Run: unset RUBY_VERSION && docker buildx bake
variable "REGISTRY" {
default = "mitre"
}
variable "IMAGE_NAME" {
default = "vulcan"
}
variable "VERSION" {
default = "latest"
}
variable "BUNDLER_VERSION" {
default = "2.3.27"
}
// Use VULCAN_RUBY_VERSION to avoid conflict with RVM's RUBY_VERSION
variable "VULCAN_RUBY_VERSION" {
default = "3.4.8"
}
variable "VULCAN_NODE_VERSION" {
default = "22.16.0"
}
// ============================================================================
// Groups - Build multiple targets at once
// ============================================================================
group "default" {
targets = ["production"]
}
group "all" {
targets = ["production", "dev"]
}
// ============================================================================
// Production Target - Optimized for size and security
// ============================================================================
target "production" {
dockerfile = "Dockerfile"
context = "."
target = "production"
tags = [
"${REGISTRY}/${IMAGE_NAME}:${VERSION}",
"${REGISTRY}/${IMAGE_NAME}:latest"
]
platforms = ["linux/amd64"]
args = {
RUBY_VERSION = "${VULCAN_RUBY_VERSION}"
NODE_VERSION = "${VULCAN_NODE_VERSION}"
BUNDLER_VERSION = "${BUNDLER_VERSION}"
}
labels = {
"org.opencontainers.image.title" = "Vulcan"
"org.opencontainers.image.description" = "STIG authoring and InSpec profile development"
"org.opencontainers.image.vendor" = "MITRE"
"org.opencontainers.image.source" = "https://github.com/mitre/vulcan"
"org.opencontainers.image.version" = "${VERSION}"
}
// Build cache configuration (only for CI/registry push)
// Uncomment for CI builds with registry access
// cache-from = ["type=registry,ref=${REGISTRY}/${IMAGE_NAME}:cache"]
// cache-to = ["type=registry,ref=${REGISTRY}/${IMAGE_NAME}:cache,mode=max"]
}
// ============================================================================
// Multi-Architecture Production Build
// ============================================================================
target "production-multiarch" {
inherits = ["production"]
platforms = [
"linux/amd64",
"linux/arm64"
]
tags = [
"${REGISTRY}/${IMAGE_NAME}:${VERSION}",
"${REGISTRY}/${IMAGE_NAME}:latest"
]
}
// ============================================================================
// Development Target - Full dev environment with all dependencies
// ============================================================================
target "dev" {
dockerfile = "Dockerfile"
context = "."
target = "development"
tags = [
"${REGISTRY}/${IMAGE_NAME}:dev"
]
platforms = ["linux/amd64"]
args = {
RUBY_VERSION = "${VULCAN_RUBY_VERSION}"
NODE_VERSION = "${VULCAN_NODE_VERSION}"
BUNDLER_VERSION = "${BUNDLER_VERSION}"
}
labels = {
"org.opencontainers.image.title" = "Vulcan Development"
"org.opencontainers.image.description" = "Vulcan development environment with all dependencies"
"org.opencontainers.image.vendor" = "MITRE"
"org.opencontainers.image.source" = "https://github.com/mitre/vulcan"
}
}
// ============================================================================
// CI Build - For GitHub Actions
// ============================================================================
target "ci" {
inherits = ["production"]
tags = [
"${REGISTRY}/${IMAGE_NAME}:ci-${VERSION}",
"${REGISTRY}/${IMAGE_NAME}:ci"
]
// GitHub Actions cache
cache-from = ["type=gha"]
cache-to = ["type=gha,mode=max"]
}
// ============================================================================
// CI Multi-Architecture Build
// ============================================================================
target "ci-multiarch" {
inherits = ["ci"]
platforms = [
"linux/amd64",
"linux/arm64"
]
}
// ============================================================================
// Release Build - For tagged releases
// ============================================================================
target "release" {
inherits = ["production-multiarch"]
// Override tags for release
tags = [
"${REGISTRY}/${IMAGE_NAME}:${VERSION}",
"${REGISTRY}/${IMAGE_NAME}:latest",
"ghcr.io/${REGISTRY}/${IMAGE_NAME}:${VERSION}",
"ghcr.io/${REGISTRY}/${IMAGE_NAME}:latest"
]
}