Skip to content

Commit 676bf86

Browse files
committed
Refactor docker naming scheme
In order to follow more closely the existing tagging scheme this commit refactors the naming for images to include the build sha BEFORE the SNAPSHOT identifier. WHile this does not exactly follow the whole system that exists today for container images in DRA it follows a pattern that is more similar. Ideally we can iterate to fold handling of this container into DRA and in that case consumers would not need to update their patterns for identifying images.
1 parent 65028a1 commit 676bf86

File tree

3 files changed

+44
-31
lines changed

3 files changed

+44
-31
lines changed

.buildkite/scripts/common/qualified-version.sh

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ export QUALIFIED_VERSION="$(
1717
# e.g: 8.0.0-alpha1
1818
printf '%s' "${VERSION_QUALIFIER:+-${VERSION_QUALIFIER}}"
1919
20+
# Include git SHA if requested
21+
if [[ -n "${INCLUDE_SHA:+x}" ]]; then
22+
printf '%s' "-$(git rev-parse --short HEAD)"
23+
fi
24+
2025
# add the SNAPSHOT tag unless WORKFLOW_TYPE=="staging" or RELEASE=="1"
2126
if [[ ! ( "${WORKFLOW_TYPE:-}" == "staging" || "${RELEASE:+$RELEASE}" == "1" ) ]]; then
2227
printf '%s' "-SNAPSHOT"

.buildkite/scripts/dra/build-and-push-observability-sre.sh

+16-11
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,26 @@ echo "Building ObservabilitySRE container"
1515

1616
echo "Pushing ObservabilitySRE container to Docker repository"
1717
docker_login
18+
19+
# Get qualified version without SHA (this is what the gradle task will produce)
20+
export INCLUDE_SHA=""
1821
QUALIFIED_VERSION="$(.buildkite/scripts/common/qualified-version.sh)"
19-
SHA="$(git rev-parse --short HEAD)"
20-
REGISTRY_PATH=docker.elastic.co/logstash/logstash-observability-sre
2122

22-
# Add architecture to the tags
23-
ARCH_TAG="${ARCH:-x86_64}" # Default to x86_64 if ARCH is not set
23+
# Set environment variable to include SHA and get version with SHA
24+
export INCLUDE_SHA=1
25+
QUALIFIED_VERSION_WITH_SHA="$(.buildkite/scripts/common/qualified-version.sh)"
26+
27+
REGISTRY_PATH=docker.elastic.co/logstash/logstash-observability-sre
2428

25-
echo "Architecture: ${ARCH_TAG}"
29+
# Current architecture
30+
ARCH="${ARCH:-x86_64}" # Default to x86_64 if ARCH is not set
31+
echo "Architecture: ${ARCH}"
2632

27-
# Push a unique tag (version + SHA) for the current build WITH the architecture in the name
28-
# Ex: docker.elastic.co/logstash/logstash-observability-sre:8.19.0-SNAPSHOT-297226b1df-aarch64
29-
SHA_ARCH_TAG="${QUALIFIED_VERSION}-${SHA}-${ARCH_TAG}"
30-
echo "Tagging and pushing: ${REGISTRY_PATH}:${QUALIFIED_VERSION} as ${REGISTRY_PATH}:${SHA_ARCH_TAG}"
31-
docker tag ${REGISTRY_PATH}:${QUALIFIED_VERSION} ${REGISTRY_PATH}:${SHA_ARCH_TAG}
32-
docker push ${REGISTRY_PATH}:${SHA_ARCH_TAG}
33+
# Create the full tag with SHA and architecture
34+
FULL_TAG="${QUALIFIED_VERSION_WITH_SHA}-${ARCH}"
35+
echo "Tagging and pushing: ${REGISTRY_PATH}:${QUALIFIED_VERSION} as ${REGISTRY_PATH}:${FULL_TAG}"
36+
docker tag ${REGISTRY_PATH}:${QUALIFIED_VERSION} ${REGISTRY_PATH}:${FULL_TAG}
37+
docker push ${REGISTRY_PATH}:${FULL_TAG}
3338

3439
# Teardown Docker environment
3540
source .buildkite/scripts/dra/docker-env-teardown.sh
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,55 @@
11
#!/bin/bash
22
# Script to create and push Docker manifest for multi-architecture support
3-
# This MUST be fun after build-and-push-observabilty-sre.sh!
3+
# This MUST be run after build-and-push-observabilty-sre.sh!
44

55
source .buildkite/scripts/common/vm-agent.sh
66
source .buildkite/scripts/dra/docker-env-setup.sh
77

