Skip to content

Commit

Permalink
Docker: add script to build all base images
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Dec 23, 2023
1 parent c4c4ade commit 6a68aa8
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docker/README.md
Expand Up @@ -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.<OS>` 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.<OS>` files. If the dependency only sometimes needs to be built from source,
see the usage of 'build_elfutils.sh' for guidance.
44 changes: 44 additions & 0 deletions 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 "]"

0 comments on commit 6a68aa8

Please sign in to comment.