Skip to content
78 changes: 45 additions & 33 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,60 @@
FROM ubuntu:18.04

# simulate keyboard input during install wizard
# y: use master branch
# n: automatically update on Mycroft launch
# y: add helper commands to PATH
# n: check code style when submitting
ARG WIZARD_SEQUENCE=ynyn
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While clever, this is very fragile. I feel anything limiting properly automating this setup should be added to the setup script (more env vars or flags, probably), and not hacked around like this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely agree. The approach is really contrived. But being an outsider to the project I was trying to modify as little as possible.

Should I split WIZARD_SEQUENCE buildarg into 4 buildargs? For instance:

  • BRANCH
  • AUTO_UPDATE
  • ADD_HELPERS
  • CHECK_CODE

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I forgot to reply to this, sorry.

Well, above all, the official installer needs to be changed to accept these kind of things as environment variables so that this can be done cleanly in a way that won't break in the future.


ENV TERM linux
ENV DEBIAN_FRONTEND noninteractive

# Install Server Dependencies for Mycroft
RUN set -x \
&& sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list \
&& apt-get update \
&& apt-get -y install git python3 python3-pip locales sudo \
&& pip3 install future msm \
# Checkout Mycroft
&& git clone https://github.com/MycroftAI/mycroft-core.git /opt/mycroft \
&& cd /opt/mycroft \
&& mkdir /opt/mycroft/skills \
# git fetch && git checkout dev && \ this branch is now merged to master
&& 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 autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN curl https://forslund.github.io/mycroft-desktop-repo/mycroft-desktop.gpg.key | apt-key add - 2> /dev/null && \
echo "deb http://forslund.github.io/mycroft-desktop-repo bionic main" > /etc/apt/sources.list.d/mycroft-desktop.list
RUN apt-get update && apt-get install -y mimic
RUN set -x

# Install system packages required by Mycroft
RUN apt-get update \
&& sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list \
&& apt-get -y install sudo locales curl git python3 python3-pip \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN curl https://forslund.github.io/mycroft-desktop-repo/mycroft-desktop.gpg.key | apt-key add - 2> /dev/null
RUN echo "deb http://forslund.github.io/mycroft-desktop-repo bionic main" > /etc/apt/sources.list.d/mycroft-desktop.list
RUN apt-get update \
&& apt-get -y install mimic \
&& apt-get clean

# Install python packages
RUN pip3 install future msm

# 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
COPY startup.sh /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

RUN chmod +x /opt/mycroft/start-mycroft.sh \
&& chmod +x /opt/mycroft/startup.sh
# Clone and checkout Mycroft repository
WORKDIR /opt/mycroft
RUN git clone https://github.com/MycroftAI/mycroft-core.git .

# Install using wizard
# ynyn: see WIZARD_SEQUENCE build-arg
# -sm: skip building mimic locally
# --allow-root:
RUN echo $WIZARD_SEQUENCE | ./dev_setup.sh --allow-root -sm
RUN mkdir scripts/logs
RUN touch scripts/logs/mycroft-bus.log
RUN touch scripts/logs/mycroft-voice.log
RUN touch scripts/logs/mycroft-skills.log
RUN touch scripts/logs/mycroft-audio.log
COPY startup.sh .
RUN chmod +x ./startup.sh

RUN echo -e "\
PATH=$PATH:/opt/mycroft/bin \n\
source /opt/mycroft/.venv/bin/activate \n\
" >> $HOME/.bashrc

EXPOSE 8181

Expand Down