-
Notifications
You must be signed in to change notification settings - Fork 13
/
Dockerfile
121 lines (88 loc) · 3.73 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
# -----------------------------------------------------------------------------
# Dockerfile for Rhasspy Supervisor Tool
# (https://github.com/rhasspy/rhasspy-supervisor)
#
# 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 \
make
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
# -----------------------------------------------------------------------------
# Build
# -----------------------------------------------------------------------------
ARG TARGETARCH
ARG TARGETVARIANT
FROM build-$TARGETARCH$TARGETVARIANT as build
ENV APP_DIR=/usr/lib/rhasspy-supervisor
COPY requirements.txt Makefile ${APP_DIR}/
COPY scripts/ ${APP_DIR}/scripts/
# IFDEF PYPI
#! ENV PIP_INDEX_URL=http://${PYPI}/simple/
#! ENV PIP_TRUSTED_HOST=${PYPI_HOST}
# ENDIF
RUN cd ${APP_DIR} && \
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
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
# -----------------------------------------------------------------------------
ARG TARGETARCH
ARG TARGETVARIANT
FROM run-$TARGETARCH$TARGETVARIANT
ENV APP_DIR=/usr/lib/rhasspy-supervisor
COPY --from=build ${APP_DIR}/ ${APP_DIR}/
COPY bin/ ${APP_DIR}/bin/
COPY rhasspysupervisor/ ${APP_DIR}/rhasspysupervisor
ENTRYPOINT ["bash", "/usr/lib/rhasspy-supervisor/bin/rhasspy-supervisor"]