88
docker_login
9+
10+
# Set INCLUDE_SHA to include git SHA in version
11+
export INCLUDE_SHA=1
912
QUALIFIED_VERSION="$(.buildkite/scripts/common/qualified-version.sh)"
10-
SHA="$(git rev-parse --short HEAD)"
1113
REGISTRY_PATH=docker.elastic.co/logstash/logstash-observability-sre
1214

1315
# Architecture-specific tags (created by the build steps)
14-
X86_64_TAG="${QUALIFIED_VERSION}-${SHA}-x86_64"
15-
AARCH64_TAG="${QUALIFIED_VERSION}-${SHA}-aarch64"
16+
X86_64_TAG="${QUALIFIED_VERSION}-x86_64"
17+
AARCH64_TAG="${QUALIFIED_VERSION}-aarch64"
1618

17-
# Target manifest tags
18-
SHA_MANIFEST_TAG="${QUALIFIED_VERSION}-${SHA}"
19+
# Target manifest tags - already has SHA from QUALIFIED_VERSION
1920
VERSION_MANIFEST_TAG="${QUALIFIED_VERSION}"
2021

21-
# Create and push manifest with SHA
22-
echo "Creating manifest list for: ${REGISTRY_PATH}:${SHA_MANIFEST_TAG}"
23-
docker manifest create ${REGISTRY_PATH}:${SHA_MANIFEST_TAG} \
22+
# Create and push manifest with version (which already includes SHA)
23+
echo "Creating manifest list for: ${REGISTRY_PATH}:${VERSION_MANIFEST_TAG}"
24+
docker manifest create ${REGISTRY_PATH}:${VERSION_MANIFEST_TAG} \
2425
${REGISTRY_PATH}:${X86_64_TAG} \
2526
${REGISTRY_PATH}:${AARCH64_TAG}
2627

27-
docker manifest annotate ${REGISTRY_PATH}:${SHA_MANIFEST_TAG} \
28+
docker manifest annotate ${REGISTRY_PATH}:${VERSION_MANIFEST_TAG} \
2829
${REGISTRY_PATH}:${X86_64_TAG} --os linux --arch amd64
2930

30-
docker manifest annotate ${REGISTRY_PATH}:${SHA_MANIFEST_TAG} \
31+
docker manifest annotate ${REGISTRY_PATH}:${VERSION_MANIFEST_TAG} \
3132
${REGISTRY_PATH}:${AARCH64_TAG} --os linux --arch arm64
3233

33-
echo "Pushing manifest: ${REGISTRY_PATH}:${SHA_MANIFEST_TAG}"
34-
docker manifest push ${REGISTRY_PATH}:${SHA_MANIFEST_TAG}
34+
echo "Pushing manifest: ${REGISTRY_PATH}:${VERSION_MANIFEST_TAG}"
35+
docker manifest push ${REGISTRY_PATH}:${VERSION_MANIFEST_TAG}
3536

36-
# Create and push manifest without SHA (just version)
37-
echo "Creating manifest list for: ${REGISTRY_PATH}:${VERSION_MANIFEST_TAG}"
38-
docker manifest create ${REGISTRY_PATH}:${VERSION_MANIFEST_TAG} \
37+
# Also create version without SHA for effective "latest" tag
38+
export INCLUDE_SHA=""
39+
BASE_VERSION="$(.buildkite/scripts/common/qualified-version.sh)"
40+
echo "Creating manifest list for: ${REGISTRY_PATH}:${BASE_VERSION}"
41+
docker manifest create ${REGISTRY_PATH}:${BASE_VERSION} \
3942
${REGISTRY_PATH}:${X86_64_TAG} \
4043
${REGISTRY_PATH}:${AARCH64_TAG}
4144

42-
docker manifest annotate ${REGISTRY_PATH}:${VERSION_MANIFEST_TAG} \
45+
docker manifest annotate ${REGISTRY_PATH}:${BASE_VERSION} \
4346
${REGISTRY_PATH}:${X86_64_TAG} --os linux --arch amd64
4447

45-
docker manifest annotate ${REGISTRY_PATH}:${VERSION_MANIFEST_TAG} \
48+
docker manifest annotate ${REGISTRY_PATH}:${BASE_VERSION} \
4649
${REGISTRY_PATH}:${AARCH64_TAG} --os linux --arch arm64
4750

48-
echo "Pushing manifest: ${REGISTRY_PATH}:${VERSION_MANIFEST_TAG}"
49-
docker manifest push ${REGISTRY_PATH}:${VERSION_MANIFEST_TAG}
51+
echo "Pushing manifest: ${REGISTRY_PATH}:${BASE_VERSION}"
52+
docker manifest push ${REGISTRY_PATH}:${BASE_VERSION}
5053

5154
# Teardown Docker environment
5255
source .buildkite/scripts/dra/docker-env-teardown.sh

0 commit comments

Comments
 (0)