Skip to content

Commit 0ce324c

Browse files
committed
chore: cleanup old dockerfile not used
1 parent 531fb92 commit 0ce324c

File tree

3 files changed

+91
-100
lines changed

3 files changed

+91
-100
lines changed

.github/workflows/agent-ci.yaml

Lines changed: 91 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ jobs:
8181
export AGENT_VERSION=$(git tag --list 'agent*' --sort=-v:refname | head -n 1 | cut -d/ -f2)+${GIT_SHA}
8282
# Convert + to - for docker tag compliance
8383
export AGENT_IMAGE_TAG=$(echo "${AGENT_VERSION}" | tr + -)
84-
TAGS="-t ${REGISTRY@L}/${{ github.repository }}/agent:${GIT_SHA} -t ${REGISTRY@L}/${{ github.repository }}/agent:${AGENT_IMAGE_TAG}"
84+
TAGS="${GIT_SHA} ${AGENT_IMAGE_TAG}"
8585
;;
8686
tag)
8787
# The version part of the tag
8888
export AGENT_VERSION=$(echo "${{ github.ref_name }}" | cut -f 2 -d /)
8989
export AGENT_IMAGE_TAG="${AGENT_VERSION}"
90-
TAGS="-t ${REGISTRY@L}/${{ github.repository }}/agent:${GIT_SHA} -t ${REGISTRY@L}/${{ github.repository }}/agent:${AGENT_VERSION} -t ${REGISTRY@L}/${{ github.repository }}/agent:latest"
90+
TAGS="${GIT_SHA} ${AGENT_VERSION} latest"
9191
;;
9292
*)
9393
echo "Unknown type ${{ github.ref_type }}"
@@ -130,70 +130,132 @@ jobs:
130130
if: always()
131131
run: |
132132
cat test-summary.md >> $GITHUB_STEP_SUMMARY
133-
build-and-push-agent:
134-
runs-on: ubuntu-latest
133+
# Build container images on native architecture runners (much faster than QEMU)
134+
build-agent:
135+
runs-on: ${{ matrix.runner }}
135136
needs: [test, compute-metadata, fetch-distroless-versions] # Don't run the build and push if the unit tests fail
136-
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
137+
strategy:
138+
matrix:
139+
include:
140+
- platform: linux/amd64
141+
runner: ubuntu-latest
142+
- platform: linux/arm64
143+
runner: ubuntu-24.04-arm
137144
permissions:
138145
contents: read
139146
packages: write
140147
attestations: write
141148
id-token: write
142-
#
143149
steps:
144150
- name: Checkout repository
145151
uses: actions/checkout@v4
146152
- name: Fetch all tags
147153
run: git fetch --tags --force
148-
# Uses the `docker/login-action` action to log in to the Container registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
149154
- name: Log in to the Container registry
150155
uses: docker/login-action@v3
151156
with:
152157
registry: ${{ env.REGISTRY }}
153158
username: ${{ github.actor }}
154159
password: ${{ secrets.GITHUB_TOKEN }}
155-
156-
# Setup for multi-platform
157-
- name: Set up QEMU
158-
uses: docker/setup-qemu-action@v3
159160

160161
- name: Set up Docker Buildx
161162
uses: docker/setup-buildx-action@v3
162163

