build-docker #59
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-docker | |
on: | |
push: | |
branches: | |
- master | |
release: | |
types: | |
- created | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "バージョン情報(A.BB.C / A.BB.C-preview.D)" | |
required: true | |
env: | |
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/sharevox_engine | |
PYTHON_VERSION: "3.8.10" | |
VOICEVOX_RESOURCE_VERSION: "0.2.0" | |
VOICEVOX_CORE_VERSION: "0.2.0" | |
VOICEVOX_ENGINE_VERSION: | |
|- # releaseタグ名か、workflow_dispatchでのバージョン名か、latestが入る | |
${{ github.event.release.tag_name || github.event.inputs.version || 'latest' }} | |
jobs: | |
build-docker: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
tag: | |
- "" | |
- cpu | |
- cpu-ubuntu20.04 | |
- nvidia | |
- nvidia-ubuntu20.04 | |
- cpu-ubuntu18.04 | |
- nvidia-ubuntu18.04 | |
include: | |
# Ubuntu 20.04 | |
- tag: "" | |
target: runtime-env | |
base_image: ubuntu:20.04 | |
base_runtime_image: ubuntu:20.04 | |
voicevox_core_asset_prefix: sharevox_core-linux-x64-cpu | |
onnxruntime_url: https://github.com/microsoft/onnxruntime/releases/download/v1.12.1/onnxruntime-linux-x64-1.12.1.tgz | |
- tag: cpu | |
target: runtime-env | |
base_image: ubuntu:20.04 | |
base_runtime_image: ubuntu:20.04 | |
voicevox_core_asset_prefix: sharevox_core-linux-x64-cpu | |
onnxruntime_url: https://github.com/microsoft/onnxruntime/releases/download/v1.12.1/onnxruntime-linux-x64-1.12.1.tgz | |
- tag: cpu-ubuntu20.04 | |
target: runtime-env | |
base_image: ubuntu:20.04 | |
base_runtime_image: ubuntu:20.04 | |
voicevox_core_asset_prefix: sharevox_core-linux-x64-cpu | |
onnxruntime_url: https://github.com/microsoft/onnxruntime/releases/download/v1.12.1/onnxruntime-linux-x64-1.12.1.tgz | |
- tag: nvidia | |
target: runtime-nvidia-env | |
base_image: ubuntu:20.04 | |
base_runtime_image: nvidia/cuda:11.6.2-cudnn8-runtime-ubuntu20.04 | |
voicevox_core_asset_prefix: sharevox_core-linux-x64-gpu | |
onnxruntime_url: https://github.com/microsoft/onnxruntime/releases/download/v1.12.1/onnxruntime-linux-x64-gpu-1.12.1.tgz | |
- tag: nvidia-ubuntu20.04 | |
target: runtime-nvidia-env | |
base_image: ubuntu:20.04 | |
base_runtime_image: nvidia/cuda:11.6.2-cudnn8-runtime-ubuntu20.04 | |
voicevox_core_asset_prefix: sharevox_core-linux-x64-gpu | |
onnxruntime_url: https://github.com/microsoft/onnxruntime/releases/download/v1.12.1/onnxruntime-linux-x64-gpu-1.12.1.tgz | |
# Ubuntu 18.04 | |
- tag: cpu-ubuntu18.04 | |
target: runtime-env | |
base_image: ubuntu:18.04 | |
base_runtime_image: ubuntu:18.04 | |
voicevox_core_asset_prefix: sharevox_core-linux-x64-cpu | |
onnxruntime_url: https://github.com/microsoft/onnxruntime/releases/download/v1.12.1/onnxruntime-linux-x64-1.12.1.tgz | |
- tag: nvidia-ubuntu18.04 | |
target: runtime-nvidia-env | |
base_image: ubuntu:18.04 | |
base_runtime_image: nvidia/cuda:11.6.2-cudnn8-runtime-ubuntu18.04 | |
voicevox_core_asset_prefix: sharevox_core-linux-x64-gpu | |
onnxruntime_url: https://github.com/microsoft/onnxruntime/releases/download/v1.12.1/onnxruntime-linux-x64-gpu-1.12.1.tgz | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# Download VOICEVOX RESOURCE | |
- name: Prepare VOICEVOX RESOURCE cache | |
uses: actions/cache@v3 | |
id: voicevox-resource-cache | |
with: | |
key: voicevox-resource-${{ env.VOICEVOX_RESOURCE_VERSION }} | |
path: download/resource | |
- name: Checkout VOICEVOX RESOURCE | |
if: steps.voicevox-resource-cache.outputs.cache-hit != 'true' | |
uses: actions/checkout@v3 | |
with: | |
repository: SHAREVOX/sharevox_resource | |
ref: ${{ env.VOICEVOX_RESOURCE_VERSION }} | |
path: download/resource | |
# Merge VOICEVOX RESOURCE | |
- name: Merge VOICEVOX RESOURCE | |
shell: bash | |
env: | |
DOWNLOAD_RESOURCE_PATH: download/resource | |
run: bash build_util/process_voicevox_resource.bash | |
- name: Build and Deploy Docker image | |
uses: docker/build-push-action@v3 | |
env: | |
IMAGE_TAG: | |
|- # If it's a release, add the version, otherwise add the `latest` | |
${{ ( | |
matrix.tag != '' && ( | |
format('{0}:{1}-{2}', env.IMAGE_NAME, matrix.tag, env.VOICEVOX_ENGINE_VERSION) | |
) || format('{0}:{1}', env.IMAGE_NAME, env.VOICEVOX_ENGINE_VERSION) | |
) }} | |
VOICEVOX_CORE_ASSET_NAME: ${{ matrix.voicevox_core_asset_prefix }}-${{ env.VOICEVOX_CORE_VERSION }} | |
with: | |
context: . | |
builder: ${{ steps.buildx.outputs.name }} | |
file: ./Dockerfile | |
build-args: | | |
BASE_IMAGE=${{ matrix.base_image }} | |
BASE_RUNTIME_IMAGE=${{ matrix.base_runtime_image }} | |
PYTHON_VERSION=${{ env.PYTHON_VERSION }} | |
VOICEVOX_ENGINE_VERSION=${{ env.VOICEVOX_ENGINE_VERSION }} | |
VOICEVOX_CORE_ASSET_NAME=${{ env.VOICEVOX_CORE_ASSET_NAME }} | |
VOICEVOX_CORE_VERSION=${{ env.VOICEVOX_CORE_VERSION }} | |
VOICEVOX_RESOURCE_VERSION=${{ env.VOICEVOX_RESOURCE_VERSION }} | |
ONNXRUNTIME_URL=${{ matrix.onnxruntime_url }} | |
target: ${{ matrix.target }} | |
push: true | |
tags: ${{ env.IMAGE_TAG }} | |
cache-from: type=registry,ref=${{ env.IMAGE_TAG }}-buildcache | |
cache-to: type=registry,ref=${{ env.IMAGE_TAG }}-buildcache,mode=max |