From 6a68aa81597c282cbf6f6c268ee0685408e27694 Mon Sep 17 00:00:00 2001 From: Tim Haines Date: Fri, 22 Dec 2023 18:43:35 -0600 Subject: [PATCH] Docker: add script to build all base images --- docker/README.md | 24 ++++++++++++++++++++ docker/build_base_images.sh | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 docker/build_base_images.sh diff --git a/docker/README.md b/docker/README.md index bf20d9eeb2..12e267f505 100644 --- a/docker/README.md +++ b/docker/README.md @@ -58,3 +58,27 @@ them locally and build in the container! # This is bound to your host - edit files there $ cd /code ``` + +## Maintainers + +### Adding a new OS image + +1. Add the relevant information to 'build_base_images.sh'. For example, `make_image ubuntu 24.10`. + +2. Run `build_base_images.sh --push` to build and push _all_ container images. + +3. Running the script above will print a complete list of supported OSes. These need to be added to the + GitHub "os:" fields in the workflow files dev-containers.yaml and pr-tests.yaml. + Make a PR to add these updated files. + +4. After committing the PR above, the 'Build and Deploy Development Containers' workflow will update/generate + the associated development containers automatically on the next committed PR. It can be run manually via + the Github interface, if preferred. + +### Adding a dependency + +Assuming all of the requisite CMake files are in place, a new dependency can be added to the container images. If +the dependency can be installed by the package provider, add it to the `Dockerfile.` file, and run +`build_base_images.sh --push`. If it needs to be built from source, add a new build script (e.g., build_foo.sh) +and call it from the `Dockerfile.` files. If the dependency only sometimes needs to be built from source, +see the usage of 'build_elfutils.sh' for guidance. diff --git a/docker/build_base_images.sh b/docker/build_base_images.sh new file mode 100644 index 0000000000..4f5d1ad7fd --- /dev/null +++ b/docker/build_base_images.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +set -e + +jobs=1 # run builds with N jobs (same as 'make -jN') +push=no # push images after building + +while [[ "$#" -gt 0 ]]; do + case $1 in + -j|--jobs) jobs="$2"; shift 2; ;; + -p|--push) push=yes; shift; ;; + esac +done + +declare -a os_versions + +function make_image { + distro=$1 + version=$2 + extra=$3 + base="ghcr.io/dyninst/amd64/${distro}-${version}-base:latest" + docker pull ${distro}:${version} # Always use latest distro image; ignoring any cached versions + docker build -f docker/Dockerfile.${distro} -t $base --build-arg build_jobs=${jobs} --build-arg version=${version} ${extra} . + docker build -f docker/Dockerfile -t ghcr.io/dyninst/amd64/${distro}-${version}:latest --build-arg build_jobs=${jobs} --build-arg base=${base} . + + if test "${push}" = "yes"; then + docker push ${base} + fi + + os_versions+=("${distro}-${version}") +} + + +make_image ubuntu 20.04 "--build-arg build_elfutils=yes" +make_image ubuntu 22.04 +make_image ubuntu 23.04 + +make_image fedora 39 + +echo -n "[" +for v in "${os_versions[@]}"; do + echo -n "'$v', " +done +echo "]"