163-
- name: Build the agent container image
164+
# Build and tag container image for single platform on native hardware
165+
- name: Build the agent container image (${{ matrix.platform }})
164166
id: build
165167
env:
166168
GIT_SHA: ${{ needs.compute-metadata.outputs.git-sha }}
167169
AGENT_VERSION: ${{ needs.compute-metadata.outputs.agent-version }}
168-
TAGS: ${{ needs.compute-metadata.outputs.tags }}
169170
run: |
170-
apt-get update && apt-get install -y make git jq
171171
cd agent
172-
echo "📦 Building agent version: ${AGENT_VERSION}"
173-
echo "🏷️ Tags: ${TAGS}"
174-
export REGISTRY=${REGISTRY@L}
175-
export BUILD_ARGS="--push"
176-
make docker-build-only \
177-
agent_version=${AGENT_VERSION} \
178-
DISTROLESS_VERSION=${{ needs.fetch-distroless-versions.outputs.distroless-version }} \
179-
PYTHON_VERSION=${{ env.PYTHON_VERSION }} \
180-
DEBIAN_VERSION=${{ env.DEBIAN_VERSION }}
181-
cat metadata.json
172+
PLATFORM_TAG=$(echo "${{ matrix.platform }}" | tr '/' '-')
173+
174+
# Lowercase for Docker compliance
175+
IMAGE_NAME=$(echo "${{env.IMAGE_NAME}}" | tr '[:upper:]' '[:lower:]')
176+
REGISTRY=$(echo "${{env.REGISTRY}}" | tr '[:upper:]' '[:lower:]')
177+
178+
# Build platform-specific tags for all target tags
179+
TAGS=""
180+
for TAG in ${{ needs.compute-metadata.outputs.tags }}; do
181+
TAGS="$TAGS -t ${REGISTRY}/${IMAGE_NAME}/agent:${TAG}-${PLATFORM_TAG}"
182+
done
183+
184+
set -x
185+
docker buildx build \
186+
--build-arg GIT_SHA=${GIT_SHA} \
187+
--build-arg AGENT_VERSION=${AGENT_VERSION} \
188+
--build-arg PYTHON_VERSION=${{ env.PYTHON_VERSION }} \
189+
--build-arg DEBIAN_VERSION=${{ env.DEBIAN_VERSION }} \
190+
--build-arg DISTROLESS_VERSION=${{ needs.fetch-distroless-versions.outputs.distroless-version }} \
191+
--push \
192+
--platform ${{ matrix.platform }} \
193+
--provenance=false \
194+
${TAGS@L} \
195+
--metadata-file=metadata.json \
196+
-f ../containers/agent.Dockerfile .
197+
182198
echo "digest=$(cat metadata.json | jq -r .\"containerimage.digest\")" >> $GITHUB_OUTPUT
183-
cat $GITHUB_OUTPUT
199+
200+
# Create multi-platform manifest from individual architecture builds
201+
create-manifest:
202+
runs-on: ubuntu-latest
203+
needs: [compute-metadata, build-agent]
204+
permissions:
205+
contents: read
206+
packages: write
207+
attestations: write
208+
id-token: write
209+
steps:
210+
- name: Log in to the Container registry
211+
uses: docker/login-action@v3
212+
with:
213+
registry: ${{ env.REGISTRY }}
214+
username: ${{ github.actor }}
215+
password: ${{ secrets.GITHUB_TOKEN }}
216+
217+
# Create and push multi-platform manifests, then delete platform-specific tags
218+
- name: Create manifests and cleanup
219+
id: manifest
220+
run: |
221+
# Lowercase for Docker compliance
222+
IMAGE_NAME=$(echo "${{env.IMAGE_NAME}}" | tr '[:upper:]' '[:lower:]')
223+
REGISTRY=$(echo "${{env.REGISTRY}}" | tr '[:upper:]' '[:lower:]')
224+
225+
# Create manifest for each tag combining amd64 and arm64 images
226+
for TAG in ${{ needs.compute-metadata.outputs.tags }}; do
227+
FULL_TAG="${REGISTRY}/${IMAGE_NAME}/agent:${TAG}"
228+
echo "📦 Creating manifest for $FULL_TAG"
229+
docker manifest create $FULL_TAG \
230+
${FULL_TAG}-linux-amd64 \
231+
${FULL_TAG}-linux-arm64
232+
docker manifest push $FULL_TAG
233+
echo "✅ Pushed $FULL_TAG"
234+
done
235+
236+
# Get digest of the main tag (git sha) for attestation
237+
MAIN_TAG="${REGISTRY}/${IMAGE_NAME}/agent:${{ needs.compute-metadata.outputs.git-sha }}"
238+
DIGEST=$(docker manifest inspect $MAIN_TAG | jq -r '.manifests[0].digest')
239+
echo "digest=$DIGEST" >> $GITHUB_OUTPUT
240+
echo "subject-name=${REGISTRY}/${IMAGE_NAME}/agent" >> $GITHUB_OUTPUT
241+
242+
# Note: Platform-specific tags (e.g., v1.0.0-linux-amd64) are left in registry
243+
# as intermediate artifacts. Users should pull the multi-platform manifest tags.
244+
# GitHub Container Registry doesn't easily support programmatic tag deletion.
245+
echo "✅ Multi-platform manifests created successfully"
184246
185-
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
247+
# Generate supply chain security attestation for the multi-platform manifest
186248
- name: Generate artifact attestation
187249
uses: actions/attest-build-provenance@v2
188250
with:
189-
subject-name: ${{ env.REGISTRY }}/${{env.IMAGE_NAME}}/agent
190-
subject-digest: ${{ steps.build.outputs.digest }}
251+
subject-name: ${{ steps.manifest.outputs.subject-name }}
252+
subject-digest: ${{ steps.manifest.outputs.digest }}
191253
push-to-registry: true
192254

193255
operator-agent-tests:
194256
name: Operator Agent Integration Tests
195257
runs-on: ubuntu-latest
196-
needs: [compute-metadata, build-and-push-agent]
258+
needs: [compute-metadata, create-manifest]
197259
permissions:
198260
contents: read
199261
packages: read

.github/workflows/operator-ci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ jobs:
271271
GIT_SHA: ${{ needs.compute-metadata.outputs.git-sha }}
272272
VERSION: ${{ needs.compute-metadata.outputs.version }}
273273
run: |
274-
sudo apt-get update && sudo apt-get install -y jq
275274
cd operator
276275
PLATFORM_TAG=$(echo "${{ matrix.platform }}" | tr '/' '-')
277276

containers/ci.Dockerfile

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)