# 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/ /