-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
143 lines (104 loc) · 4.28 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# -----------------------------------------------------------------------------
# Dockerfile for Rhasspy Text to Speech Service
# (https://github.com/rhasspy/rhasspy-tts-cli-hermes)
#
# Requires Docker buildx: https://docs.docker.com/buildx/working-with-buildx/
# See scripts/build-docker.sh
#
# Builds a multi-arch image for amd64/armv6/armv7/arm64.
# The virtual environment from the build stage is copied over to the run stage.
# The Rhasspy source code is then copied into the run stage and executed within
# that virtual environment.
#
# Build stages are named build-$TARGETARCH$TARGETVARIANT, so build-amd64,
# build-armv6, etc. Run stages are named similarly.
#
# armv6 images (Raspberry Pi 0/1) are derived from balena base images:
# https://www.balena.io/docs/reference/base-images/base-images/#balena-base-images
#
# The IFDEF statements are handled by docker/preprocess.sh. These are just
# comments that are uncommented if the environment variable after the IFDEF is
# not empty.
#
# The build-docker.sh script will optionally add apt/pypi proxies running locally:
# * apt - https://docs.docker.com/engine/examples/apt-cacher-ng/
# * pypi - https://github.com/jayfk/docker-pypi-cache
# -----------------------------------------------------------------------------
FROM ubuntu:eoan as build-ubuntu
ENV LANG C.UTF-8
# IFDEF PROXY
#! RUN echo 'Acquire::http { Proxy "http://${PROXY}"; };' >> /etc/apt/apt.conf.d/01proxy
# ENDIF
RUN apt-get update && \
apt-get install --no-install-recommends --yes \
python3 python3-setuptools python3-pip python3-venv \
build-essential curl ca-certificates
FROM build-ubuntu as build-amd64
FROM build-ubuntu as build-armv7
FROM build-ubuntu as build-arm64
# -----------------------------------------------------------------------------
FROM balenalib/raspberry-pi-debian-python:3.7-buster-build-20200604 as build-armv6
ENV LANG C.UTF-8
# IFDEF PROXY
#! RUN echo 'Acquire::http { Proxy "http://${PROXY}"; };' >> /etc/apt/apt.conf.d/01proxy
# ENDIF
RUN install_packages curl ca-certificates
# -----------------------------------------------------------------------------
# Build
# -----------------------------------------------------------------------------
ARG TARGETARCH
ARG TARGETVARIANT
FROM build-$TARGETARCH$TARGETVARIANT as build
ENV APP_DIR=/usr/lib/rhasspy-tts-cli-hermes
ENV BUILD_DIR=/build
# Directory of prebuilt tools
COPY download/ ${BUILD_DIR}/download/
COPY requirements.txt ${BUILD_DIR}/
# Autoconf
COPY m4/ ${BUILD_DIR}/m4/
COPY configure config.sub config.guess \
install-sh missing aclocal.m4 \
Makefile.in rhasspy-tts-cli-hermes.in \
${BUILD_DIR}/
RUN cd ${BUILD_DIR} && \
./configure --enable-in-place --prefix=${APP_DIR}/.venv
COPY scripts/ ${BUILD_DIR}/scripts/
# IFDEF PYPI
#! ENV PIP_INDEX_URL=http://${PYPI}/simple/
#! ENV PIP_TRUSTED_HOST=${PYPI_HOST}
# ENDIF
RUN cd ${BUILD_DIR} && \
make && \
make install
# Strip binaries and shared libraries
RUN (find ${APP_DIR} -type f -name '*.so*' -print0 | xargs -0 strip --strip-unneeded -- 2>/dev/null) || true
RUN (find ${APP_DIR} -type f -executable -print0 | xargs -0 strip --strip-unneeded -- 2>/dev/null) || true
# -----------------------------------------------------------------------------
FROM ubuntu:eoan as run-ubuntu
ENV LANG C.UTF-8
# IFDEF PROXY
#! RUN echo 'Acquire::http { Proxy "http://${PROXY}"; };' >> /etc/apt/apt.conf.d/01proxy
# ENDIF
RUN apt-get update && \
apt-get install --yes --no-install-recommends \
python3 \
espeak flite libttspico-utils
FROM run-ubuntu as run-amd64
FROM run-ubuntu as run-armv7
FROM run-ubuntu as run-arm64
# -----------------------------------------------------------------------------
FROM balenalib/raspberry-pi-debian-python:3.7-buster-run-20200604 as run-armv6
ENV LANG C.UTF-8
RUN install_packages \
espeak flite
# -----------------------------------------------------------------------------
# Run
# -----------------------------------------------------------------------------
ARG TARGETARCH
ARG TARGETVARIANT
FROM run-$TARGETARCH$TARGETVARIANT
ENV APP_DIR=/usr/lib/rhasspy-tts-cli-hermes
COPY --from=build ${APP_DIR}/ ${APP_DIR}/
COPY bin/ ${APP_DIR}/bin/
COPY rhasspytts_cli_hermes/ ${APP_DIR}/rhasspytts_cli_hermes
ENTRYPOINT ["bash", "/usr/lib/rhasspy-tts-cli-hermes/bin/rhasspy-tts-cli-hermes"]