-
Notifications
You must be signed in to change notification settings - Fork 1.9k
183 lines (165 loc) · 7.13 KB
/
Copy pathdocker-build-media-server.yml
File metadata and controls
183 lines (165 loc) · 7.13 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
name: "Docker Build Media Server"
on:
workflow_dispatch:
inputs:
tag:
description: "Tag for the Docker image"
required: false
default: "latest"
type: string
push:
branches:
- main
paths:
- "apps/media-server/**"
- ".github/workflows/docker-build-media-server.yml"
pull_request:
paths:
- "apps/media-server/**"
- ".github/workflows/docker-build-media-server.yml"
concurrency:
group: media-server-${{ github.head_ref || github.ref_name }}-${{ inputs.tag || 'latest' }}
cancel-in-progress: true
jobs:
build:
name: Build Docker Image (${{ matrix.platform }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 25
strategy:
matrix:
include:
- platform: amd64
runner: ubuntu-24.04
- platform: arm64
runner: ubuntu-24.04-arm
fail-fast: false
permissions:
contents: read
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Downcase GITHUB_REPOSITORY_OWNER
run: |
echo "REPOSITORY_OWNER=${GITHUB_REPOSITORY_OWNER@L}" >>"${GITHUB_ENV}"
- name: Build Platform Image
id: build
uses: docker/build-push-action@v5
with:
context: ./apps/media-server
file: ./apps/media-server/Dockerfile.standalone
platforms: linux/${{ matrix.platform }}
push: ${{ github.event_name != 'pull_request' }}
load: ${{ github.event_name == 'pull_request' }}
tags: ${{ github.event_name == 'pull_request' && 'cap-media-server:verification' || '' }}
outputs: ${{ github.event_name != 'pull_request' && format('type=image,name=ghcr.io/{0}/cap-media-server,push-by-digest=true', env.REPOSITORY_OWNER) || '' }}
cache-from: type=gha,scope=media-server-${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=media-server-${{ matrix.platform }}
- name: Verify recording decode in the production image
env:
MEDIA_IMAGE: ${{ github.event_name == 'pull_request' && 'cap-media-server:verification' || format('ghcr.io/{0}/cap-media-server@{1}', env.REPOSITORY_OWNER, steps.build.outputs.digest) }}
run: |
docker run --rm --network none --entrypoint bun "$MEDIA_IMAGE" test \
src/__tests__/lib/audio-quality-policy.test.ts \
src/__tests__/lib/audio-quality.integration.test.ts \
src/__tests__/lib/audio-quality-formats.integration.test.ts \
src/__tests__/lib/audio-quality-benchmark.test.ts
docker run --rm --network none --entrypoint bun "$MEDIA_IMAGE" test \
src/__tests__/lib/recording-verification.integration.test.ts \
src/__tests__/lib/job-manager.test.ts
docker run --rm --network none --entrypoint bun "$MEDIA_IMAGE" test \
src/__tests__/lib/media-size.test.ts \
src/__tests__/lib/media-probe.integration.test.ts
docker run --rm --network none --entrypoint bun "$MEDIA_IMAGE" test \
src/__tests__/lib/media-transfer.test.ts \
src/__tests__/lib/drive-resumable-upload.test.ts \
src/__tests__/lib/storage-upload.test.ts \
src/__tests__/lib/container-memory.test.ts
docker run --rm --network none --entrypoint bun "$MEDIA_IMAGE" test \
src/__tests__/routes/recording-verification.test.ts
docker run --rm --network none --entrypoint bun "$MEDIA_IMAGE" test \
src/__tests__/routes/video.test.ts
docker run --rm --network none --entrypoint bun "$MEDIA_IMAGE" test \
src/__tests__/lib/media-routes-real-world.integration.test.ts
docker run --rm --network none --entrypoint bun "$MEDIA_IMAGE" test \
src/__tests__/lib/media-video.integration.test.ts
- name: Verify long recording performance in the production image
env:
MEDIA_IMAGE: ${{ github.event_name == 'pull_request' && 'cap-media-server:verification' || format('ghcr.io/{0}/cap-media-server@{1}', env.REPOSITORY_OWNER, steps.build.outputs.digest) }}
run: |
docker run --rm --network none --cpus 2 --memory 2g \
-e MEDIA_SERVER_RECORDING_PERFORMANCE_TESTS=1 \
--entrypoint bun "$MEDIA_IMAGE" test \
src/__tests__/lib/recording-verification.integration.test.ts \
--test-name-pattern 'streams a complete long recording'
docker run --rm --network none --cpus 2 --memory 2g \
-e MEDIA_SERVER_TRANSFER_PERFORMANCE_TESTS=1 \
--entrypoint bun "$MEDIA_IMAGE" test \
src/__tests__/lib/media-transfer.integration.test.ts \
src/__tests__/lib/drive-resumable-upload.test.ts
- name: Export Digest
if: github.event_name != 'pull_request'
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload Digest
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: digests-media-server-${{ matrix.platform }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
name: Create Multi-Architecture Manifest
needs: build
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Download Digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-media-server-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Downcase GITHUB_REPOSITORY_OWNER
run: |
echo "REPOSITORY_OWNER=${GITHUB_REPOSITORY_OWNER@L}" >>"${GITHUB_ENV}"
- name: Create Image Manifest
env:
IMAGE_TAG: ${{ inputs.tag || 'latest' }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ "$IMAGE_TAG" == "latest" ]]; then
current="$(gh api "repos/${GITHUB_REPOSITORY}/git/ref/heads/main" --jq .object.sha)"
[[ "$current" == "$GITHUB_SHA" ]] || exit 1
fi
sources=()
for path in /tmp/digests/*; do
digest="${path##*/}"
[[ "$digest" =~ ^[0-9a-f]{64}$ ]] || exit 1
sources+=("ghcr.io/${REPOSITORY_OWNER}/cap-media-server@sha256:${digest}")
done
((${#sources[@]} > 0))
docker buildx imagetools create -t "ghcr.io/${REPOSITORY_OWNER}/cap-media-server:${IMAGE_TAG}" "${sources[@]}"