Refactor Dockerfile

This commit is contained in:
Michael Hansen
2020-04-10 11:05:18 -04:00
parent 32f7e37657
commit 015c37fa5d
3 changed files with 83 additions and 2 deletions
+4 -2
View File
@@ -1,7 +1,6 @@
*
!etc/qemu-*
!download/rhasspy-tools*
!download/rhasspy-*
!download/pocketsphinx-python.tar.gz
!download/snowboy*
!download/kaldi*
@@ -9,6 +8,9 @@
!requirements.txt
!dist/
!etc/wav
!etc/shflags
!create-venv.sh
!download-dependencies.sh
!docker/run.sh
!docker/rhasspy
+74
View File
@@ -0,0 +1,74 @@
FROM ubuntu:eoan as build
ARG TARGETPLATFORM
ARG TARGETARCH
ARG TARGETVARIANT
ENV LANG C.UTF-8
ENV RHASSPY_APP /usr/share/rhasspy
ENV RHASSPY_VENV ${RHASSPY_APP}/.venv
WORKDIR /
RUN apt-get update && \
apt-get install --no-install-recommends --yes \
python3 python3-dev python3-setuptools python3-pip python3-venv \
build-essential swig portaudio19-dev libatlas-base-dev
COPY etc/shflags ${RHASSPY_APP}/etc/
COPY download/ ${RHASSPY_APP}/download/
COPY create-venv.sh download-dependencies.sh requirements.txt ${RHASSPY_APP}/
RUN cd ${RHASSPY_APP} && ./create-venv.sh --nosystem
# -----------------------------------------------------------------------------
FROM ubuntu:eoan
ARG TARGETPLATFORM
ARG TARGETARCH
ARG TARGETVARIANT
ENV LANG C.UTF-8
ENV RHASSPY_APP /usr/share/rhasspy
ENV RHASSPY_VENV ${RHASSPY_APP}/.venv
WORKDIR /
RUN apt-get update && \
apt-get install --no-install-recommends --yes \
python3 python3-dev \
bash jq unzip curl perl \
libportaudio2 libatlas3-base \
libgfortran4 ca-certificates \
sox espeak flite libttspico-utils alsa-utils lame \
libasound2-plugins \
libfreetype6-dev libpng-dev pkg-config libffi-dev libssl-dev \
gstreamer1.0-tools gstreamer1.0-plugins-good
COPY --from=build ${RHASSPY_VENV} ${RHASSPY_VENV}
# Runtime tools
ADD download/rhasspy-tools_${TARGETARCH}${TARGETVARIANT}.tar.gz /usr/
ADD download/kaldi_${TARGETARCH}${TARGETVARIANT}.tar.gz /opt/
RUN ldconfig
# Copy script to run
COPY docker/run.sh /run.sh
RUN chmod +x /run.sh
COPY profiles/ ${RHASSPY_APP}/profiles/
COPY profiles/defaults.json ${RHASSPY_APP}/profiles/
COPY docker/rhasspy ${RHASSPY_APP}/bin/
COPY dist/ ${RHASSPY_APP}/dist/
COPY etc/wav/* ${RHASSPY_APP}/etc/wav/
COPY rhasspy/profile_schema.json ${RHASSPY_APP}/rhasspy/
COPY rhasspy/train/jsgf2fst/*.py ${RHASSPY_APP}/rhasspy/train/jsgf2fst/
COPY rhasspy/train/*.py ${RHASSPY_APP}/rhasspy/train/
COPY *.py ${RHASSPY_APP}/
COPY rhasspy/*.py ${RHASSPY_APP}/rhasspy/
COPY VERSION ${RHASSPY_APP}/
ENV CONFIG_PATH /data/options.json
ENV KALDI_PREFIX /opt
ENTRYPOINT ["/run.sh"]
+5
View File
@@ -19,6 +19,11 @@ if [[ -f "${CONFIG_PATH}" ]]; then
RHASSPY_ARGS="--profile \"${profile_name}\" --user-profiles \"${profile_dir}\""
fi
RHASSPY_VENV="${RHASSPY_APP}/.venv"
if [[ -d "${RHASSPY_VENV}" ]]; then
source "${RHASSPY_VENV}/bin/activate"
fi
cd "${RHASSPY_APP}"
if [[ -z "${RHASSPY_ARGS}" ]]; then