Skip to content

Commit 7b4da18

Browse files
committed
chore: more few changes and wrap to 80 cols when possible
Signed-off-by: Jonathan Gonzalez V. <[email protected]>
1 parent c5db896 commit 7b4da18

File tree

1 file changed

+12
-13
lines changed
  • content/blog/building-images-bake

1 file changed

+12
-13
lines changed

content/blog/building-images-bake/index.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
title: "Creating a custom container image for CloudNativePG v2.0"
33
date: 2025-07-22
44
draft: false
5-
image:
6-
url:
7-
attribution:
85
author: jgonzalez
96
tags:
107
- blog
@@ -38,8 +35,6 @@ parallel.
3835
- A Bake file, using the one provided in the [CloudNativePG repository](https://github.com/cloudnative-pg/postgres-containers/blob/main/docker-bake.hcl) as a base.
3936
- A second, local Bake file to override the base configuration—this lets you apply your custom changes and build the container images accordingly.
4037

41-
Baking time: 5 minutes.
42-
4338
## Instructions
4439

4540
### Step 1: Prepare local Bake file
@@ -83,8 +78,10 @@ EOT
8378

8479
There are a few important points to highlight:
8580

86-
- The `extensions` variable is a list of extensions that we want to include in the image. In our recipe we are using `pgvector`, but you can add any others as needed.
87-
- The `dockerfile-inline` variable contains our Dockerfile definition, which cannot be used remotely. We will explain why later.
81+
- The `extensions` variable is a list of extensions that we want to include in the image. In our recipe we are using
82+
`pgvector`, but you can add any others as needed.
83+
- The `dockerfile-inline` variable contains our Dockerfile definition, which cannot be used remotely. We will explain
84+
why later.
8885
- The `target` and the `tgt` values share the same name, but you can use any name you prefer.
8986
- The `pgVersion` variable is a list specifying the PostgreSQL version(s) in MAJOR.MINOR format.
9087
- The `name` field is used to identify individual entries in the matrix we’ve defined.
@@ -110,7 +107,8 @@ functions and default targets, then attach a local Bake file to override any def
110107
In the command above, `-f cwd://bake.hcl` is the local file that we created in Step 1, and
111108
`-f docker-bake.hcl` is the remote file in the git repo, that we're using to build the image.
112109

113-
You can explore more about all the content generated and used inside the Bake file by appending the `--print` flag, as in the following command:
110+
You can explore more about all the content generated and used inside the Bake file by appending the `--print` flag, as
111+
in the following command:
114112

115113
```bash
116114
docker buildx bake -f docker-bake.hcl -f cwd://bake.hcl "https://github.com/cloudnative-pg/postgres-containers.git" myimage --print
@@ -145,7 +143,7 @@ The `docker-bake.hcl` file contains a lot of functions that are used to build th
145143
This function, given the list of extensions we provided, will return a string of the extensions with the correct package name
146144
for a Debian-based distribution, in our case, Debian Bookworm.
147145
For example, the `pgvector` extension will be translated into
148-
`postgresql-16-pgvector,` which is the name of the package for pgvector extensions for PostgreSQL 16 in the Debian
146+
`postgresql-16-pgvector`, which is the name of the package for pgvector extensions for PostgreSQL 16 in the Debian
149147
Bookworm distribution.
150148

151149
When we add elements to, for example, the `args` variable, those elements are processed by the Docker bake command, and will be
@@ -159,12 +157,13 @@ CloudNativePG images and add only the specific extensions we need—without rebu
159157

160158
## Making your images for specific architectures
161159

162-
By default, we build the images for `amd64` and `arm64` architectures, which is the recommended approach for most users.
163-
However, if you want to build images for your specific architecture and so, saving some space, you can override the
164-
`platforms` variable in your local Bake file.
160+
By default, images are built for both `amd64` and `arm64` architectures, which is the recommended setup for most users.
161+
However, if you want to target a specific architecture and reduce image size, you can override the `platforms` variable
162+
in your local Bake file.
165163

166164
```hcl
167165
platforms = ["linux/amd64"]
168166
```
169167

170-
If you’d like to build everything into your own repository while managing the same tags, that’s also possible. We may cover that in a future post.
168+
If you’d like to build everything into your own repository while managing the same tags, that’s also possible.
169+
We may cover that in a future post.

0 commit comments

Comments
 (0)