-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathDockerfile.core1
197 lines (152 loc) · 7.04 KB
/
Dockerfile.core1
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
196
197
# Copyright 2022 Mycroft AI Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# -----------------------------------------------------------------------------
#
# Docker build script for Mark II
#
# Requires buildkit: https://docs.docker.com/develop/develop-images/build_enhancements/
# -----------------------------------------------------------------------------
FROM scratch as base
ADD raspberry-pi-os/p2.tar /
# -----------------------------------------------------------------------------
# Base image with locale set
FROM base as base-with-locale
ARG TARGETARCH
ARG TARGETVARIANT
ENV DEBIAN_FRONTEND=noninteractive
# Set the locale
RUN --mount=type=cache,id=apt-base-with-local,target=/var/cache/apt \
apt-get update && apt-get install -y locales \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# -----------------------------------------------------------------------------
# Base image for building tools and virtual environments
FROM base-with-locale as base-build
WORKDIR /build
COPY docker/packages-build.txt docker/packages-venv.txt ./
RUN --mount=type=cache,id=apt-base-build,target=/var/cache/apt \
apt-get update && \
cat packages-*.txt | xargs apt-get install --yes --no-install-recommends
# -----------------------------------------------------------------------------
# Build
# -----------------------------------------------------------------------------
# Image where Mycroft GUI is built
FROM base-build as build-gui
COPY mycroft-dinkum/services/gui/mycroft-gui/ ./mycroft-gui/
COPY docker/build/gui/build-mycroft-gui.sh ./
RUN ./build-mycroft-gui.sh
COPY mycroft-dinkum/services/gui/lottie-qml/ ./lottie-qml/
COPY docker/build/gui/build-lottie-qml.sh ./
RUN ./build-lottie-qml.sh
COPY mycroft-dinkum/services/gui/mycroft-gui-mark-2/ ./mycroft-gui-mark-2/
COPY docker/build/gui/build-mycroft-gui-mark-2.sh ./
RUN ./build-mycroft-gui-mark-2.sh
# -----------------------------------------------------------------------------
FROM base-build as build-core1
COPY docker/packages-core1.txt ./
RUN --mount=type=cache,id=apt-base-build,target=/var/cache/apt \
apt-get update && \
cat packages-*.txt | xargs apt-get install --yes --no-install-recommends
# Install Mycroft
RUN cd /opt && \
git clone --single-branch --branch mark-ii/latest 'https://github.com/MycroftAI/mycroft-core.git' mycroft
RUN --mount=type=cache,id=apt-build-core1,target=/var/cache/apt \
--mount=type=cache,id=pip-build-core1,target=/root/.cache/pip \
cd /opt/mycroft && \
CI=true bash dev_setup.sh --allow-root -sm
# Install Mimic 3 plugin
RUN --mount=type=cache,id=pip-build-hal,target=/root/.cache/pip \
/opt/mycroft/bin/mycroft-pip install --upgrade pip && \
/opt/mycroft/bin/mycroft-pip install mycroft-plugin-tts-mimic3[all]
# Install skills
RUN mkdir -p /opt/mycroft/skills && \
cd /opt/mycroft/skills && \
git clone --single-branch --branch bugfix/resting-screen 'https://github.com/MycroftAI/skill-homescreen' homescreen && \
git clone --single-branch --branch bugfix/resting_screen 'https://github.com/mycroftai/skill-mark-2' mycroft-mark-2
# -----------------------------------------------------------------------------
# Image where XMOS/HAL services are built
FROM base-build as build-hal
COPY dbus-hal /usr/local/mycroft/mark-2/dbus-hal/
RUN --mount=type=cache,id=pip-build-hal,target=/root/.cache/pip \
cd /usr/local/mycroft/mark-2/dbus-hal/ && \
./install.sh
# -----------------------------------------------------------------------------
# Run
# -----------------------------------------------------------------------------
FROM base-with-locale as run
ARG TARGETARCH
ARG TARGETVARIANT
ENV DEBIAN_FRONTEND=noninteractive
RUN echo "Dir::Cache var/cache/apt/${TARGETARCH}${TARGETVARIANT};" > /etc/apt/apt.conf.d/01cache
COPY docker/packages-run.txt docker/packages-core1.txt ./
RUN --mount=type=cache,id=apt-build,target=/var/cache/apt \
mkdir -p /var/cache/apt/${TARGETARCH}${TARGETVARIANT}/archives/partial && \
apt-get update && \
cat packages-*.txt | xargs apt-get install --yes --no-install-recommends
# Kernel module and setup scripts
COPY vocalfusion/app_xvf3510_int_spi_boot_v4_2_0.bin \
vocalfusion/run.sh \
vocalfusion/setup_microphone.py \
vocalfusion/setup_speakers.py \
vocalfusion/vocalfusion-rpi-setup-5.2.0/loader/i2s_master/i2s_master_loader.ko \
vocalfusion/vocalfusion-rpi-setup-5.2.0/resources/clk_dac_setup/setup_mclk \
vocalfusion/vocalfusion-rpi-setup-5.2.0/resources/clk_dac_setup/setup_bclk \
/usr/local/mycroft/mark-2/
# ALSA config
COPY vocalfusion/vocalfusion-rpi-setup-5.2.0/resources/asoundrc_vf_xvf3510_int \
/etc/alsa/conf.d/20-xmos.conf
# systemd service
COPY vocalfusion/etc/mark2-microphone.service \
/etc/systemd/system/
# Enable i2c
RUN echo 'i2c-dev' >> /etc/modules
# Copy HAL tools
COPY --from=build-hal --chown=pi:pi /usr/local/mycroft/ /usr/local/mycroft/
# Copy pre-built GUI files
COPY --from=build-gui /usr/local/ /usr/
COPY --from=build-gui /usr/lib/aarch64-linux-gnu/qt5/qml/ /usr/lib/aarch64-linux-gnu/qt5/qml/
# Copy core1 code and virtual environment
COPY --from=build-core1 --chown=pi:pi /opt/mycroft/ /opt/mycroft/
# Copy system files
COPY files/ /
COPY files-core1/ /
# Create directory for logs
RUN mkdir -p /var/log/mycroft
# Install the Noto Sans font family using config from /etc
ADD docker/build/mycroft/Font_NotoSans-hinted.tar.gz /usr/share/fonts/truetype/noto-sans/
COPY docker/build/mycroft/install-fonts.sh ./
RUN ./install-fonts.sh
# Fix permissions
RUN chown -R pi:pi /home/pi/ /var/log/mycroft/
# Enable services
RUN systemctl enable /etc/systemd/system/mark2-microphone.service && \
systemctl enable /etc/systemd/system/mark2-hal.service && \
systemctl enable /etc/systemd/system/mark2-boot.service && \
systemctl enable /etc/systemd/system/mark2-core1.service && \
systemctl enable /etc/systemd/system/mark2-plasma.service && \
systemctl enable /etc/systemd/system/mark2-automount.service && \
systemctl set-default graphical
# Service aliases
RUN ln -s /etc/systemd/system/mark2-microphone.service /etc/systemd/system/mycroft-xmos.service && \
ln -s /etc/systemd/system/mark2-plasma.service /etc/systemd/system/mycroft-plasma.service
# Clean up
RUN --mount=type=cache,id=apt-build,target=/var/cache/apt \
apt-get clean && \
apt-get autoremove --yes && \
rm -rf /var/lib/apt/ && \
rm -f /etc/apt/apt.conf.d/01cache