Skip to content

Commit

Permalink
tools/ci: sanitize Docker tags
Browse files Browse the repository at this point in the history
Sanitize Docker tags to remove characters used in semver that are not
valid in Docker tags (primarily `+`)
  • Loading branch information
rfratto committed Mar 19, 2024
1 parent 8098d4d commit 03aa3b7
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions tools/ci/docker-containers
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ else
VERSION=$(./tools/image-tag)
fi

# The TAG_VERSION is the version to use for the Docker tag. It is sanitized to
# force it to be a valid tag name; ./tools/image-tag can emit characters that
# are valid for semver but invalid for Docker tags, such as +.
TAG_VERSION=${VERSION//+/-}

# We also need to know which "branch tag" to update. Branch tags are used as a
# secondary tag for Docker containers. The branch tag is "latest" when being
# tagged from a stable release (i.e., not a release candidate).
Expand All @@ -54,7 +59,7 @@ fi
if [ -n "$DRONE_TAG" ] && [[ "$DRONE_TAG" != *"-rc."* ]]; then
BRANCH_TAG=latest
else
BRANCH_TAG=$VERSION
BRANCH_TAG=$TAG_VERSION
fi

# Build all of our images.
Expand All @@ -68,21 +73,21 @@ case "$TARGET_CONTAINER" in
--platform $BUILD_PLATFORMS \
--build-arg RELEASE_BUILD=1 \
--build-arg VERSION="$VERSION" \
-t "$AGENT_IMAGE:$VERSION" \
-t "$AGENT_IMAGE:$TAG_VERSION" \
-t "$AGENT_IMAGE:$BRANCH_TAG" \
-f cmd/grafana-agent/Dockerfile \
.
;;

agent-boringcrypto)
docker buildx build --push \
--platform $BUILD_PLATFORMS_BORINGCRYPTO \
--build-arg RELEASE_BUILD=1 \
--build-arg VERSION="$VERSION" \
--build-arg GOEXPERIMENT=boringcrypto \
-t "$AGENT_BORINGCRYPTO_IMAGE:$VERSION" \
-t "$AGENT_BORINGCRYPTO_IMAGE:$BRANCH_TAG" \
-f cmd/grafana-agent/Dockerfile \
docker buildx build --push \
--platform $BUILD_PLATFORMS_BORINGCRYPTO \
--build-arg RELEASE_BUILD=1 \
--build-arg VERSION="$VERSION" \
--build-arg GOEXPERIMENT=boringcrypto \
-t "$AGENT_BORINGCRYPTO_IMAGE:$TAG_VERSION" \
-t "$AGENT_BORINGCRYPTO_IMAGE:$BRANCH_TAG" \
-f cmd/grafana-agent/Dockerfile \
.
;;

Expand Down

0 comments on commit 03aa3b7

Please sign in to comment.