cca741f604bf978f08ac3271be5983a7b9955a8a — Karl Schultheisz a month ago c45a6e3
envsetup.sh: tag container images with Dockerfile hash

When working with multiple branches or worktrees in where the Dockerfile
differs, we want to use the container image that goes with the right
Dockerfile. A simple way to do this is to tag the container with the
Git object hash of the Dockerfile.

This is too sensitive: it responds to syntactic changes that don't affect
semantics. But it prevents us from using the wrong image.
2 files changed, 15 insertions(+), 7 deletions(-)

M envsetup.sh
M README.md => README.md +4 -4
@@ 4,14 4,14 @@ This repository shows how to containerize a build system for a C application.

## Usage

Build the container image:

	podman build -t build_environment .

Load aliases into the current shell environment that wrap build system commands:

	. ./envsetup.sh

Build the container image:


Use the usual Meson and Ninja commands as you like:

	meson setup build/

M envsetup.sh => envsetup.sh +11 -3
@@ 1,3 1,11 @@
PODMAN_WRAPPER='podman run --rm --volume=.:/home/root build_environment'
alias meson='$PODMAN_WRAPPER meson'
alias ninja='$PODMAN_WRAPPER ninja'
hash() {
	git hash-object Dockerfile

build_container_image() {
	podman build -t build-environment:$(hash) .

PODMAN_WRAPPER='podman run --pull=never --rm --volume=.:/home/root build-environment'
alias meson='$PODMAN_WRAPPER:$(hash) meson'
alias ninja='$PODMAN_WRAPPER:$(hash) ninja'