set shell := ["bash","-eu","-o","pipefail","-c"] set dotenv-load := true repo := `echo "${IMG_REPO:-${REG}/${NS}/${IMG}}"` # tag = git tag if exact; else branch-shortsha tag := `git describe --tags --exact-match 2>/dev/null || echo "$(git rev-parse --abbrev-ref HEAD)-$(git rev-parse --short HEAD)"` vcs_ref := `git rev-parse --short HEAD` build_date := `date -u +%Y-%m-%dT%H:%M:%SZ` default: build print-env: @echo REPO={{repo}} @echo TAG={{tag}} build: docker build -t "{{repo}}:{{tag}}" \ --build-arg VERSION="{{tag}}" \ --build-arg VCS_REF="{{vcs_ref}}" \ --build-arg BUILD_DATE="{{build_date}}" . build-latest: docker build -t "{{repo}}:latest" \ --build-arg VERSION="latest" \ --build-arg VCS_REF="{{vcs_ref}}" \ --build-arg BUILD_DATE="{{build_date}}" . run: docker run --rm "{{repo}}:{{tag}}" clean: docker images "{{repo}}" --format '{{"{{.Repository}}:{{.Tag}}"}}' | xargs -r -n1 docker rmi