@@ -56,19 +56,31 @@ jobs:
5656 fi
5757
5858 build :
59- name : Build and upload docker image
59+ name : Build and upload docker image (${{ matrix.device }})
6060 runs-on : ubuntu-latest
6161 needs : check_paths
6262 if : needs.check_paths.outputs.run_workflow == 'true'
63+ strategy :
64+ matrix :
65+ device : [cpu, xpu, gpu]
6366 permissions :
6467 contents : read
65- pull-requests : write
6668 steps :
6769 - name : Checkout repository
6870 uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
6971 with :
7072 persist-credentials : false
7173
74+ - name : Initial cleanup
75+ uses : open-edge-platform/geti-ci/actions/cleanup-runner@b7d997c1651b1e1b99a280033bd268b55ccb7923
76+ with :
77+ type : " initial"
78+
79+ - name : Pre-build cleanup
80+ uses : open-edge-platform/geti-ci/actions/cleanup-runner@b7d997c1651b1e1b99a280033bd268b55ccb7923
81+ with :
82+ type : " pre-build"
83+
7284 - name : Set up Docker Compose
7385 uses : docker/setup-compose-action@364cc21a5de5b1ee4a7f5f9d3fa374ce0ccde746 # v1.2.0
7486
@@ -83,28 +95,27 @@ jobs:
8395 type=semver,pattern={{version}}
8496 type=semver,pattern={{major}}.{{minor}}
8597
86- - name : Build images
98+ - name : Build image for ${{ matrix.device }}
8799 working-directory : application/docker
88100 run : |
89101 # Build and tag images using provided metadata
90102 for TAG in $TAGS ; do
91- TAG=${TAG} docker compose build
92-
93- docker save -o geti-tune-${TAG}.tar geti-tune:${TAG}
103+ AI_DEVICE=${DEVICE} TAG=${TAG} docker compose build
94104 done
95105 env :
96106 TAGS : ${{ steps.meta.outputs.tags }}
107+ DEVICE : ${{ matrix.device }}
97108 PUBLIC_API_BASE_URL : " /"
98109
99110 - name : Run simple checks on the built image
100111 working-directory : application/docker
101112 run : |
102113 # Get the first tag for testing
103114 FIRST_TAG=$(echo "$TAGS" | awk 'NR==1 {print $1}')
104- echo "Testing container with tag: $FIRST_TAG"
115+ echo "Testing container with tag: $FIRST_TAG for device: $DEVICE "
105116
106117 # Start the container in detached mode
107- CONTAINER_ID=$(docker run -d --rm -v .:/app/data -p 80:80 geti-tune:${FIRST_TAG})
118+ CONTAINER_ID=$(docker run -d --rm -v .:/app/data -p 80:80 geti-tune-${DEVICE} :${FIRST_TAG})
108119 echo "Started container: $CONTAINER_ID"
109120
110121 # Function to cleanup container on exit
@@ -147,39 +158,91 @@ jobs:
147158 echo "All checks passed successfully!"
148159 env :
149160 TAGS : ${{ steps.meta.outputs.tags }}
161+ DEVICE : ${{ matrix.device }}
150162
151163 - name : Get Docker image sizes
152164 working-directory : application/docker
153165 id : image-sizes
154166 if : github.event_name == 'pull_request'
155167 run : |
156- echo "## Docker Image Sizes" > image_sizes.md
157- echo "" >> image_sizes.md
158- echo "| Image | Size |" >> image_sizes.md
159- echo "|-------|------|" >> image_sizes.md
160-
161- for tar_file in geti-tune-*.tar; do
162- if [ -f "$tar_file" ]; then
163- size=$(ls -lh "$tar_file" | awk '{print $5}')
164- image_name=$(basename "$tar_file" .tar)
165- echo "| $image_name | $size |" >> image_sizes.md
168+ mkdir -p image-sizes
169+
170+ echo "| Image | Size |" > image-sizes/${DEVICE}.md
171+ echo "|-------|------|" >> image-sizes/${DEVICE}.md
172+
173+ for TAG in $TAGS ; do
174+ IMAGE="geti-tune-${DEVICE}:${TAG}"
175+ if docker image inspect "$IMAGE" >/dev/null 2>&1; then
176+ size_bytes=$(docker image inspect "$IMAGE" --format='{{.Size}}')
177+ size_readable=$(numfmt --to=iec --format "%.1f" "$size_bytes")
178+ echo "| $IMAGE | $size_readable |" >> image-sizes/${DEVICE}.md
166179 fi
167180 done
181+ env :
182+ TAGS : ${{ steps.meta.outputs.tags }}
183+ DEVICE : ${{ matrix.device }}
168184
169- echo "SIZES_CONTENT<<EOF" >> $GITHUB_OUTPUT
170- cat image_sizes.md >> $GITHUB_OUTPUT
171- echo "EOF" >> $GITHUB_OUTPUT
185+ - name : Upload image sizes
186+ if : github.event_name == 'pull_request'
187+ uses : actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
188+ with :
189+ name : image-sizes-${{ matrix.device }}
190+ path : application/docker/image-sizes/${{ matrix.device }}.md
191+ retention-days : 1
172192
173- - name : Comment PR with image sizes
174- uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
175- if : |
176- github.event_name == 'pull_request' &&
177- github.event.pull_request.head.repo.full_name == github.repository
193+ - name : Extract first tag
194+ id : first-tag
195+ run : |
196+ FIRST_TAG=$(echo "$TAGS" | awk 'NR==1 {print $1}')
197+ echo "tag=${FIRST_TAG}" >> $GITHUB_OUTPUT
198+ env :
199+ TAGS : ${{ steps.meta.outputs.tags }}
200+
201+ - name : Upload image as artifact
202+ # Image upload is heavy and slow, so we skip it on PRs
203+ if : github.event_name == 'push' || github.event_name == 'workflow_dispatch'
204+ uses : ishworkh/container-image-artifact-upload@5d71a2417f0576fa11fe770fb04ece58c4587714
205+ with :
206+ image : " geti-tune-${{ matrix.device }}:${{ steps.first-tag.outputs.tag }}"
207+ retention_days : " 3"
208+ continue-on-error : true
178209 env :
179- SIZES_CONTENT : ${{ steps.image-sizes.outputs.SIZES_CONTENT }}
210+ FIRST_TAG : ${{ steps.first-tag.outputs.tag }}
211+
212+ comment-sizes :
213+ name : Comment PR with all image sizes
214+ needs : build
215+ if : github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
216+ runs-on : ubuntu-latest
217+ permissions :
218+ pull-requests : write
219+ continue-on-error : true
220+ steps :
221+ - name : Download all image size artifacts
222+ uses : actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
223+ with :
224+ pattern : image-sizes-*
225+ merge-multiple : true
226+ path : image-sizes
227+
228+ - name : Combine image sizes and comment
229+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
180230 with :
181231 script : |
182- const comment = process.env.SIZES_CONTENT;
232+ const fs = require('fs');
233+ const path = require('path');
234+
235+ // Read all device size files
236+ const sizesDir = 'image-sizes';
237+ const files = fs.readdirSync(sizesDir).sort();
238+
239+ let comment = '## Docker Image Sizes\n\n';
240+
241+ for (const file of files) {
242+ const device = path.basename(file, '.md');
243+ const content = fs.readFileSync(path.join(sizesDir, file), 'utf8');
244+ comment += `### ${device.toUpperCase()}\n\n${content}\n\n`;
245+ }
183246
184247 // Find existing comment
185248 const comments = await github.rest.issues.listComments({
@@ -210,14 +273,6 @@ jobs:
210273 });
211274 }
212275
213- - name : Upload Docker images as artifacts
214- uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
215- with :
216- name : docker-images
217- path : |
218- application/docker/geti-tune-*.tar
219- retention-days : 7
220-
221276 required_check :
222277 name : Required Check build
223278 needs :
0 commit comments