-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathadvanced-docker-compose-build.yml
More file actions
214 lines (188 loc) · 7.07 KB
/
Copy pathadvanced-docker-compose-build.yml
File metadata and controls
214 lines (188 loc) · 7.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
name: Build and Deploy Advanced (Docker Compose)
on:
workflow_dispatch:
inputs:
version:
description: Optional version tag override (e.g. v1.2.3)
required: false
push:
branches: [ "main" ]
paths:
- "*"
- "backends/advanced/**"
- "extras/asr-services/**"
- "extras/speaker-recognition/**"
- ".github/workflows/advanced-docker-compose-build.yml"
release:
types: [ published ]
permissions:
contents: write
packages: write
actions: read
env:
REGISTRY: ghcr.io
jobs:
build-images:
name: Build ${{ matrix.image }}
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- image: chronicle-backend
service: chronicle-backend
source-image: chronicle-backend:latest
directory: backends/advanced
variant: ""
- image: chronicle-asr-nemo-cu126
service: parakeet-asr
source-image: parakeet-asr:latest
directory: extras/asr-services
variant: cu126
- image: chronicle-asr-nemo-cu128
service: parakeet-asr
source-image: parakeet-asr:latest
directory: extras/asr-services
variant: cu128
- image: chronicle-speaker-cpu
service: speaker-service
source-image: chronicle-speaker:latest
directory: extras/speaker-recognition
variant: cpu
- image: chronicle-speaker-cu126
service: speaker-service
source-image: chronicle-speaker:latest
directory: extras/speaker-recognition
variant: cu126
- image: chronicle-speaker-cu128
service: speaker-service
source-image: chronicle-speaker:latest
directory: extras/speaker-recognition
variant: cu128
env:
ADVANCED_ENV: ${{ secrets.ADVANCED_ENV }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Print commit details
working-directory: ${{ matrix.directory }}
run: |
echo "Image: ${{ matrix.image }}"
echo "Event: ${{ github.event_name }}"
echo "Ref: $GITHUB_REF"
echo "Ref name: ${{ github.ref_name }}"
echo "Repository: $GITHUB_REPOSITORY"
echo "Actor: $GITHUB_ACTOR"
echo "SHA: $GITHUB_SHA"
echo "Short SHA: ${GITHUB_SHA::7}"
echo "Commit info:"
git log -1 --pretty=format:'Author: %an <%ae>%nDate: %ad%nSubject: %s' || true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Copy .env template
working-directory: ${{ matrix.directory }}
run: |
set -euo pipefail
if [ -f .env.template ]; then
cp .env.template .env
else
touch .env
fi
- name: Create .env from secret (if provided)
if: matrix.image == 'chronicle-backend' && env.ADVANCED_ENV != ''
working-directory: ${{ matrix.directory }}
run: |
echo "Writing .env from ADVANCED_ENV secret"
printf "%s\n" "${ADVANCED_ENV}" > .env
- name: Free Disk Space
working-directory: ${{ matrix.directory }}
run: |
echo "Freeing disk space..."
df -h
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /usr/share/swift
docker system prune -a -f
df -h
- name: Determine version
id: version
working-directory: ${{ matrix.directory }}
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
VERSION="${{ github.event.inputs.version }}"
elif [ "${{ github.event_name }}" = "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION="${GITHUB_REF#refs/tags/}"
else
VERSION="sha-${GITHUB_SHA::7}"
fi
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
- name: Build, tag, and push ${{ matrix.image }}
working-directory: ${{ matrix.directory }}
env:
OWNER: ${{ github.repository_owner }}
VERSION: ${{ steps.version.outputs.VERSION }}
CHRONICLE_BUILD_VERSION: ${{ steps.version.outputs.VERSION }}
PYTORCH_CUDA_VERSION: ${{ matrix.variant }}
run: |
set -euo pipefail
docker compose version
OWNER_LC=$(echo "$OWNER" | tr '[:upper:]' '[:lower:]')
docker compose build --pull "${{ matrix.service }}"
img_id=$(docker image inspect "${{ matrix.source-image }}" --format '{{.Id}}')
target_image="$REGISTRY/$OWNER_LC/${{ matrix.image }}:$VERSION"
latest_image="$REGISTRY/$OWNER_LC/${{ matrix.image }}:latest"
docker tag "$img_id" "$target_image"
docker tag "$img_id" "$latest_image"
docker push "$target_image"
docker push "$latest_image"
update-release:
name: Update release notes
needs: build-images
if: github.event_name == 'release' || inputs.version != ''
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
VERSION: ${{ github.event.release.tag_name || inputs.version }}
TAG_NAME: ${{ github.event.release.tag_name || inputs.version }}
steps:
- name: Update release notes with Docker images
run: |
set -euo pipefail
OWNER_LC=$(echo "$OWNER" | tr '[:upper:]' '[:lower:]')
DOCKER_SECTION=$(cat <<EOF
---
## Docker Images
All images are published to \`ghcr.io/${OWNER_LC}\` with tags \`${VERSION}\` and \`latest\`.
### Core Services
\`\`\`bash
docker pull ghcr.io/${OWNER_LC}/chronicle-backend:${VERSION}
\`\`\`
### Parakeet ASR (pick your CUDA version)
\`\`\`bash
docker pull ghcr.io/${OWNER_LC}/chronicle-asr-nemo-cu126:${VERSION}
docker pull ghcr.io/${OWNER_LC}/chronicle-asr-nemo-cu128:${VERSION}
\`\`\`
### Speaker Recognition (pick your variant)
\`\`\`bash
docker pull ghcr.io/${OWNER_LC}/chronicle-speaker-cpu:${VERSION}
docker pull ghcr.io/${OWNER_LC}/chronicle-speaker-cu126:${VERSION}
docker pull ghcr.io/${OWNER_LC}/chronicle-speaker-cu128:${VERSION}
\`\`\`
EOF
)
EXISTING_BODY=$(gh release view "$TAG_NAME" --json body -q '.body' --repo "$GITHUB_REPOSITORY")
EXISTING_BODY="${EXISTING_BODY%%$'\n---\n\n## Docker Images'*}"
UPDATED_BODY="${EXISTING_BODY}${DOCKER_SECTION}"
gh release edit "$TAG_NAME" --notes "$UPDATED_BODY" --repo "$GITHUB_REPOSITORY"
echo "Release notes updated with Docker image info"