@@ -3,136 +3,3 @@ version: '3'
33silent : true
44
55tasks :
6- docker:image:test:ref :
7- desc : Print test image reference for CST
8- cmds :
9- - echo "{{.DOCKER_NAME}}:{{.VERSION_FULL}}{{.VERSION_SUFFIX}}"
10-
11- docker:login :
12- desc : Login to hub.docker.com and ghcr.io
13- cmds :
14- - |
15- set -eu
16- docker_username='{{.DOCKER_USERNAME}}'
17- github_username='{{.GITHUB_USERNAME}}'
18- has_dockerhub=false
19- has_ghcr=false
20-
21- if [ -n "$docker_username" ] && [ -n "${DOCKER_TOKEN:-}" ]; then
22- has_dockerhub=true
23- fi
24-
25- if [ -n "$github_username" ] && [ -n "${GITHUB_TOKEN:-}" ]; then
26- has_ghcr=true
27- fi
28-
29- if [ "$has_dockerhub" = false ] && [ "$has_ghcr" = false ]; then
30- echo "❌ No registry credentials provided. Set DOCKER_USERNAME/DOCKER_TOKEN or GITHUB_USERNAME/GITHUB_TOKEN."
31- exit 1
32- fi
33-
34- if [ "$has_dockerhub" = true ]; then
35- echo "Logging into Docker Hub as $docker_username"
36- printf '%s' "${DOCKER_TOKEN}" | docker login -u "$docker_username" --password-stdin
37- else
38- echo "⚠️ Skipping Docker Hub login (missing DOCKER_USERNAME/DOCKER_TOKEN)"
39- fi
40-
41- if [ "$has_ghcr" = true ]; then
42- echo "Logging into GHCR as $github_username"
43- printf '%s' "${GITHUB_TOKEN}" | docker login ghcr.io -u "$github_username" --password-stdin
44- else
45- echo "⚠️ Skipping GHCR login (missing GITHUB_USERNAME/GITHUB_TOKEN)"
46- fi
47-
48- docker:cmds :
49- desc : Show full docker build command
50- cmds :
51- - echo -e '{{.DOCKER_BUILD_START}} {{.DOCKER_BUILD_FINISH}}' | {{.SED}} 's/--/ \\\n --/g'
52-
53- docker:build :
54- desc : Build Docker image
55- cmds :
56- - docker buildx create --use
57- - ' {{.DOCKER_BUILD_START}} {{.DOCKER_BUILD_FINISH}}'
58-
59- docker:build:inspect :
60- desc : Inspect built Docker image
61- cmds :
62- - |
63- image_inspect_out=$(docker image inspect {{.DOCKER_NAME}}:{{.VERSION_FULL}}{{.VERSION_SUFFIX}} | jq -r)
64- echo -e "\nℹ️ Docker image inspect:"
65- echo "$image_inspect_out" | jq
66-
67- docker:push :
68- desc : Build and push Docker images
69- deps :
70- - task : docker:login
71- cmds :
72- - docker buildx create --use
73- - ' {{.DOCKER_BUILD_START}} --push {{.DOCKER_BUILD_FINISH}}'
74-
75- docker:push:inspect :
76- desc : Inspect built Docker image
77- cmds :
78- - |
79- set -eu
80- image="{{.DOCKER_NAME}}:{{.VERSION_FULL}}{{.VERSION_SUFFIX}}"
81-
82- echo -e "\nℹ️ Trying local image inspect: $image"
83- set +e
84- image_inspect_out=$(docker image inspect "$image" 2>/dev/null || true)
85- rc=$?
86- set -e
87-
88- # Validate that docker inspect returned a non-empty array with an Id
89- has_local=0
90- if [ "$rc" -eq 0 ] && [ -n "$image_inspect_out" ]; then
91- if echo "$image_inspect_out" | jq -e 'type=="array" and (length > 0) and \
92- (.[0].Id != null and .[0].Id != "")' >/dev/null 2>&1; then
93- has_local=1
94- fi
95- fi
96-
97- if [ "$has_local" -eq 1 ]; then
98- echo -e "\n✅ Local image found. Docker image inspect:"
99- echo "$image_inspect_out" | jq
100- image_sha=$(echo "$image_inspect_out" | jq -r '.[0].Id // empty')
101- if [ -n "$image_sha" ]; then
102- echo -e "\nℹ️ Docker manifest inspect (local):"
103- docker manifest inspect "${image}@${image_sha}" | jq || true
104- fi
105- exit 0
106- fi
107-
108- echo -e "\nℹ️ Local image not found or inspect returned empty; inspecting remote with buildx imagetools..."
109- set +e
110- raw=$(docker buildx imagetools inspect --raw "$image" 2>/dev/null || true)
111- set -e
112-
113- if [ -z "$raw" ]; then
114- echo "❌ Failed to inspect remote image with buildx imagetools: $image"
115- exit 1
116- fi
117-
118- echo -e "\n✅ Remote manifest/index (raw):"
119- echo "$raw" | jq
120-
121- echo -e "\nℹ️ Attempting to pull and inspect per-platform manifests:"
122- echo "$raw" | jq -r '.manifests[]?.digest' | while IFS= read -r digest; do
123- if [ -z "$digest" ] || [ "$digest" = "null" ]; then
124- continue
125- fi
126- ref="${image%@*}@${digest}"
127- echo -e "\nℹ️ Pulling $ref (may fail for some registries)..."
128- set +e
129- docker pull "$ref" >/dev/null 2>&1 || true
130- pulled_rc=$?
131- set -e
132- if [ "$pulled_rc" -eq 0 ]; then
133- echo "ℹ️ Inspecting pulled image $ref"
134- docker image inspect "$ref" | jq || true
135- else
136- echo "⚠️ Could not pull $ref; skipping image inspect"
137- fi
138- done
0 commit comments