Эх сурвалжийг харах

add debian 8 to the docker CI chain

nico 8 жил өмнө
parent
commit
549b1a63fc

+ 4 - 1
.travis.yml

@@ -8,7 +8,8 @@ python:
 
 # command to install dependencies
 before_install:
-- docker build --force-rm=true --build-arg branch=$TRAVIS_BRANCH -t kalliope-ubuntu1604 -f docker/ubuntu_16_04.dockerfile .
+- docker build --force-rm=true --build-arg TRAVIS_BRANCH=${TRAVIS_BRANCH} --build-arg TRAVIS_EVENT_TYPE=${TRAVIS_EVENT_TYPE} --build-arg TRAVIS_PULL_REQUEST_SLUG=${TRAVIS_PULL_REQUEST_SLUG} --build-arg TRAVIS_PULL_REQUEST_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH} -t kalliope-ubuntu1604 -f docker/ubuntu_16_04.dockerfile .
+- docker build --force-rm=true --build-arg TRAVIS_BRANCH=${TRAVIS_BRANCH} --build-arg TRAVIS_EVENT_TYPE=${TRAVIS_EVENT_TYPE} --build-arg TRAVIS_PULL_REQUEST_SLUG=${TRAVIS_PULL_REQUEST_SLUG} --build-arg TRAVIS_PULL_REQUEST_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH} -t kalliope-debian8 -f docker/debian8.dockerfile .
 - sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse"
 - sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse"
 - sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse"
@@ -24,3 +25,5 @@ install: "pip install -r install/files/python_requirements.txt"
 script:
   - pytest
   - docker run -it --rm kalliope-ubuntu1604
+  - docker run -it --rm kalliope-debian8
+

+ 36 - 0
docker/clone_and_test.sh

@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+# get travis env
+echo "TRAVIS_EVENT_TYPE: ${TRAVIS_EVENT_TYPE}"
+echo "TRAVIS_BRANCH: ${TRAVIS_BRANCH}"
+echo "TRAVIS_PULL_REQUEST_SLUG: ${TRAVIS_PULL_REQUEST_SLUG}"
+echo "TRAVIS_PULL_REQUEST_BRANCH: ${TRAVIS_PULL_REQUEST_BRANCH}"
+
+# set default variable if not in env
+if [ -z ${TRAVIS_EVENT_TYPE} ]; then
+TRAVIS_EVENT_TYPE="push";
+echo "TRAVIS_EVENT_TYPE set to push";
+fi
+
+if [ -z ${TRAVIS_BRANCH} ]; then
+TRAVIS_BRANCH="master";
+echo "TRAVIS_BRANCH set to master";
+fi
+
+# check if this is a pull request or a push
+if [ ${TRAVIS_EVENT_TYPE} == "pull_request" ]; then
+    git clone https://github.com/${TRAVIS_PULL_REQUEST_SLUG} kalliope;
+    cd kalliope;
+    git checkout ${TRAVIS_PULL_REQUEST_BRANCH};
+else
+    # it's a push
+    git clone https://github.com/kalliope-project/kalliope.git kalliope;
+    cd kalliope;
+    git checkout ${TRAVIS_BRANCH};
+fi
+
+# install
+sudo python setup.py install
+
+# tests
+python -m unittest discover

+ 41 - 0
docker/debian8.dockerfile

