Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu 18.04ベースのDockerイメージ自動ビルドを追加 #98

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
31ed310
docker: add BASE_IMAGE arg
aoirint Sep 15, 2021
94273a5
build-docker: support BASE_IMAGE arg
aoirint Sep 15, 2021
e8938c7
build-docker: add ubuntu18.04 images
aoirint Sep 15, 2021
f1057ce
fix duplicated docker image tags
aoirint Sep 15, 2021
56de4eb
Merge remote-tracking branch 'origin/master' into patch-linux-docker-…
aoirint Sep 16, 2021
827f85d
Merge remote-tracking branch 'origin/master' into patch-linux-docker-…
aoirint Sep 21, 2021
023e9ca
Makefile: build-linux-docker-ubuntu18.04
aoirint Sep 21, 2021
e233917
linux: sort workflow job matrix
aoirint Sep 21, 2021
6b1568a
linux docker: upgrade to VOICEVOX CORE 0.6.0
aoirint Sep 21, 2021
98437a6
linux docker: overwrite gpu so with cpu so
aoirint Sep 21, 2021
f8e2ebe
linux docker: rewrite setup.py to use libcore_cpu for cpu image
aoirint Sep 21, 2021
036af8f
remove unused core shared object (prevent ldconfig error)
aoirint Sep 21, 2021
6c460d4
swap build arg order (core library name -> core example version)
aoirint Sep 21, 2021
f1f8703
revert swap
aoirint Sep 21, 2021
1ebc541
fix yaml string
aoirint Sep 21, 2021
ba1cedd
fix yaml string
aoirint Sep 21, 2021
5d619f9
fix matrix
aoirint Sep 21, 2021
f04e1ed
fix matrix
aoirint Sep 21, 2021
ae52cbf
reduce diff
aoirint Sep 21, 2021
ff1a29b
revert matrix build.yml
aoirint Sep 21, 2021
a05d19b
on push master
aoirint Sep 21, 2021
6042fae
split workaround layer
aoirint Sep 21, 2021
48db41a
Merge branch 'patch-linux-voicevox-core-0.6.0' into patch-linux-docke…
aoirint Sep 21, 2021
0267cc7
follow voicevox core 0.6.0
aoirint Sep 21, 2021
7d585c6
Makefile: follow #114
aoirint Sep 21, 2021
435b2fa
reset workaround: rename libcore_cpu to libcore
aoirint Sep 21, 2021
63af667
rm -f instead rm
aoirint Sep 21, 2021
bd85ce4
Merge branch 'patch-linux-voicevox-core-0.6.0' into patch-linux-docke…
aoirint Sep 21, 2021
d882adf
reorder entrypoint.sh dump to fast debug rebuild
aoirint Sep 21, 2021
946a2a9
logic to determine old glibc is used or not
aoirint Sep 21, 2021
3acb099
replace glibc version check logic with build arg flag
aoirint Sep 21, 2021
f5e4982
add use_glibc_229_workaround build-arg to workflow
aoirint Sep 21, 2021
8f596a3
workflow: commonize voicevox_core_version, voicevox_core_example_version
aoirint Sep 21, 2021
cb44be9
add os in matrix
aoirint Sep 21, 2021
2e05c79
add tag to matrix
aoirint Sep 21, 2021
b543c2f
commonize os
aoirint Sep 21, 2021
8171385
fix matrix for build.yml
aoirint Sep 21, 2021
cef5590
fix matrix for build.yml
aoirint Sep 21, 2021
a1798e0
Merge branch 'patch-linux-voicevox-core-0.6.0' into patch-linux-docke…
aoirint Sep 21, 2021
ae4d7e2
rm os in include
aoirint Sep 21, 2021
2c9da04
add tag in matrix
aoirint Sep 21, 2021
5849b2d
use cpu core for cpu-ubuntu18.04
aoirint Sep 21, 2021
21a24a9
rename GLIBC_229_WORKAROUND to GLIBC_231_WORKAROUND
aoirint Sep 21, 2021
7727734
fix indent
aoirint Sep 21, 2021
8abeca1
remove redundant versions
aoirint Sep 21, 2021
2139420
replace retry logic (unsupported feature for old gnu parallel)
aoirint Sep 21, 2021
484b37e
fix indent
aoirint Sep 21, 2021
24840b6
revert ldconfig location
aoirint Sep 21, 2021
466c0df
Merge remote-tracking branch 'origin/master' into patch-linux-docker-…
aoirint Sep 23, 2021
739d6e1
Merge branch 'master' into patch-linux-docker-base-image-ubuntu18.04
aoirint Sep 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ jobs:
- cpu-ubuntu20.04
- nvidia
- nvidia-ubuntu20.04
- cpu-ubuntu18.04
- nvidia-ubuntu18.04
voicevox_core_version: [0.6.0]
voicevox_core_example_version: [0.6.0]
include:
# Ubuntu 20.04
- tag: ''
target: runtime-env
base_image: ubuntu:focal
Expand Down Expand Up @@ -57,6 +60,21 @@ jobs:
base_runtime_image: nvidia/cuda:11.4.1-cudnn8-runtime-ubuntu20.04
voicevox_core_library_name: core
libtorch_url: https://download.pytorch.org/libtorch/cu111/libtorch-cxx11-abi-shared-with-deps-1.9.0%2Bcu111.zip
# Ubuntu 18.04
- tag: cpu-ubuntu18.04
target: runtime-env
base_image: ubuntu:bionic
base_runtime_image: ubuntu:bionic
voicevox_core_library_name: core_cpu
libtorch_url: https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.9.0%2Bcpu.zip
use_glibc_231_workaround: 1
- tag: nvidia-ubuntu18.04
target: runtime-nvidia-env
base_image: ubuntu:bionic
base_runtime_image: nvidia/cuda:11.4.1-cudnn8-runtime-ubuntu18.04
voicevox_core_library_name: core
libtorch_url: https://download.pytorch.org/libtorch/cu111/libtorch-cxx11-abi-shared-with-deps-1.9.0%2Bcu111.zip
use_glibc_231_workaround: 1

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -94,6 +112,7 @@ jobs:
VOICEVOX_CORE_EXAMPLE_VERSION=${{ matrix.voicevox_core_example_version }}
VOICEVOX_CORE_LIBRARY_NAME=${{ matrix.voicevox_core_library_name }}
LIBTORCH_URL=${{ matrix.libtorch_url }}
USE_GLIBC_231_WORKAROUND=${{ matrix.use_glibc_231_workaround || '0' }}
target: ${{ matrix.target }}
push: true
tags: |
Expand Down
48 changes: 33 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ WORKDIR /opt/voicevox_engine
# libsndfile1: soundfile shared object
# ca-certificates: pyopenjtalk dictionary download
# build-essential: pyopenjtalk local build
# parallel: retry download pyopenjtalk dictionary
RUN <<EOF
apt-get update
apt-get install -y \
Expand All @@ -154,7 +153,6 @@ RUN <<EOF
libsndfile1 \
ca-certificates \
build-essential \
parallel \
gosu
apt-get clean
rm -rf /var/lib/apt/lists/*
Expand Down Expand Up @@ -186,15 +184,7 @@ ADD ./requirements.txt /tmp/
ADD ./voicevox_engine /opt/voicevox_engine/voicevox_engine
ADD ./run.py ./check_tts.py ./VERSION.txt ./LICENSE ./LGPL_LICENSE /opt/voicevox_engine/

# Create container start shell
COPY <<EOF /entrypoint.sh
#!/bin/bash
cat /opt/voicevox_core/README.txt > /dev/stderr
exec "\$@"
EOF

RUN <<EOF
chmod +x /entrypoint.sh
# Create a general user
useradd --create-home user
# Update ld
Expand All @@ -211,14 +201,42 @@ RUN <<EOF
# Install voicevox_core
cd /opt/voicevox_core_example/example/python
gosu user pip3 install .
EOF

# FIXME: remove first execution delay
# try 5 times, delay 5 seconds before each execution.
# if all tries are failed, `docker build` will be failed.
# Keep layer cache above if dict download failed in local build
RUN <<EOF
set -eux

# Download openjtalk dictionary
parallel --retries 5 --delay 5 --ungroup \
gosu user python3 -c "import pyopenjtalk; pyopenjtalk._lazy_init()"
# try 5 times, sleep 5 seconds before retry
for i in $(seq 5); do
EXIT_CODE=0
gosu user /opt/python/bin/python3 -c "import pyopenjtalk; pyopenjtalk._lazy_init()" || EXIT_CODE=$?
if [ "$EXIT_CODE" = "0" ]; then
break
fi
sleep 5
done

if [ "$EXIT_CODE" != "0" ]; then
exit "$EXIT_CODE"
fi
EOF

# Create container start shell
ARG USE_GLIBC_231_WORKAROUND=0
COPY --chmod=775 <<EOF /entrypoint.sh
#!/bin/bash
cat /opt/voicevox_core/README.txt > /dev/stderr

# Workaround: ldconfig fail to load LibTorch if glibc < 2.31.
# For isolating problems and simplifing script, use flag USE_GLIBC_231_WORKAROUND
# instead of implementing version check logic.
if [ "${USE_GLIBC_231_WORKAROUND}" = "1" ]; then
export LD_LIBRARY_PATH="/opt/libtorch/lib:\${LD_LIBRARY_PATH:-}"
fi

exec "\$@"
EOF

ENTRYPOINT [ "/entrypoint.sh" ]
Expand Down
59 changes: 51 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
CMD=

.PHONY: build-linux-docker-ubuntu
build-linux-docker-ubuntu:
# Ubuntu 20.04
.PHONY: build-linux-docker-ubuntu20.04
build-linux-docker-ubuntu20.04:
docker buildx build . \
-t hiroshiba/voicevox_engine:cpu-ubuntu20.04-latest \
--target runtime-env \
Expand All @@ -11,14 +12,14 @@ build-linux-docker-ubuntu:
--build-arg LIBTORCH_URL=https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.9.0%2Bcpu.zip \
--build-arg VOICEVOX_CORE_LIBRARY_NAME=core_cpu

.PHONY: run-linux-docker-ubuntu
run-linux-docker-ubuntu:
.PHONY: run-linux-docker-ubuntu20.04
run-linux-docker-ubuntu20.04:
docker run --rm -it \
-p '127.0.0.1:50021:50021' \
hiroshiba/voicevox_engine:cpu-ubuntu20.04-latest $(CMD)

.PHONY: build-linux-docker-nvidia
build-linux-docker-nvidia:
.PHONY: build-linux-docker-nvidia-ubuntu20.04
build-linux-docker-nvidia-ubuntu20.04:
docker buildx build . \
-t hiroshiba/voicevox_engine:nvidia-ubuntu20.04-latest \
--target runtime-nvidia-env \
Expand All @@ -28,13 +29,54 @@ build-linux-docker-nvidia:
--build-arg LIBTORCH_URL=https://download.pytorch.org/libtorch/cu111/libtorch-cxx11-abi-shared-with-deps-1.9.0%2Bcu111.zip \
--build-arg VOICEVOX_CORE_LIBRARY_NAME=core

.PHONY: run-linux-docker-nvidia
run-linux-docker-nvidia:
.PHONY: run-linux-docker-nvidia-ubuntu20.04
run-linux-docker-nvidia-ubuntu20.04:
docker run --rm -it \
--gpus all \
-p '127.0.0.1:50021:50021' \
hiroshiba/voicevox_engine:nvidia-ubuntu20.04-latest $(CMD)


# Ubuntu 18.04
.PHONY: build-linux-docker-ubuntu18.04
build-linux-docker-ubuntu18.04:
docker buildx build . \
-t hiroshiba/voicevox_engine:cpu-ubuntu18.04-latest \
--target runtime-env \
--progress plain \
--build-arg BASE_IMAGE=ubuntu:bionic \
--build-arg BASE_RUNTIME_IMAGE=ubuntu:bionic \
--build-arg LIBTORCH_URL=https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.9.0%2Bcpu.zip \
--build-arg VOICEVOX_CORE_LIBRARY_NAME=core_cpu \
--build-arg USE_GLIBC_231_WORKAROUND=1

.PHONY: run-linux-docker-ubuntu18.04
run-linux-docker-ubuntu18.04:
docker run --rm -it \
-p '127.0.0.1:50021:50021' \
hiroshiba/voicevox_engine:cpu-ubuntu18.04-latest $(CMD)

.PHONY: build-linux-docker-nvidia-ubuntu18.04
build-linux-docker-nvidia-ubuntu18.04:
docker buildx build . \
-t hiroshiba/voicevox_engine:nvidia-ubuntu18.04-latest \
--target runtime-nvidia-env \
--progress plain \
--build-arg BASE_IMAGE=ubuntu:bionic \
--build-arg BASE_RUNTIME_IMAGE=nvidia/cuda:11.4.1-cudnn8-runtime-ubuntu18.04 \
--build-arg LIBTORCH_URL=https://download.pytorch.org/libtorch/cu111/libtorch-cxx11-abi-shared-with-deps-1.9.0%2Bcu111.zip \
--build-arg VOICEVOX_CORE_LIBRARY_NAME=core \
--build-arg USE_GLIBC_231_WORKAROUND=1

.PHONY: run-linux-docker-nvidia-ubuntu18.04
run-linux-docker-nvidia-ubuntu18.04:
docker run --rm -it \
--gpus all \
-p '127.0.0.1:50021:50021' \
hiroshiba/voicevox_engine:nvidia-ubuntu18.04-latest $(CMD)


# Python env for test
.PHONY: build-linux-docker-compile-python-env
build-linux-docker-compile-python-env:
docker buildx build . \
Expand All @@ -48,6 +90,7 @@ run-linux-docker-compile-python-env:
docker run --rm -it \
hiroshiba/voicevox_engine:compile-python-env $(CMD)


Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
# Build linux binary in Docker
.PHONY: build-linux-docker-build
build-linux-docker-build:
Expand Down