forked from rhasspy/rhasspy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.debian
195 lines (153 loc) · 7.06 KB
/
Dockerfile.debian
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
FROM debian:buster-slim as base
ENV LANG C.UTF-8
ENV DEBIAN_FRONTEND=noninteractive
# IFDEF APT_PROXY
#! RUN echo 'Acquire::http { Proxy "http://${APT_PROXY_HOST}:${APT_PROXY_PORT}"; };' >> /etc/apt/apt.conf.d/01proxy
# ENDIF
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && \
apt-get install --no-install-recommends --yes \
build-essential swig portaudio19-dev \
libatlas-base-dev libopenblas-dev gfortran \
gfortran libopenblas-dev liblapack-dev cython \
curl ca-certificates \
libffi-dev
ENV NUM_JOBS=8
ENV BUILD_DIR=/build
ENV APP_DIR=${BUILD_DIR}/rhasspy/usr/lib/rhasspy
# -----------------------------------------------------------------------------
FROM base as base-amd64
FROM base as base-armv7
FROM base as base-arm64
FROM balenalib/raspberry-pi-debian:buster-build-20210225 as base-armv6
ENV LANG C.UTF-8
# IFDEF APT_PROXY
#! RUN echo 'Acquire::http { Proxy "http://${APT_PROXY_HOST}:${APT_PROXY_PORT}"; };' >> /etc/apt/apt.conf.d/01proxy
# ENDIF
RUN --mount=type=cache,target=/var/cache/apt \
install_packages \
swig portaudio19-dev libatlas-base-dev \
curl ca-certificates
ENV NUM_JOBS=8
ENV BUILD_DIR=/build
ENV APP_DIR=${BUILD_DIR}/rhasspy/usr/lib/rhasspy
# -----------------------------------------------------------------------------
# Python 3.7
# -----------------------------------------------------------------------------
ARG TARGETARCH
ARG TARGETVARIANT
FROM base-$TARGETARCH$TARGETVARIANT as python
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && \
apt-get install --yes --no-install-recommends \
build-essential \
git zlib1g-dev patchelf rsync \
libncursesw5-dev libreadline-gplv2-dev libssl-dev \
libgdbm-dev libc6-dev libsqlite3-dev libbz2-dev libffi-dev
ADD download/source/Python-3.7.8.tgz /build
RUN cd /build/Python-3.7.8 && \
./configure && \
make -j $NUM_JOBS && \
make install DESTDIR=$APP_DIR
# -----------------------------------------------------------------------------
# Rhasspy
# -----------------------------------------------------------------------------
ARG TARGETARCH
ARG TARGETVARIANT
FROM base-$TARGETARCH$TARGETVARIANT as rhasspy
COPY --from=python ${APP_DIR}/ ${APP_DIR}/
COPY --from=python ${APP_DIR}/usr/local/include/python3.7m/ /usr/include/
ENV PYTHON=${APP_DIR}/usr/local/bin/python3
# IFDEF PYPI_PROXY
#! ENV PIP_INDEX_URL=http://${PYPI_PROXY_HOST}:${PYPI_PROXY_PORT}/simple/
#! ENV PIP_TRUSTED_HOST=${PYPI_PROXY_HOST}
# ENDIF
RUN ${PYTHON} -m pip install --upgrade pip
RUN ${PYTHON} -m pip install --upgrade wheel setuptools
ARG TARGETARCH
ARG TARGETVARIANT
# Directory of prebuilt tools
ENV DOWNLOAD_DIR=${BUILD_DIR}/download
COPY download/shared/ ${DOWNLOAD_DIR}/shared/
COPY download/${TARGETARCH}${TARGETVARIANT}/ ${DOWNLOAD_DIR}/${TARGETARCH}${TARGETVARIANT}/
# Copy Rhasspy source
COPY rhasspy/ ${APP_DIR}/rhasspy/
COPY rhasspy-server-hermes/ ${APP_DIR}/rhasspy-server-hermes/
COPY rhasspy-wake-snowboy-hermes/ ${APP_DIR}/rhasspy-wake-snowboy-hermes/
COPY rhasspy-wake-porcupine-hermes/ ${APP_DIR}/rhasspy-wake-porcupine-hermes/
COPY rhasspy-wake-precise-hermes/ ${APP_DIR}/rhasspy-wake-precise-hermes/
COPY rhasspy-profile/ ${APP_DIR}/rhasspy-profile/
COPY rhasspy-asr/ ${APP_DIR}/rhasspy-asr/
COPY rhasspy-asr-deepspeech ${APP_DIR}/rhasspy-asr-deepspeech/
COPY rhasspy-asr-deepspeech-hermes/ ${APP_DIR}/rhasspy-asr-deepspeech-hermes/
COPY rhasspy-asr-pocketsphinx/ ${APP_DIR}/rhasspy-asr-pocketsphinx/
COPY rhasspy-asr-pocketsphinx-hermes/ ${APP_DIR}/rhasspy-asr-pocketsphinx-hermes/
COPY rhasspy-asr-kaldi/ ${APP_DIR}/rhasspy-asr-kaldi/
COPY rhasspy-asr-kaldi-hermes/ ${APP_DIR}/rhasspy-asr-kaldi-hermes/
COPY rhasspy-asr-vosk-hermes/ ${APP_DIR}/rhasspy-asr-vosk-hermes/
COPY rhasspy-dialogue-hermes/ ${APP_DIR}/rhasspy-dialogue-hermes/
COPY rhasspy-fuzzywuzzy/ ${APP_DIR}/rhasspy-fuzzywuzzy/
COPY rhasspy-fuzzywuzzy-hermes/ ${APP_DIR}/rhasspy-fuzzywuzzy-hermes/
COPY rhasspy-hermes/ ${APP_DIR}/rhasspy-hermes/
COPY rhasspy-homeassistant-hermes/ ${APP_DIR}/rhasspy-homeassistant-hermes/
COPY rhasspy-microphone-cli-hermes/ ${APP_DIR}/rhasspy-microphone-cli-hermes/
COPY rhasspy-microphone-pyaudio-hermes/ ${APP_DIR}/rhasspy-microphone-pyaudio-hermes/
COPY rhasspy-nlu/ ${APP_DIR}/rhasspy-nlu/
COPY rhasspy-nlu-hermes/ ${APP_DIR}/rhasspy-nlu-hermes/
COPY rhasspy-rasa-nlu-hermes/ ${APP_DIR}/rhasspy-rasa-nlu-hermes/
COPY rhasspy-remote-http-hermes/ ${APP_DIR}/rhasspy-remote-http-hermes/
COPY rhasspy-silence/ ${APP_DIR}/rhasspy-silence/
COPY rhasspy-speakers-cli-hermes/ ${APP_DIR}/rhasspy-speakers-cli-hermes/
COPY rhasspy-supervisor/ ${APP_DIR}/rhasspy-supervisor/
COPY rhasspy-tts-cli-hermes/ ${APP_DIR}/rhasspy-tts-cli-hermes/
COPY rhasspy-tts-wavenet-hermes/ ${APP_DIR}/rhasspy-wavenet-cli-hermes/
COPY rhasspy-wake-pocketsphinx-hermes/ ${APP_DIR}/rhasspy-wake-pocketsphinx-hermes/
COPY rhasspy-wake-raven/ ${APP_DIR}/rhasspy-wake-raven/
COPY rhasspy-wake-raven-hermes/ ${APP_DIR}/rhasspy-wake-raven-hermes/
COPY rhasspy-tts-larynx-hermes/ ${APP_DIR}/rhasspy-tts-larynx-hermes/
# Autoconf
COPY m4/ ${APP_DIR}/m4/
COPY configure config.sub config.guess \
install-sh missing aclocal.m4 \
RHASSPY_DIRS Makefile.in setup.py.in rhasspy.sh.in rhasspy.spec.in \
${APP_DIR}/
RUN cd ${APP_DIR} && \
./configure --enable-in-place --disable-virtualenv --prefix=${APP_DIR}/
COPY scripts/install/ ${APP_DIR}/scripts/install/
COPY etc/shflags ${APP_DIR}/etc/
COPY etc/wav/ ${APP_DIR}/etc/wav/
COPY README.md LICENSE RHASSPY_DIRS ${APP_DIR}/
RUN --mount=type=cache,target=/root/.cache/pip \
export PIP_INSTALL_ARGS="-f ${DOWNLOAD_DIR}/shared -f ${DOWNLOAD_DIR}/${TARGETARCH}${TARGETVARIANT}" && \
export PIP_PRE_PREINSTALL_PACKAGES='cython' && \
export PIP_PREINSTALL_PACKAGES='numpy==1.20.1 scipy==1.5.1' && \
export PIP_VERSION='pip<=20.2.4' && \
if [ "${TARGETARCH}${TARGETVARIANT}" = 'amd64' ]; then \
export PIP_PREINSTALL_PACKAGES="${PIP_PREINSTALL_PACKAGES} detect-simd~=0.2.0"; \
fi && \
if [ ! "${TARGETARCH}${TARGETVARIANT}" = 'armv6' ]; then \
export PIP_PREINSTALL_PACKAGES="${PIP_PREINSTALL_PACKAGES} scikit-learn==0.23.2"; \
fi && \
export POCKETSPHINX_FROM_SRC=no && \
cd ${APP_DIR} && \
make && \
make install
# Clean up
RUN cd ${APP_DIR} && \
find . -depth -type d -name '.git' -exec rm -rf {} \; && \
find . -depth -type d -name '__pycache__' -exec rm -rf {} \; && \
find . -type f -name 'g2p.fst.gz' -exec gunzip -f {} \;
COPY VERSION ${BUILD_DIR}/
COPY debian/control.in /
RUN export DEBIAN_ARCH="$(dpkg-architecture | grep DEB_BUILD_ARCH= | sed -e 's/[^=]\+=//')" && \
export VERSION="$(cat ${BUILD_DIR}/VERSION)" && \
mkdir -p ${BUILD_DIR}/rhasspy/DEBIAN && \
sed -e s"/@VERSION@/${VERSION}/" -e "s/@DEBIAN_ARCH@/${DEBIAN_ARCH}/" < /control.in > ${BUILD_DIR}/rhasspy/DEBIAN/control
COPY debian/rhasspy ${BUILD_DIR}/rhasspy/usr/bin/
RUN cd ${BUILD_DIR} && \
dpkg --build rhasspy
RUN cd ${BUILD_DIR} && \
dpkg-name *.deb
# -----------------------------------------------------------------------------
FROM scratch
COPY --from=rhasspy /build/*.deb /