@@ -35,59 +35,44 @@ jobs:
35
35
36
36
build-docker :
37
37
needs : [config]
38
- runs-on : ${{ matrix.os }}
38
+ runs-on : ubuntu-latest
39
39
40
40
strategy :
41
41
matrix :
42
- os : [ubuntu-latest]
43
- tag :
44
- - " "
45
- - cpu
46
- - cpu-ubuntu20.04
47
- - nvidia
48
- - nvidia-ubuntu20.04
49
- - cpu-ubuntu22.04
50
- - nvidia-ubuntu22.04
42
+ # 各変数の説明
43
+ # prefixes: Docker tagのプレフィックス。カンマ区切り。空文字列の場合、バージョン文字列のみがタグ名になる
44
+ # buildcache_prefix: ビルドキャッシュのプレフィックス。空文字列やカンマは使用不可
45
+ # target: Dockerfileのビルドステージ名
46
+ # base_image: Dockerfileのビルド用ステージのベースイメージ
47
+ # base_runtime_image: Dockerfileの実行用ステージのベースイメージ
48
+ # onnxruntime_version: ONNX Runtimeのバージョン
49
+ # platforms: Dockerのプラットフォームバリアント。カンマ区切り。 参考: https://docs.docker.com/build/building/multi-platform/
51
50
include :
52
51
# Ubuntu 20.04
53
- - tag : " "
52
+ - prefixes : " ,cpu,cpu-ubuntu20.04"
53
+ buildcache_prefix : " cpu-ubuntu20.04"
54
54
target : runtime-env
55
55
base_image : ubuntu:20.04
56
56
base_runtime_image : ubuntu:20.04
57
57
onnxruntime_version : 1.13.1
58
58
platforms : linux/amd64,linux/arm64/v8
59
- - tag : cpu
60
- target : runtime-env
61
- base_image : ubuntu:20.04
62
- base_runtime_image : ubuntu:20.04
63
- onnxruntime_version : 1.13.1
64
- platforms : linux/amd64,linux/arm64/v8
65
- - tag : cpu-ubuntu20.04
66
- target : runtime-env
67
- base_image : ubuntu:20.04
68
- base_runtime_image : ubuntu:20.04
69
- onnxruntime_version : 1.13.1
70
- platforms : linux/amd64,linux/arm64/v8
71
- - tag : nvidia
72
- target : runtime-nvidia-env
73
- base_image : ubuntu:20.04
74
- base_runtime_image : nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu20.04
75
- onnxruntime_version : 1.13.1
76
- platforms : linux/amd64
77
- - tag : nvidia-ubuntu20.04
59
+ - prefixes : " nvidia,nvidia-ubuntu20.04"
60
+ buildcache_prefix : " nvidia-ubuntu20.04"
78
61
target : runtime-nvidia-env
79
62
base_image : ubuntu:20.04
80
63
base_runtime_image : nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu20.04
81
64
onnxruntime_version : 1.13.1
82
65
platforms : linux/amd64
83
66
# Ubuntu 22.04
84
- - tag : cpu-ubuntu22.04
67
+ - prefixes : " cpu-ubuntu22.04"
68
+ buildcache_prefix : " cpu-ubuntu22.04"
85
69
target : runtime-env
86
70
base_image : ubuntu:22.04
87
71
base_runtime_image : ubuntu:22.04
88
72
onnxruntime_version : 1.13.1
89
73
platforms : linux/amd64,linux/arm64/v8
90
- - tag : nvidia-ubuntu22.04
74
+ - prefixes : " nvidia-ubuntu22.04"
75
+ buildcache_prefix : " nvidia-ubuntu22.04"
91
76
target : runtime-nvidia-env
92
77
base_image : ubuntu:22.04
93
78
base_runtime_image : nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04
@@ -137,32 +122,43 @@ jobs:
137
122
DOWNLOAD_RESOURCE_PATH : download/resource
138
123
run : bash tools/process_voicevox_resource.bash
139
124
125
+ - name : <Build> Generate Docker image names
126
+ id : generate-docker-image-names
127
+ run : |
128
+ # Dockerイメージ名を outputs.tags に改行区切りで格納する
129
+ {
130
+ echo "tags<<EOF"
131
+
132
+ python3 tools/generate_docker_image_names.py \
133
+ --repository "${{ env.IMAGE_NAME }}" \
134
+ --version "${{ needs.config.outputs.version_or_latest }}" \
135
+ --prefix "${{ matrix.prefixes }}"
136
+
137
+ echo "EOF"
138
+ } >> "$GITHUB_OUTPUT"
139
+
140
+ # ビルドキャッシュに指定するためのDockerイメージ名を生成する
141
+ # NOTE: デフォルトブランチへのコミットの場合のみキャッシュを作成する
142
+ - name : <Build> Generate Docker buildcache image names
143
+ id : generate-docker-buildcache-image-names
144
+ run : |
145
+ # --cache-from に指定するためのDockerイメージ名
146
+ # 常にデフォルトブランチのビルドキャッシュ(*-latest-buildcache)を使用する
147
+ cache_from="type=registry,ref=${{ env.IMAGE_NAME }}:${{ matrix.buildcache_prefix }}-latest-buildcache"
148
+
149
+ # --cache-to に指定するためのDockerイメージ名
150
+ # リリースの場合、ビルドキャッシュを作成しないため、空文字列を格納する
151
+ cache_to=""
152
+ if [ "${{ needs.config.outputs.version_or_latest }}" = "latest" ]; then
153
+ cache_to="type=registry,ref=${{ env.IMAGE_NAME }}:${{ matrix.buildcache_prefix }}-latest-buildcache,mode=max"
154
+ fi
155
+
156
+ # outputs に格納する
157
+ echo "cache-from=$cache_from" >> "$GITHUB_OUTPUT"
158
+ echo "cache-to=$cache_to" >> "$GITHUB_OUTPUT"
159
+
140
160
- name : <Build/Deploy> Build and Deploy Docker image
141
161
uses : docker/build-push-action@v5
142
- env :
143
- IMAGE_TAG :
144
- |- # If it's a release, add the version, otherwise add the `latest`
145
- ${{ (
146
- matrix.tag != '' && (
147
- format('{0}:{1}-{2}', env.IMAGE_NAME, matrix.tag, needs.config.outputs.version_or_latest)
148
- ) || format('{0}:{1}', env.IMAGE_NAME, needs.config.outputs.version_or_latest)
149
- ) }}
150
- IMAGE_CACHE_FROM :
151
- |- # Always use the `latest` buildcache. :latest-buildcache or :{tag}-latest-buildcache
152
- ${{ (
153
- matrix.tag != '' && (
154
- format('type=registry,ref={0}:{1}-latest-buildcache', env.IMAGE_NAME, matrix.tag)
155
- ) || format('type=registry,ref={0}:latest-buildcache', env.IMAGE_NAME)
156
- ) }}
157
- IMAGE_CACHE_TO :
158
- |- # If it's a release, do not create buildcache, otherwise create the `latest` buildcache. :latest-buildcache or :{tag}-latest-buildcache
159
- ${{ (
160
- needs.config.outputs.version_or_latest == 'latest' && (
161
- matrix.tag != '' && (
162
- format('type=registry,ref={0}:{1}-latest-buildcache,mode=max', env.IMAGE_NAME, matrix.tag)
163
- ) || format('type=registry,ref={0}:latest-buildcache,mode=max', env.IMAGE_NAME)
164
- ) || ''
165
- ) }}
166
162
with :
167
163
context : .
168
164
builder : ${{ steps.buildx.outputs.name }}
@@ -178,9 +174,9 @@ jobs:
178
174
ONNXRUNTIME_VERSION=${{ matrix.onnxruntime_version }}
179
175
target : ${{ matrix.target }}
180
176
push : true
181
- tags : ${{ env.IMAGE_TAG }}
182
- cache-from : ${{ env.IMAGE_CACHE_FROM }}
183
- cache-to : ${{ env.IMAGE_CACHE_TO }}
177
+ tags : ${{ steps.generate-docker-image-names.outputs.tags }}
178
+ cache-from : ${{ steps.generate-docker-buildcache-image-names.outputs.cache-from }}
179
+ cache-to : ${{ steps.generate-docker-buildcache-image-names.outputs.cache-to }}
184
180
platforms : ${{ matrix.platforms }}
185
181
186
182
run-release-test-workflow :
0 commit comments