From 5f5785c57fcce5d5fb776fc200095d026f767378 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 26 Apr 2022 23:03:41 -0400 Subject: [PATCH] Fixing docker builds --- .gitignore | 1 + Dockerfile | 7 ++- Dockerfile.binary | 110 --------------------------------- Dockerfile.debian | 3 +- Dockerfile.debian.dockerignore | 1 + Dockerfile.dist | 5 ++ Dockerfile.dist.dockerignore | 1 + Dockerfile.dockerignore | 1 + Dockerfile.gpu | 1 - Dockerfile.sample | 6 +- Dockerfile.sample.dockerignore | 1 + Makefile | 2 +- debian/control.in | 2 +- install.sh | 4 +- 14 files changed, 25 insertions(+), 120 deletions(-) delete mode 100644 Dockerfile.binary diff --git a/.gitignore b/.gitignore index 5573f10..c42b43c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ dist/ /samples/ /voices/ +/wheels/*.whl diff --git a/Dockerfile b/Dockerfile index 9b03704..f03a0af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,10 +35,14 @@ RUN --mount=type=cache,id=apt-build,target=/var/cache/apt \ mkdir -p /var/cache/apt/${TARGETARCH}${TARGETVARIANT}/archives/partial && \ apt-get update && \ apt-get install --yes --no-install-recommends \ - python3 python3-pip python3-venv + python3 python3-pip python3-venv \ + build-essential python3-dev + WORKDIR /home/mimic3/app +COPY wheels/ ./wheels/ + COPY opentts-abc/ ./opentts-abc/ COPY mimic3-http/ ./mimic3-http/ COPY mimic3-tts/ ./mimic3-tts/ @@ -46,7 +50,6 @@ COPY install.sh ./ # Install mimic3 RUN --mount=type=cache,id=pip-requirements,target=/root/.cache/pip \ - PIP_INSTALL='install -f https://synesthesiam.github.io/prebuilt-apps/' \ ./install.sh # Download default voice diff --git a/Dockerfile.binary b/Dockerfile.binary deleted file mode 100644 index 3e56c6d..0000000 --- a/Dockerfile.binary +++ /dev/null @@ -1,110 +0,0 @@ -# Copyright 2022 Mycroft AI Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -# ----------------------------------------------------------------------------- -# Dockerfile for Mimic 3 (https://github.com/MycroftAI/mimic3) -# -# Creates self-contained binaries using PyInstaller -# (https://pyinstaller.readthedocs.io/en/stable/). -# -# Requires Docker buildx: https://docs.docker.com/buildx/working-with-buildx/ -# ----------------------------------------------------------------------------- - -FROM debian:bullseye as build -ARG TARGETARCH -ARG TARGETVARIANT - -ENV LANG C.UTF-8 -ENV DEBIAN_FRONTEND=noninteractive - -RUN echo "Dir::Cache var/cache/apt/${TARGETARCH}${TARGETVARIANT};" > /etc/apt/apt.conf.d/01cache - -RUN --mount=type=cache,id=apt-build,target=/var/cache/apt \ - mkdir -p /var/cache/apt/${TARGETARCH}${TARGETVARIANT}/archives/partial && \ - apt-get update && \ - apt-get install --yes --no-install-recommends \ - python3 python3-pip python3-venv \ - build-essential python3-dev \ - libespeak-ng1 - -WORKDIR /build/mimic3 -COPY ./ ./ - -# Install mimic3 -RUN --mount=type=cache,id=pip-venv,target=/root/.cache/pip \ - PIP_INSTALL='install -f https://synesthesiam.github.io/prebuilt-apps/' \ - ./install.sh - -# Install PyInstaller -RUN --mount=type=cache,id=pip-venv,target=/root/.cache/pip \ - .venv/bin/pip3 install 'pyinstaller>=4,<5' - -# Create binary -RUN .venv/bin/pyinstaller \ - --noconfirm \ - --name mimic3 \ - --hidden-import 'pycrfsuite._dumpparser' \ - --hidden-import 'pycrfsuite._logparser' \ - --collect-binaries 'onnxruntime' \ - --collect-data 'gruut' \ - --hidden-import "gruut_lang_de" \ - --collect-data "gruut_lang_de" \ - --hidden-import "gruut_lang_en" \ - --collect-data "gruut_lang_en" \ - --hidden-import "gruut_lang_es" \ - --collect-data "gruut_lang_es" \ - --hidden-import "gruut_lang_fr" \ - --collect-data "gruut_lang_fr" \ - --hidden-import "gruut_lang_it" \ - --collect-data "gruut_lang_it" \ - --hidden-import "gruut_lang_nl" \ - --collect-data "gruut_lang_nl" \ - --hidden-import "gruut_lang_ru" \ - --collect-data "gruut_lang_ru" \ - --hidden-import "gruut_lang_sw" \ - --collect-data "gruut_lang_sw" \ - --hidden-import "gruut_lang_fa" \ - --collect-data "gruut_lang_fa" \ - --collect-data 'espeak_phonemizer' \ - --collect-data 'phonemes2ids' \ - --hidden-import 'swagger_ui' \ - --hidden-import 'epitran' \ - --hidden-import 'hazm' \ - --collect-data 'hazm' \ - --collect-data 'panphon' \ - --collect-data 'mimic3_tts' \ - --collect-data 'mimic3_http' \ - pyinstaller/mimic3.py - -# Have to manually copy these over for some reason -RUN find .venv -name 'wapiti' -type d -exec cp -R {} dist/mimic3/ \; -RUN find .venv -name 'libwapiti.*.so' -type f -exec cp {} dist/mimic3/ \; - -# Clean up unused lexicons -RUN find dist/mimic3/ -wholename '*/gruut_lang_*/espeak' -type d | \ - while read -r espeak_dir; do \ - rm -rf "${espeak_dir}"; \ - done - -# Copy convenience scripts -COPY pyinstaller/mimic3-server \ - pyinstaller/mimic3-download \ - dist/mimic3/ - -# ----------------------------------------------------------------------------- - -FROM scratch - -COPY --from=build /build/mimic3/dist/ / diff --git a/Dockerfile.debian b/Dockerfile.debian index 19ec8d7..1a0263a 100644 --- a/Dockerfile.debian +++ b/Dockerfile.debian @@ -43,6 +43,8 @@ RUN --mount=type=cache,id=apt-build,target=/var/cache/apt \ WORKDIR /build/mimic3 +COPY wheels/ ./wheels/ + COPY opentts-abc/ ./opentts-abc/ COPY mimic3-http/ ./mimic3-http/ COPY mimic3-tts/ ./mimic3-tts/ @@ -50,7 +52,6 @@ COPY install.sh ./ # Install mimic3 RUN --mount=type=cache,id=pip-venv,target=/root/.cache/pip \ - PIP_INSTALL='install -f https://synesthesiam.github.io/prebuilt-apps/' \ ./install.sh # Install PyInstaller diff --git a/Dockerfile.debian.dockerignore b/Dockerfile.debian.dockerignore index db3b6e2..5caa72f 100644 --- a/Dockerfile.debian.dockerignore +++ b/Dockerfile.debian.dockerignore @@ -6,6 +6,7 @@ !tests/apope_sample.txt !tests/apope_sample_*.wav !voices/ +!wheels/ # Debian packaging !debian/control.in diff --git a/Dockerfile.dist b/Dockerfile.dist index 4877fe5..c83a95d 100644 --- a/Dockerfile.dist +++ b/Dockerfile.dist @@ -37,6 +37,8 @@ RUN --mount=type=cache,id=apt-build,target=/var/cache/apt \ WORKDIR /build/mimic3 +COPY wheels/ ./wheels/ + COPY opentts-abc/ ./opentts-abc/ COPY mimic3-http/ ./mimic3-http/ COPY mimic3-tts/ ./mimic3-tts/ @@ -65,6 +67,8 @@ RUN --mount=type=cache,id=apt-run,target=/var/cache/apt \ WORKDIR /test +COPY wheels/ ./wheels/ + COPY --from=build /build/mimic3/dist/*.tar.gz ./dist/ # Install mimic3 using source distribution @@ -72,6 +76,7 @@ RUN --mount=type=cache,id=pip-requirements,target=/root/.cache/pip \ python3 -m venv .venv && \ .venv/bin/pip3 install \ -f https://synesthesiam.github.io/prebuilt-apps/ \ + -f https://www.piwheels.hostedpi.com/simple/numpy/ \ -f dist/ \ mimic3-tts diff --git a/Dockerfile.dist.dockerignore b/Dockerfile.dist.dockerignore index 9d96d09..b806b3a 100644 --- a/Dockerfile.dist.dockerignore +++ b/Dockerfile.dist.dockerignore @@ -3,6 +3,7 @@ !tests/apope_sample.txt !tests/apope_sample_*.wav !voices/ +!wheels/ # opentts-abc !opentts-abc/setup.py diff --git a/Dockerfile.dockerignore b/Dockerfile.dockerignore index 6afb7f8..0e4e897 100644 --- a/Dockerfile.dockerignore +++ b/Dockerfile.dockerignore @@ -3,6 +3,7 @@ !tests/apope_sample.txt !tests/apope_sample_*.wav !voices/ +!wheels/ # opentts-abc !opentts-abc/setup.py diff --git a/Dockerfile.gpu b/Dockerfile.gpu index a027782..014a3a0 100644 --- a/Dockerfile.gpu +++ b/Dockerfile.gpu @@ -50,7 +50,6 @@ RUN sed -i 's/onnxruntime/onnxruntime-gpu/' mimic3-tts/requirements.txt # Install mimic3 RUN --mount=type=cache,id=pip-requirements,target=/root/.cache/pip \ - PIP_INSTALL='install -f https://synesthesiam.github.io/prebuilt-apps/' \ ./install.sh RUN useradd -ms /bin/bash mimic3 diff --git a/Dockerfile.sample b/Dockerfile.sample index bd918e4..772fb02 100644 --- a/Dockerfile.sample +++ b/Dockerfile.sample @@ -34,11 +34,12 @@ RUN --mount=type=cache,id=apt-build,target=/var/cache/apt \ mkdir -p /var/cache/apt/${TARGETARCH}${TARGETVARIANT}/archives/partial && \ apt-get update && \ apt-get install --yes --no-install-recommends \ - python3 python3-pip python3-venv \ - build-essential python3-dev + python3 python3-pip python3-venv WORKDIR /home/mimic3/app +COPY wheels/ ./wheels/ + COPY opentts-abc/ ./opentts-abc/ COPY mimic3-http/ ./mimic3-http/ COPY mimic3-tts/ ./mimic3-tts/ @@ -46,7 +47,6 @@ COPY install.sh ./ # Install mimic3 RUN --mount=type=cache,id=pip-requirements,target=/root/.cache/pip \ - PIP_INSTALL='install -f https://synesthesiam.github.io/prebuilt-apps/' \ ./install.sh # Download default voice diff --git a/Dockerfile.sample.dockerignore b/Dockerfile.sample.dockerignore index 07725eb..ba9405b 100644 --- a/Dockerfile.sample.dockerignore +++ b/Dockerfile.sample.dockerignore @@ -2,6 +2,7 @@ !install.sh !tests/apope_sample.txt !voices/ +!wheels/ # opentts-abc !opentts-abc/setup.py diff --git a/Makefile b/Makefile index af9c995..f08233c 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ SHELL := bash # linux/amd64,linux/arm64,linux/arm/v7 DOCKER_PLATFORM ?= linux/amd64 -DOCKER_OUTPUT ?= --load +DOCKER_OUTPUT ?= DOCKER_TAG ?= mycroftai/mimic3 # Build source distributions for PyPI. diff --git a/debian/control.in b/debian/control.in index 4e8769a..5f56ad6 100644 --- a/debian/control.in +++ b/debian/control.in @@ -2,7 +2,7 @@ Package: mimic3-tts Version: ${VERSION} Section: utils Priority: optional -Depends: libespeak-ng1 libatomic1 libgomp1 +Depends: libespeak-ng1,libatomic1,libgomp1 Recommends: sox Architecture: ${DEBIAN_ARCH} Maintainer: Mycroft AI diff --git a/install.sh b/install.sh index d03fed3..71a90f7 100755 --- a/install.sh +++ b/install.sh @@ -34,7 +34,9 @@ this_dir="$( cd "$( dirname "$0" )" && pwd )" : "${PYTHON=python3}" # pip install command -: "${PIP_INSTALL=install}" +if [ -z "${PIP_INSTALL}" ]; then + PIP_INSTALL="install -f "${this_dir}/wheels"" +fi python_version="$(${PYTHON} --version)"