Skip to content

Commit 17c5d6e

Browse files
committed
move environmen&registry variables from the hcl file to the bake command
Signed-off-by: Daniel Chambre <[email protected]>
1 parent 40702d9 commit 17c5d6e

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

content/blog/customizing-hcl/bake.hcl

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
variable "environment" {
2-
default = "production"
3-
}
4-
5-
variable "registry" {
6-
default = "your.repo.url/cnpg"
7-
}
8-
9-
platforms = [
10-
"linux/amd64",
11-
]
1+
platforms = [
2+
"linux/amd64",
3+
]
124

135
extensions = [
146
"dbgsym",

content/blog/customizing-hcl/index.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,9 @@ To build a custom image we add the following content in a local file with name
5353
`bake.hcl`:
5454

5555
```hcl
56-
variable "environment" {
57-
default = "production"
58-
}
59-
60-
variable "registry" {
61-
default = "your.repo.url/cnpg"
62-
}
63-
64-
platforms = [
65-
"linux/amd64",
66-
]
56+
platforms = [
57+
"linux/amd64",
58+
]
6759
6860
extensions = [
6961
"dbgsym",
@@ -130,10 +122,6 @@ EOT
130122

131123
Starting at the beginning of the file:
132124

133-
- The `environment` variable is set to `production` for all of my images,
134-
because I use the same image to stage it through dev/test/prod.
135-
- The `registry` variable contains the repo upload url, so I don't have to add
136-
this information every time I build an image.
137125
- The `platforms` variable is `linux/amd64` for all of my images.
138126
- The `extensions` variable contains some extensions I use regularly.
139127
- The `dockerfile-inline` part is extended with binaries, some of them are handy
@@ -149,9 +137,15 @@ this information every time I build an image.
149137
We can now build the image using the following command:
150138

151139
```bash
152-
docker buildx bake -f docker-bake.hcl -f cwd://bake.hcl "https://github.com/cloudnative-pg/postgres-containers.git" myimage
140+
environment=production registry=your.repo.url docker buildx bake -f docker-bake.hcl -f cwd://bake.hcl "https://github.com/cloudnative-pg/postgres-containers.git" myimage
153141
```
154142

143+
- The `environment` variable is set to `production` for all of my images,
144+
because I use the same image to stage it through dev/test/prod.
145+
- The `registry` variable contains the repo upload url, so the images get
146+
uploaded there instead of the `localhost:5000` registry used in the
147+
[hcl file](https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg.github.io/refs/heads/main/content/blog/building-images-bake/bake.hcl).
148+
155149
### Step 3: Use it
156150

157151
The only missing step to use the images is to update your

0 commit comments

Comments
 (0)