Created
April 1, 2021 03:56
-
-
Save krisgesling/04db75c28bf7329ea009d4845a886def to your computer and use it in GitHub Desktop.
Mark II mycroft container build script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine as qemu | |
RUN if [ -n "aarch64" ]; then \ | |
wget -O /qemu-aarch64-static https://github.com/multiarch/qemu-user-static/releases/download/v5.1.0-5/qemu-aarch64-static; \ | |
else \ | |
echo '#!/bin/sh\n\ntrue' > /qemu-aarch64-static; \ | |
fi; \ | |
chmod a+x /qemu-aarch64-static | |
FROM arm64v8/ubuntu:20.04 as builder | |
COPY --from=qemu /qemu-aarch64-static /usr/bin/ | |
WORKDIR /opt/build | |
ENV TERM linux | |
ENV DEBIAN_FRONTEND noninteractive | |
RUN apt-get update && apt-get -y install wget devscripts build-essential git gcc make automake libpcre2-dev libtool libasound2-dev git-core g++ cmake extra-cmake-modules gettext pkg-config qml-module-qtwebengine pkg-kde-tools qtbase5-dev qtdeclarative5-dev libkf5kio-dev libqt5websockets5-dev libkf5i18n-dev libkf5notifications-dev libkf5plasma-dev libqt5webview5-dev qtmultimedia5-dev && rm -rf /var/lib/apt/lists/* | |
ADD mycroft-gui /opt/build/mycroft-gui/ | |
RUN mkdir -p mycroft-gui/builddir && cd mycroft-gui/builddir && \ | |
cmake ../ -DCMAKE_INSTALL_PREFIX=/usr/local \ | |
-DCMAKE_BUILD_TYPE=Release -DKDE_INSTALL_LIBDIR=lib \ | |
-DKDE_INSTALL_USE_QT_SYS_PATHS=on && \ | |
make -j8 && make install | |
ADD lottie-qml /opt/build/lottie-qml/ | |
RUN mkdir -p lottie-qml/builddir && cd lottie-qml/builddir && \ | |
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release \ | |
-DKDE_INSTALL_LIBDIR=lib -DKDE_INSTALL_USE_QT_SYS_PATHS=ON && \ | |
make -j8 && make install | |
RUN apt-get update && apt-get install -y plasma-workspace-dev && rm -rf /var/lib/apt/lists/* | |
ADD mycroft-gui-mark-2 /opt/build/mycroft-gui-mark-2/ | |
RUN sed -i 's/CW/NORMAL/g' mycroft-gui-mark-2/lookandfeel/contents/plasmoidsetupscripts/org.kde.mycroft.mark2.js && \ | |
mkdir -p mycroft-gui-mark-2/builddir && cd mycroft-gui-mark-2/builddir && \ | |
cmake ../ -DCMAKE_INSTALL_PREFIX=/usr/local \ | |
-DCMAKE_BUILD_TYPE=Release -DKDE_INSTALL_LIBDIR=lib \ | |
-DKDE_INSTALL_USE_QT_SYS_PATHS=on && \ | |
make -j8 && make install | |
# Add Camera support | |
ADD userland /opt/build/userland | |
RUN cd /opt/build/userland && ./buildme --aarch64 | |
FROM arm64v8/ubuntu:20.04 | |
COPY --from=qemu /qemu-aarch64-static /usr/bin/ | |
ENV TERM linux | |
ENV DEBIAN_FRONTEND noninteractive | |
RUN apt-get update && apt-get -y install wget curl apt-transport-https \ | |
software-properties-common && rm -rf /var/lib/apt/lists/* | |
RUN curl -fsSL https://forslund.github.io/mycroft-alternatives/conf/mycroft-alternatives.gpg.key | apt-key add - && echo "deb http://forslund.github.io/mycroft-alternatives focal main" > /etc/apt/sources.list.d/mycroft-alt.list | |
RUN apt-get update && apt-get -y --no-install-recommends install \ | |
sddm \ | |
xauth \ | |
kwin-wayland \ | |
konsole \ | |
plasma-workspace-wayland \ | |
plasma-pa \ | |
plasma-widgets-addons \ | |
libkf5wallet-bin \ | |
kscreen \ | |
gstreamer1.0-plugins-base \ | |
gstreamer1.0-plugins-good \ | |
gstreamer1.0-plugins-bad \ | |
gstreamer1.0-plugins-ugly \ | |
gstreamer1.0-libav \ | |
libqt5multimedia5-plugins \ | |
plasma-nano \ | |
qtvirtualkeyboard-plugin \ | |
librespot \ | |
mimic \ | |
pcre2-utils \ | |
portaudio19-dev \ | |
jq \ | |
mpg123 \ | |
libfann-dev \ | |
flac \ | |
breeze-icon-theme \ | |
python3 \ | |
python3-dev \ | |
python3-setuptools \ | |
libtool \ | |
libffi-dev \ | |
libssl-dev \ | |
plasma-nm \ | |
swig \ | |
screen \ | |
curl \ | |
wiringpi \ | |
i2c-tools \ | |
libqt5websockets5 \ | |
&& mv /usr/bin/plasmashell /usr/bin/plasmashell.bin \ | |
&& rm -rf /var/lib/apt/lists/* | |
ADD mycroft-core /opt/mycroft/ | |
RUN mkdir -p /opt/mycroft/.git | |
ADD .git/modules/mycroft-core /opt/mycroft/.git | |
RUN sed -i 's/worktree = ..\/..\/..\/mycroft-core/worktree = \/opt\/mycroft/' /opt/mycroft/.git/config | |
COPY --from=builder /usr/local/ /usr/ | |
COPY --from=builder /usr/lib/aarch64-linux-gnu/qt5/qml/ /usr/lib/aarch64-linux-gnu/qt5/qml/ | |
COPY --from=builder /opt/vc /opt/vc | |
# Install Server Dependencies for Mycroft | |
RUN set -x \ | |
&& sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list \ | |
&& apt-get update \ | |
&& apt-get -y --no-install-recommends install libpcre2-8-0 python3 python3-pip locales sudo pulseaudio \ | |
adduser udev libasound2 libasound2-dev alsa-utils mimic unzip \ | |
&& pip3 install future msm==0.8.8 spidev smbus2 RPi.GPIO \ | |
&& cd /opt/mycroft \ | |
&& mkdir /opt/mycroft/skills \ | |
&& CI=true /opt/mycroft/./dev_setup.sh --allow-root -sm \ | |
&& mkdir /opt/mycroft/scripts/logs \ | |
&& touch /opt/mycroft/scripts/logs/mycroft-bus.log \ | |
&& touch /opt/mycroft/scripts/logs/mycroft-voice.log \ | |
&& touch /opt/mycroft/scripts/logs/mycroft-skills.log \ | |
&& touch /opt/mycroft/scripts/logs/mycroft-audio.log \ | |
&& apt-get -y remove portaudio19-dev \ | |
&& apt-get -y autoremove \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |
ADD mycroft-devices/Mimic2-local-cache.zip /opt/mycroft/preloaded_cache/Mimic2-local-cache.zip | |
RUN unzip /opt/mycroft/preloaded_cache/Mimic2-local-cache.zip -d /opt/mycroft/preloaded_cache/Mimic2/ | |
# Set the locale | |
RUN locale-gen en_US.UTF-8 | |
ENV LANG en_US.UTF-8 | |
ENV LANGUAGE en_US:en | |
ENV LC_ALL en_US.UTF-8 | |
WORKDIR /opt/mycroft | |
ENV PYTHONPATH $PYTHONPATH:/mycroft/ai | |
RUN echo "PATH=$PATH:/opt/mycroft/bin" >> $HOME/.bashrc \ | |
&& echo "source /opt/mycroft/.venv/bin/activate" >> $HOME/.bashrc \ | |
&& echo "source /opt/mycroft/.camerarc" >> $HOME/.bashrc | |
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/mycroft/bin | |
ADD files / | |
RUN chmod +x /opt/mycroft/start-mycroft.sh && chmod +x /opt/mycroft/startup.sh && chmod +x /opt/mycroft/pairing.sh | |
RUN ln -s /etc/systemd/system/mycroft-xmos.service \ | |
/etc/systemd/system/multi-user.target.wants/ \ | |
&& rm -f /etc/systemd/system/timers.target.wants/apt-daily-upgrade.timer \ | |
&& rm -f /etc/systemd/system/timers.target.wants/apt-daily.timer \ | |
&& systemctl enable sddm \ | |
&& systemctl set-default graphical.target \ | |
&& systemctl disable systemd-networkd \ | |
&& systemctl disable network-manager \ | |
&& systemctl disable snapd \ | |
&& systemctl disable ModemManager \ | |
&& systemctl disable apt-daily.timer \ | |
&& systemctl disable apt-daily-upgrade.timer \ | |
&& systemctl disable wpa_supplicant | |
RUN sed -i 's/1/0/g' /etc/apt/apt.conf.d/20auto-upgrades | |
RUN echo -e '\n[keyfile]\nunmanaged-devices=interface-name:eth*;interface-name:wlan*;interface-name:lxcbr*' >> /etc/NetworkManager/NetworkManager.conf | |
RUN adduser --disabled-password --gecos "" --uid 1050 mycroft && c_rehash | |
RUN groupadd -f --system gpio | |
RUN groupadd -f --system i2c | |
RUN usermod -a -G gpio mycroft | |
RUN usermod -a -G i2c mycroft | |
RUN usermod -a -G video mycroft | |
RUN cp /opt/mycroft/asound-template /home/mycroft/.asoundrc && chown mycroft:mycroft /home/mycroft/.asoundrc | |
RUN mkdir -p /home/mycroft/.config/systemd/user/default.target.wants/ && chown -R mycroft:mycroft /home/mycroft/.config/ \ | |
&& ln -s /usr/lib/systemd/user/mycroft.service /home/mycroft/.config/systemd/user/default.target.wants/mycroft.service | |
RUN echo "PATH=$PATH:/opt/mycroft/bin" >> /home/mycroft/.bashrc && \ | |
echo "source /opt/mycroft/.venv/bin/activate" >> /home/mycroft/.bashrc && \ | |
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/vc/lib/" >> /home/mycroft/.bashrc | |
RUN mv /usr/share/alsa/pulse-alsa.conf /usr/share/alsa/pulse-alsa.conf.old | |
RUN git clone https://github.com/MycroftAI/skill-wifi-connect /opt/mycroft/skills/skill-wifi-connect | |
RUN chown root:root /etc/sudoers && chmod 0440 /etc/sudoers | |
RUN chown root:root /etc/sudoers.d && chmod -R 0440 /etc/sudoers.d | |
# TODO Remove after Skills have been released for 21.02 | |
RUN wget https://github.com/MycroftAI/skill-pairing/tarball/feature/mark-2-screens -O /opt/mycroft/skills/pairing-skill.tar.gz && \ | |
cd /opt/mycroft/skills/ && tar -xvzf pairing-skill.tar.gz && mv MycroftAI-skill-pairing-* mycroft-pairing.mycroftai && rm pairing-skill.tar.gz | |
RUN wget https://github.com/MycroftAI/mycroft-timer/tarball/20.08 -O /opt/mycroft/skills/timer-skill.tar.gz && \ | |
cd /opt/mycroft/skills/ && tar -xvzf timer-skill.tar.gz && mv MycroftAI-mycroft-timer-* mycroft-timer.mycroftai && \ | |
rm timer-skill.tar.gz | |
RUN /bin/bash -c 'source /root/.bashrc; mycroft-pip install -r /opt/mycroft/skills/mycroft-timer.mycroftai/requirements.txt;'; | |
RUN wget https://github.com/MycroftAI/skill-date-time/tarball/feature/build-date -O /opt/mycroft/skills/date-time-skill.tar.gz && \ | |
cd /opt/mycroft/skills/ && tar -xvzf date-time-skill.tar.gz && mv MycroftAI-skill-date-time-* mycroft-date-time.mycroftai && \ | |
rm date-time-skill.tar.gz | |
RUN /bin/bash -c 'source /root/.bashrc; mycroft-pip install -r /opt/mycroft/skills/mycroft-date-time.mycroftai/requirements.txt'; | |
RUN wget https://github.com/MycroftAI/skill-camera/tarball/20.08 -O /opt/mycroft/skills/skill-camera.tar.gz && \ | |
cd /opt/mycroft/skills/ && tar -xvzf skill-camera.tar.gz && mv MycroftAI-skill-camera-* skill-camera.aiix && \ | |
rm skill-camera.tar.gz | |
RUN apt-get update && apt-get -y install vlc-bin vlc-plugin-base | |
RUN /bin/bash -c 'source /root/.bashrc; msm -p mycroft_mark_2 default'; | |
# TODO Fix this workaround - some Python packages are being installed to an incorrect location | |
RUN cp -r /usr/local/lib/python3.8/dist-packages/* /opt/mycroft/.venv/lib/python3.8/site-packages/ | |
RUN chown -R mycroft:mycroft /opt/mycroft | |
# TODO remove in 21.02 when we've moved to MSM v0.9.x | |
RUN /bin/bash -c 'source /root/.bashrc; mycroft-pip install --no-cache --upgrade https://github.com/MycroftAI/mycroft-skills-manager/tarball/feature/no-confirm-install-v0.8.8;'; | |
# Add default Precise model | |
RUN mkdir -p /home/mycroft/.mycroft/precise/ | |
COPY precise-data/hey-mycroft.tar.gz /home/mycroft/.mycroft/precise/ | |
RUN cd /home/mycroft/.mycroft/precise/ && tar -xvzf hey-mycroft.tar.gz | |
# Add beta Precise model - # TODO remove when added to Selene | |
RUN cd /home/mycroft/.mycroft/precise && \ | |
wget https://github.com/MycroftAI/precise-data/raw/production_models/hey-mycroft-001/hey-mycroft_C1_E6000_B5000_D0.2_R20_S0.8.pb && \ | |
wget https://github.com/MycroftAI/precise-data/raw/production_models/hey-mycroft-001/hey-mycroft_C1_E6000_B5000_D0.2_R20_S0.8.pb.params | |
# Add Precise Engine binary | |
RUN wget https://github.com/MycroftAI/mycroft-precise/releases/download/v0.3.0/precise-engine_0.3.0_aarch64.tar.gz -O /home/mycroft/.mycroft/precise/precise-engine_0.3.0_aarch64.tar.gz && \ | |
cd /home/mycroft/.mycroft/precise/ && tar -xvzf precise-engine_0.3.0_aarch64.tar.gz && chown -R mycroft:mycroft /home/mycroft/ | |
RUN echo "mycroft - nice -20" >> /etc/security/limits.conf | |
ADD debs/libportaudio2_19.6.0_arm64_KenFix-NoPatch.deb /opt/ | |
RUN dpkg -i /opt/libportaudio2_19.6.0_arm64_KenFix-NoPatch.deb | |
COPY --chown=0:0 --from=registry.gitlab.com/pantacor/pantavisor-runtime/pvtoolbox:arm32v7-master /usr/local/bin/pvsocket /usr/local/bin/pvsocket | |
COPY --chown=0:0 --from=registry.gitlab.com/pantacor/pantavisor-runtime/pvtoolbox:arm32v7-master /usr/local/bin/pvlog /usr/local/bin/pvlog | |
COPY --chown=0:0 --from=registry.gitlab.com/pantacor/pantavisor-runtime/pvtoolbox:arm32v7-master /usr/local/bin/pvmeta /usr/local/bin/pvmeta | |
COPY --chown=0:0 --from=registry.gitlab.com/pantacor/pantavisor-runtime/pvtoolbox:arm32v7-master /usr/local/bin/pvreboot /usr/local/bin/pvreboot | |
COPY --chown=0:0 --from=registry.gitlab.com/pantacor/pantavisor-runtime/pvtoolbox:arm32v7-master /usr/local/bin/pvpoweroff /usr/local/bin/pvpoweroff | |
RUN chmod +x /usr/local/bin/pvsocket | |
RUN chmod +x /usr/local/bin/pvlog | |
RUN chmod +x /usr/local/bin/pvmeta | |
RUN chmod +x /usr/local/bin/pvreboot | |
RUN chmod +x /usr/local/bin/pvpoweroff | |
# TODO remove development tools for production release | |
RUN apt-get update && apt-get -y install nano | |
# Automatically log into the mycroft account | |
RUN echo "su -l mycroft" >> $HOME/.bashrc | |
# Store build info for Mark II Skill to show devs | |
RUN jq -n --arg datetime "$(date +%F) $(date +%T)" '{"build_date": $datetime}' > /etc/mycroft/build-info.json | |
CMD [ "/lib/systemd/systemd" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mycroft-devices is deprecated for official Mark II builds. Though I could certainly see community efforts continuing to create debos recipes for this type of scenario. Plenty of projects want more of a standard linux OS that has the dependencies baked in. So I could see mycroft-devices being renamed but continuing for that purpose.