-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build): multi-arch build starting point
- Loading branch information
1 parent
5536895
commit bc6cb1d
Showing
4 changed files
with
72 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
set -eEuo pipefail | ||
|
||
AMD64_DOCKER_HOST=${AMD64_DOCKER_HOST:-"unix:///var/run/docker.sock"} | ||
ARM_DOCKER_HOST=${ARM_DOCKER_HOST:-"tcp://raspberrypi.local:2375"} | ||
|
||
if [ ! -x ${HOME}/.docker/cli-plugins/docker-buildx ]; then | ||
mkdir -p ${HOME}/.docker/cli-plugins/ | ||
wget https://github.com/docker/buildx/releases/download/v0.7.0/buildx-v0.7.0.linux-amd64 -O ${HOME}/.docker/cli-plugins/docker-buildx | ||
chmod +x ${HOME}/.docker/cli-plugins/docker-buildx | ||
fi | ||
|
||
docker buildx version | ||
|
||
BUILDER="multiarch-builder" | ||
CONFIG=${PWD}/multiarch/buildkitd.toml | ||
docker buildx create --name ${BUILDER} --buildkitd-flags '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host' --config=${CONFIG} --driver=docker-container --driver-opt image=moby/buildkit:latest,network=host --platform=linux/amd64 --use ${AMD64_DOCKER_HOST} | ||
docker buildx create --name ${BUILDER} --buildkitd-flags '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host' --config=${CONFIG} --driver=docker-container --driver-opt image=moby/buildkit:latest,network=host --platform=linux/arm64,linux/arm/v7,linux/arm/v6 --append ${ARM_DOCKER_HOST} | ||
stopbuilders() { | ||
set +x | ||
echo stopping builders | ||
docker buildx stop ${BUILDER} | ||
docker buildx rm ${BUILDER} | ||
} | ||
trap stopbuilders INT TERM EXIT | ||
|
||
docker buildx inspect --bootstrap --builder=${BUILDER} | ||
|
||
PLATFORM="${PLATFORM:-"linux/amd64,linux/arm/v7,linux/arm64"}" | ||
|
||
docker --log-level=debug \ | ||
buildx build ${PWD} \ | ||
--builder=${BUILDER} \ | ||
--allow security.insecure \ | ||
--platform=${PLATFORM} \ | ||
$@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Mutliarch builds | ||
|
||
## Requirements | ||
|
||
An ARM64 server with docker daemon exposed (for example, a raspberry pi 4 with Raspberry Pi OS 64bits) | ||
|
||
## Build | ||
|
||
At repository root, launch : | ||
|
||
``` | ||
./docker-build-multiarch.sh --tag=TAG --push | ||
``` | ||
|
||
It will build and push multi-arch docker images as TAG. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
################### | ||
## https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md | ||
|
||
debug = true | ||
|
||
# insecure-entitlements allows insecure entitlements, disabled by default. | ||
insecure-entitlements = [ "network.host", "security.insecure" ] |