@@ -0,0 +1,41 @@
+FROM debian:8
+
+ENV no_proxy="127.0.0.1,localhost,kalliope.fr"
+
+# Need some packages in non-free repo
+RUN sed -i -- 's/jessie main/jessie main contrib non-free/g' /etc/apt/sources.list
+
+# install packages
+RUN apt-get update && apt-get install -y \
+    git python-dev libsmpeg0 libttspico-utils libsmpeg0 \
+    flac dialog portaudio19-dev build-essential libssl-dev \
+    libffi-dev sox libatlas3-base mplayer wget vim sudo\
+    && rm -rf /var/lib/apt/lists/*
+
+# Install the last PIP
+RUN wget https://bootstrap.pypa.io/get-pip.py
+RUN python get-pip.py
+
+# add a standart user. tests must not be ran as root
+RUN useradd -m -u 1000 tester
+RUN usermod -aG sudo tester
+RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
+
+# get TRAVIS environment variables
+ARG TRAVIS_BRANCH
+ARG TRAVIS_EVENT_TYPE
+ARG TRAVIS_PULL_REQUEST_SLUG
+ARG TRAVIS_PULL_REQUEST_BRANCH
+ENV TRAVIS_BRANCH=${TRAVIS_BRANCH}
+ENV TRAVIS_EVENT_TYPE=${TRAVIS_EVENT_TYPE}
+ENV TRAVIS_PULL_REQUEST_SLUG=${TRAVIS_PULL_REQUEST_SLUG}
+ENV TRAVIS_PULL_REQUEST_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH}
+
+ADD docker/clone_and_test.sh /home/tester/clone_and_test.sh
+RUN chown tester /home/tester/clone_and_test.sh
+
+USER tester
+WORKDIR /home/tester
+
+# run tests
+CMD ./clone_and_test.sh

+ 37 - 6
docker/docker.md

@@ -2,19 +2,50 @@
 
 ## Create images
 
-Build the image for Ubuntu 16.04.
+### Ubuntu 16.04
+Build the image for Ubuntu 16.04. By default, the master branch of the Kalliope project will be cloned.
 ```
-docker build --force-rm=true -t kalliope-app -f docker/ubuntu_16_04.dockerfile .
+docker build --force-rm=true -t kalliope-ubuntu1604 -f docker/ubuntu_16_04.dockerfile .
 ```
 
-If we want a specific branch of Kalliope
+To build with TRAVIS env we need to send global variables
 ```
-docker build --force-rm=true --build-arg branch=dev -t kalliope-app -f ubuntu_16_04.dockerfile .
+docker build \
+--force-rm=true \
+--build-arg TRAVIS_BRANCH=${TRAVIS_BRANCH} \
+--build-arg TRAVIS_EVENT_TYPE=${TRAVIS_EVENT_TYPE} \
+--build-arg TRAVIS_PULL_REQUEST_SLUG=${TRAVIS_PULL_REQUEST_SLUG} \
+--build-arg TRAVIS_PULL_REQUEST_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH} \
+-t kalliope-ubuntu1604 \
+-f docker/ubuntu_16_04.dockerfile .
+```
+
+### Debian Jessie
+Build the image for Debian Jessie. By default, the master branch of the Kalliope project will be cloned.
+```
+docker build --force-rm=true -t kalliope-debian8 -f docker/debian8.dockerfile .
+```
+
+To build with TRAVIS env we need to send global variables
+```
+docker build \
+--force-rm=true \
+--build-arg TRAVIS_BRANCH=${TRAVIS_BRANCH} \
+--build-arg TRAVIS_EVENT_TYPE=${TRAVIS_EVENT_TYPE} \
+--build-arg TRAVIS_PULL_REQUEST_SLUG=${TRAVIS_PULL_REQUEST_SLUG} \
+--build-arg TRAVIS_PULL_REQUEST_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH} \
+-t kalliope-debian8 \
+-f docker/debian8.dockerfile .
 ```
 
 ## Run the test
 
 Ubuntu image
 ```
-docker run -it --rm kalliope-app
-```
+docker run -it --rm kalliope-ubuntu1604
+```
+
+Debian image
+```
+docker run -it --rm kalliope-debian8
+```

+ 18 - 9
docker/ubuntu_16_04.dockerfile

@@ -9,7 +9,7 @@ RUN echo "deb http://us.archive.ubuntu.com/ubuntu/ xenial multiverse" >> /etc/ap
 RUN apt-get update && apt-get install -y \
     git python-dev libsmpeg0 libttspico-utils libsmpeg0 flac dialog \
     libffi-dev libffi-dev libssl-dev portaudio19-dev build-essential \
-    sox libatlas3-base mplayer wget vim\
+    sox libatlas3-base mplayer wget vim sudo\
     && rm -rf /var/lib/apt/lists/*
 
 # Install the last PIP
@@ -18,15 +18,24 @@ RUN python get-pip.py
 
 # add a standart user. tests must not be ran as root
 RUN useradd -m -u 1000 tester
-
-# by default we get the master branch. We can override this by adding
-ARG branch=master
-RUN cd /home/tester && git clone https://github.com/kalliope-project/kalliope.git
-RUN cd /home/tester/kalliope && git checkout ${branch} && python setup.py install
-RUN chown -R tester:tester /home/tester/kalliope
+RUN usermod -aG sudo tester
+RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
+
+# get TRAVIS environment variables
+ARG TRAVIS_BRANCH
+ARG TRAVIS_EVENT_TYPE
+ARG TRAVIS_PULL_REQUEST_SLUG
+ARG TRAVIS_PULL_REQUEST_BRANCH
+ENV TRAVIS_BRANCH=${TRAVIS_BRANCH}
+ENV TRAVIS_EVENT_TYPE=${TRAVIS_EVENT_TYPE}
+ENV TRAVIS_PULL_REQUEST_SLUG=${TRAVIS_PULL_REQUEST_SLUG}
+ENV TRAVIS_PULL_REQUEST_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH}
+
+ADD docker/clone_and_test.sh /home/tester/clone_and_test.sh
+RUN chown tester /home/tester/clone_and_test.sh
 
 USER tester
-WORKDIR /home/tester/kalliope
+WORKDIR /home/tester
 
 # run tests
-CMD ["python", "-m", "unittest", "discover"]
+CMD ./clone_and_test.sh