Skip to content

Commit 372aa06

Browse files
committed
Add workflow to build chatbot-rag-app docker image
1 parent cf42c5d commit 372aa06

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: build chatbot-rag-app image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- example-apps/chatbot-rag-app/**
9+
- .github/workflows/docker-chatbot-rag-app.yml
10+
- '!**/*.md'
11+
pull_request:
12+
branches:
13+
- main
14+
paths:
15+
# Verify changes to the Dockerfile on PRs
16+
- example-apps/chatbot-rag-app/Dockerfile
17+
- .github/workflows/docker-chatbot-rag-app.yml
18+
- '!**/*.md'
19+
workflow_dispatch:
20+
21+
permissions:
22+
contents: read
23+
packages: write
24+
25+
env:
26+
IMAGE: ghcr.io/${{ github.repository }}/chatbot-rag-app
27+
28+
jobs:
29+
build-image:
30+
strategy:
31+
matrix:
32+
runner:
33+
- ubuntu-24.04
34+
- ubuntu-24.04-arm
35+
runs-on: ${{ matrix.runner }}
36+
steps:
37+
- uses: actions/checkout@v4
38+
- uses: docker/setup-buildx-action@v3
39+
- uses: docker/login-action@v3
40+
if: github.event_name == 'push'
41+
with:
42+
registry: ghcr.io
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
- uses: docker/build-push-action@v6
46+
id: build
47+
with:
48+
context: example-apps/chatbot-rag-app
49+
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.event_name == 'push' && 'true' || 'false' }}
50+
cache-from: type=gha
51+
cache-to: type=gha,mode=max
52+
- name: export digest
53+
run: |
54+
mkdir -p /tmp/digests
55+
digest="${{ steps.build.outputs.digest }}"
56+
touch "/tmp/digests/${digest#sha256:}"
57+
- name: upload digest
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: digests-${{ matrix.runner }}
61+
path: /tmp/digests/*
62+
if-no-files-found: error
63+
retention-days: 1
64+
65+
push-manifest:
66+
runs-on: ubuntu-24.04
67+
needs: build-image
68+
if: github.event_name == 'push'
69+
steps:
70+
- uses: actions/checkout@v4
71+
- uses: docker/setup-buildx-action@v3
72+
- uses: docker/login-action@v3
73+
with:
74+
registry: ghcr.io
75+
username: ${{ github.actor }}
76+
password: ${{ secrets.GITHUB_TOKEN }}
77+
- name: Docker meta
78+
id: meta
79+
uses: docker/metadata-action@v5
80+
with:
81+
images: ${{ env.IMAGE }}
82+
tags: |
83+
type=raw,latest
84+
type=sha,format=long
85+
- name: Download digests
86+
uses: actions/download-artifact@v4
87+
with:
88+
path: /tmp/digests
89+
pattern: digests-*
90+
merge-multiple: true
91+
- run: ls /tmp/digests
92+
- name: Create manifest list and push
93+
working-directory: /tmp/digests
94+
run: |
95+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
96+
$(printf '${{ env.IMAGE }}@sha256:%s ' *)
97+
- name: Inspect image to verify
98+
run: |
99+
docker buildx imagetools inspect ${{ env.IMAGE }}:${{ steps.meta.outputs.version }}

0 commit comments

Comments
 (0)