Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
62d5290
wip
dmehala Sep 12, 2023
2dd2389
ci: wip
dmehala Sep 13, 2023
2d01345
ci: wip
dmehala Sep 13, 2023
5413562
ci: build for arm64
dmehala Sep 13, 2023
48cd1ac
ci: split workflow
dmehala Sep 13, 2023
a2e8bdc
ci: matrix
dmehala Sep 13, 2023
ada53ce
ci: matrix
dmehala Sep 13, 2023
61c3d2d
wip
dmehala Sep 18, 2023
2913349
wip
dmehala Sep 18, 2023
5fd792f
wip
dmehala Sep 18, 2023
0b8dfc4
wip
dmehala Sep 18, 2023
1785db4
wip
dmehala Sep 18, 2023
abb8cf6
wip
dmehala Sep 18, 2023
93f9b32
wip
dmehala Sep 18, 2023
509b32c
wip
dmehala Sep 18, 2023
d1bac25
enable docker_buildkit
dmehala Sep 18, 2023
00832ee
wip: debug
dmehala Sep 18, 2023
b78a2da
wip: fix shellcheck
dmehala Sep 18, 2023
9572308
wip: use buildkit
dmehala Sep 18, 2023
2d27374
wip: force arm64
dmehala Sep 18, 2023
a19f47c
wip: still testing:w
dmehala Sep 18, 2023
c54e435
wip: add DOCKER_DEFAULT_PLATFORM
dmehala Sep 18, 2023
03c42d3
wip: fix shell
dmehala Sep 18, 2023
0fa243d
wip: fix shell script
dmehala Sep 18, 2023
e838a00
wip: enable buildkit
dmehala Sep 18, 2023
9913d74
wip: test buildx instead
dmehala Sep 18, 2023
768d6a2
wip: testing on arm
dmehala Sep 18, 2023
9d12db8
wip: use cimg/base instead
dmehala Sep 18, 2023
279095c
wip: final
dmehala Sep 18, 2023
3a6b6a7
wip: quick fix
dmehala Sep 18, 2023
a9506d3
wip: fix script
dmehala Sep 18, 2023
ca3ba89
final
dmehala Sep 22, 2023
50c4ff9
ci: buildall test
dmehala Sep 22, 2023
853d1ca
resolve docker compose services ahead of time
dgoffredo Oct 18, 2023
4603145
support newer docker compose
dgoffredo Oct 18, 2023
1c84540
remove spurious whitespace in comment
dgoffredo Oct 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,756 changes: 3,391 additions & 1,365 deletions .circleci/config.yml

Large diffs are not rendered by default.

94 changes: 55 additions & 39 deletions bin/docker_build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/sh

#!/usr/bin/env sh
set -e

usage() {
Expand All @@ -8,38 +7,64 @@ docker_build.sh - Create a build image in Docker

usage:

docker_build.sh [--yes] [--push] [--rm] [<BASE_IMAGE>]
docker_build.sh --platform <PLATFORM> [--yes] [--push] [<BASE_IMAGE>]
`docker build` an image suitable for building a Datadog nginx
module compatible with the optionally specified BASE_IMAGE.
If BASE_IMAGE is not specified, use the contents of the
nginx-version-info file.

Prompt the user for confirmation unless --yes is specified.

--platform comma separated list of platform to build.
Example: --platform linux/amd64,linux/arm64

If --push is specified, push the resulting image to DockerHub
with a suitable tag.

If --rm is specified, then the image will be deleted locally after
it's been build and/or pushed.

docker_build.sh --help
docker_build.sh -h
Print this message.
END_USAGE
}

ask() {
if [ "$yes" -eq 1 ]; then
return
fi

while true; do
printf '%s [Yn]: ' "$1"
read -r response
case "$response" in
n|N|no|NO|No) return 1 ;;
y|Y|yes|YES|Yes|'') return ;;
*) >&2 printf "\nI don't understand.\n"
esac
done
}

repo=$(dirname "$0")/..
yes=0
push=0
delete=0
platform=''
base_image=''

while [ $# -ne 0 ]; do
case "$1" in
-h|--help) usage; exit ;;
-y|--yes) yes=1 ;;
-p|--push) push=1 ;;
-d|--rm) delete=1 ;;
-h|--help)
usage
exit
;;
-y|--yes)
yes=1
;;
-p|--push)
push=1
;;
--platform)
platform="$2"
shift
;;
*)
if [ -n "$base_image" ]; then
>&2 printf 'base image was specified twice: first as %s and now as %s.' "$base_image" "$1"
Expand All @@ -57,40 +82,31 @@ if [ -z "$base_image" ]; then
base_image="$BASE_IMAGE"
fi

ask() {
if [ "$yes" -eq 1 ]; then
return
fi

while true; do
printf '%s [Yn]: ' "$1"
read -r response
case "$response" in
n|N|no|NO|No) return 1 ;;
y|Y|yes|YES|Yes|'') return ;;
*) >&2 printf "\nI don't understand.\n"
esac
done
}
if [ -z "$platform" ]; then
>&2 printf 'ERROR: missing platform.\n'
usage
exit
fi

base_image_without_colons=$(echo "$base_image" | tr ':' '_')
built_tag="nginx-datadog-build-$base_image_without_colons"
if ! ask "Build image compatible with $base_image and tag as $built_tag?"; then

local_destination="$(pwd)/${built_tag}.tar"
remote_destination="datadog/docker-library:$built_tag"
buildx_output_args="--output=type=image,name=${remote_destination},push=true"

if ! ask "Build image compatible with ${base_image} for ${platform} and tag as ${built_tag}?"; then
exit 1
fi
docker build --build-arg "BASE_IMAGE=$base_image" --tag "$built_tag" "$repo"

if [ "$push" -eq 0 ]; then
exit
fi
destination="datadog/docker-library:$built_tag"
if ! ask "Push built image to \"$destination\"?"; then
exit
if ! ask "Push built image to \"${remote_destination}\"?"; then
buildx_output_args="--output=type=tar,dest=${local_destination}"
fi
fi

docker tag "$built_tag" "$destination"
docker push "$destination"

if [ "$delete" -eq 1 ]; then
docker images --no-trunc | awk "{ if (\$2 == \"$built_tag\") { print \$3 } }" | xargs docker rmi --force
fi
docker buildx build \
--platform "${platform}" \
--build-arg "BASE_IMAGE=${base_image}" \
"${buildx_output_args}" \
"${repo}"
352 changes: 225 additions & 127 deletions bin/generate_jobs_yaml.sh

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bin/rebuild_all_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ bin=$(dirname "$0")

base_images | while read -r base_image; do
echo "Building build image for base image $base_image"
"$bin"/docker_build.sh --yes --push --rm "$base_image"
"$bin"/docker_build.sh --platform linux/amd64,linux/arm64 --yes --push "$base_image"
done
Loading