diff --git a/.dockerignore b/.dockerignore index 9cfa55f..89db35a 100755 --- a/.dockerignore +++ b/.dockerignore @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4e7c830 --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/docker/run.sh b/docker/run.sh index c85a14a..31c5ad2 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -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