#!/usr/bin/env bash # # docker compose wrapper for the docker-dev rig that stamps the git commit into the images (#893). # # .dockerignore keeps .git/ out of the build context, so the in-image `dotnet publish` cannot read the # commit itself and AssemblyInformationalVersion would be a bare "1.0.0". This exports SOURCE_REVISION # (git rev-parse HEAD, suffixed "-dirty" for an uncommitted tree) for the compose `build.args`, which # the Dockerfile hands to the SDK as SourceRevisionId -> "1.0.0+". An explicit SOURCE_REVISION in # the environment wins; outside a git checkout it stays empty and the images stamp a bare "1.0.0". # # Usage (any docker compose arguments; the base compose file is always passed first): # docker-dev/compose.sh up -d --build # docker-dev/compose.sh -f docker-dev/docker-compose.questdb.yml up -d --build central-1 central-2 # docker-dev/compose.sh build central-1 # set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" SOURCE_REVISION="${SOURCE_REVISION:-}" if [ -z "$SOURCE_REVISION" ] && git -C "$REPO_ROOT" rev-parse --git-dir >/dev/null 2>&1; then SOURCE_REVISION="$(git -C "$REPO_ROOT" rev-parse HEAD)" if [ -n "$(git -C "$REPO_ROOT" status --porcelain --untracked-files=no)" ]; then SOURCE_REVISION="${SOURCE_REVISION}-dirty" fi fi export SOURCE_REVISION echo "Source revision: ${SOURCE_REVISION:-}" >&2 exec docker compose -f "$SCRIPT_DIR/docker-compose.yml" "$@"