Skip to content

Commit bc91985

Browse files
authored
Merge pull request #971 from NBardelot/feature/local_buildx_builder
Improve local builds with another buildx builder
2 parents 3845a49 + 1f1372f commit bc91985

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

CONTRIBUTING.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,29 @@ We'd love to accept your patches, but before we can do that, you must sign the C
1212
## Contributing A Patch
1313

1414
1. Submit an issue describing your proposed change.
15-
1. If your proposal is accepted, and you haven't already done so, sign the Contributor License Agreement (see details above).
16-
1. Fork the repo, develop and test your code changes. Don't forget tests!
17-
1. Submit a pull request.
15+
2. If your proposal is accepted, and you haven't already done so, sign the Contributor License Agreement (see details above).
16+
3. Fork the repo, develop and test your code changes. Don't forget tests!
17+
4. Submit a pull request.
18+
19+
## Building container images with *buildx* locally on your computer
20+
21+
First, please read the following article:
22+
[Building Multi-Architecture Docker Images With Buildx](https://medium.com/@artur.klauser/building-multi-architecture-docker-images-with-buildx-27d80f7e2408).
23+
24+
By default the `Makefile` creates a *buildx* builder dedicated to `git-sync` with a container driver. But it won't work out-of-the-box
25+
if you use private container images registries and *pull* private dependencies, with authentication. You can adapt the *buildx* builder
26+
for a local build.
27+
28+
For example, if you've already got a `default` *buildx* builder with a docker driver (with access to the host engine) you can try
29+
to run a build with the following call to `make`:
30+
31+
```sh
32+
docker login $YOUR_PRIVATE_REGISTRY
33+
docker pull $BUILD_IMAGE_IN_PRIVATE_REGISTRY
34+
docker pull $BASEIMAGE_IN_PRIVATE_REGISTRY
35+
make all-container \
36+
BUILDX_BUILDER_SKIP_CREATION=skip \
37+
BUILDX_BUILDER_NAME=default \
38+
BUILD_IMAGE=$BUILD_IMAGE_IN_PRIVATE_REGISTRY \
39+
BASEIMAGE=$BASEIMAGE_IN_PRIVATE_REGISTRY
40+
```

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ DBG ?=
3535
HTTP_PROXY ?=
3636
HTTPS_PROXY ?=
3737

38+
# Allow some buildx adaptation for local builds
39+
BUILDX_BUILDER_NAME := git-sync
40+
BUILDX_BUILDER_SKIP_CREATION ?=
41+
3842
###
3943
### These variables should not need tweaking.
4044
###
@@ -177,7 +181,7 @@ container: .container-$(DOTFILE_IMAGE) container-name
177181
FORCE=0; \
178182
if [ -z "$(ALLOW_STALE_APT)" ]; then FORCE=$$(date +%s); fi; \
179183
docker buildx build \
180-
--builder git-sync \
184+
--builder "$(BUILDX_BUILDER_NAME)" \
181185
--build-arg FORCE_REBUILD="$$FORCE" \
182186
--build-arg HASH_LICENSES="$$HASH_LICENSES" \
183187
--build-arg HASH_BINARY="$$HASH_BINARY" \
@@ -262,7 +266,7 @@ test-tools: $(foreach tool, $(TEST_TOOLS), .container-test_tool.$(tool))
262266
# this. See https://medium.com/@artur.klauser/building-multi-architecture-docker-images-with-buildx-27d80f7e2408
263267
# for great context.
264268
.buildx-initialized:
265-
docker buildx create --name git-sync --node git-sync-0 >/dev/null
269+
if [ -z "$(BUILDX_BUILDER_SKIP_CREATION)" ]; then docker buildx create --name "$(BUILDX_BUILDER_NAME)" --node git-sync-0 >/dev/null; fi
266270
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes >/dev/null
267271
date > $@
268272

0 commit comments

Comments
 (0)