Update docker build

Docker build will now perform most actions of the dev-setup making it
possible to use caches in a greater extent speeding up the build
pull/2506/head
Chris Veilleux 2020-02-13 11:43:03 +01:00 committed by Åke Forslund
parent b436e5575a
commit 00acf2b10c
2 changed files with 74 additions and 19 deletions

2
Jenkinsfile vendored
View File

@ -28,7 +28,7 @@ pipeline {
steps {
echo 'Building Test Docker Image'
sh 'cp test/Dockerfile.test Dockerfile'
sh 'docker build --no-cache --target voight_kampff -t mycroft-core:${BRANCH_ALIAS} .'
sh 'docker build --target voight_kampff -t mycroft-core:${BRANCH_ALIAS} .'
echo 'Running Tests'
timeout(time: 10, unit: 'MINUTES')
{

View File

@ -1,40 +1,95 @@
# Build an Ubuntu-based container to run Mycroft
#
# The steps in this build are ordered from least likely to change to most
# likely to change. The intent behind this is to reduce build time so things
# like Jenkins jobs don't spend a lot of time re-building things that did not
# change from one build to the next.
#
FROM ubuntu:18.04 as builder
ENV TERM linux
ENV DEBIAN_FRONTEND noninteractive
COPY . /opt/mycroft/mycroft-core
# Un-comment any package sources that include a multiverse
RUN sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list
# Install Server Dependencies for Mycroft
RUN set -x \
# Un-comment any package sources that include a multiverse
&& sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list \
&& apt-get update \
# Install packages specific to Docker implementation
&& apt-get -y install locales sudo\
&& mkdir /opt/mycroft/skills \
&& CI=true bash -x /opt/mycroft/mycroft-core/dev_setup.sh --allow-root -sm \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN apt-get update && apt-get install -y \
autoconf \
automake \
bison \
build-essential \
curl \
flac \
git \
jq \
libfann-dev \
libffi-dev \
libicu-dev \
libjpeg-dev \
libglib2.0-dev \
libssl-dev \
libtool \
locales \
mpg123 \
pkg-config \
portaudio19-dev \
pulseaudio \
pulseaudio-utils \
python3 \
python3-dev \
python3-pip \
python3-setuptools \
python3-venv \
screen \
sudo \
swig \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# 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
# Add the local configuration directory
RUN mkdir ~/.mycroft
VOLUME /root/.mycroft
# Setup the virtual environment
# This may not be the most efficient way to do this in terms of number of
# steps, but it is built to take advantage of Docker's caching mechanism
# to only rebuild things that have changed since the last build.
RUN mkdir /opt/mycroft
RUN mkdir /var/log/mycroft
WORKDIR /opt/mycroft
RUN mkdir mycroft-core skills ~/.mycroft
RUN python3 -m venv "/opt/mycroft/mycroft-core/.venv"
RUN mycroft-core/.venv/bin/python -m pip install pip==20.0.2
COPY requirements.txt mycroft-core
RUN mycroft-core/.venv/bin/python -m pip install -r mycroft-core/requirements.txt
COPY . mycroft-core
EXPOSE 8181
# Integration Test Suite
#
# Build against this target to set the container up as an executable that
# will run the "voight_kampff" integration test suite.
#
FROM builder as voight_kampff
# Add the mycroft core virtual environment to the system path.
ENV PATH /opt/mycroft/mycroft-core/.venv/bin:$PATH
WORKDIR /opt/mycroft/mycroft-core/test/integrationtests/voight_kampff
# Install required packages for test environments
RUN mycroft-core/.venv/bin/python -m pip install -r mycroft-core/test-requirements.txt
RUN mycroft-core/.venv/bin/python -m pip install --no-deps /opt/mycroft/mycroft-core
RUN mkdir ~/.mycroft/allure-result
# Install Mark I default skills
RUN msm -p mycroft_mark_1 default
# The behave feature files for a skill are defined within the skill's
# repository. Copy those files into the local feature file directory
# for test discovery.
RUN python -m test.integrationtests.voight_kampff.test_setup -c default.yml
RUN mkdir ~/.mycroft/allure-result
WORKDIR /opt/mycroft/mycroft-core
# Generate hash of required packages
RUN md5sum requirements.txt test-requirements.txt dev_setup.sh > .installed
RUN python -m test.integrationtests.voight_kampff.test_setup -c test/integrationtests/voight_kampff/default.yml
# Setup and run the integration tests
WORKDIR /opt/mycroft/mycroft-core/test/integrationtests/voight_kampff
ENTRYPOINT "./run_test_suite.sh"