]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
docker: add alpine,debian,ubuntu test images 909/head
authorVirtualTam <virtualtam@flibidi.net>
Tue, 30 May 2017 21:45:17 +0000 (23:45 +0200)
committerVirtualTam <virtualtam@flibidi.net>
Mon, 18 Sep 2017 19:13:59 +0000 (21:13 +0200)
Relates to https://github.com/shaarli/Shaarli/issues/843

Added:
- Makefile target to run commands in a Docker test context
- Docker images to run Shaarli test suites:
  - Alpine 3.6
  - Debian 8
  - Debian 9
  - Ubuntu 16.04
- Documentation

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Makefile
doc/md/Unit-tests-Docker.md [new file with mode: 0644]
docker/test/alpine36/Dockerfile [new file with mode: 0644]
docker/test/debian8/Dockerfile [new file with mode: 0644]
docker/test/debian9/Dockerfile [new file with mode: 0644]
docker/test/ubuntu16/Dockerfile [new file with mode: 0644]
mkdocs.yml

index 40badb1d916bfaa50c58ff08d3af2159872726d3..a3696ec987886657dfd2ecca1345575c4928c38c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,16 @@ PHP_COMMA_SOURCE = index.php,application,tests,plugins
 
 all: static_analysis_summary check_permissions test
 
+##
+# Docker test adapter
+#
+# Shaarli sources and vendored libraries are copied from a shared volume
+# to a user-owned directory to enable running tests as a non-root user.
+##
+docker_%:
+       rsync -az /shaarli/ ~/shaarli/
+       cd ~/shaarli && make $*
+
 ##
 # Concise status of the project
 # These targets are non-blocking: || exit 0
diff --git a/doc/md/Unit-tests-Docker.md b/doc/md/Unit-tests-Docker.md
new file mode 100644 (file)
index 0000000..c2de7cc
--- /dev/null
@@ -0,0 +1,56 @@
+## Running tests inside Docker containers
+
+Read first:
+
+- [Docker 101](docker/docker-101.md)
+- [Docker resources](docker/resources.md)
+- [Unit tests](Unit-tests.md)
+
+### Docker test images
+
+Test Dockerfiles are located under `docker/tests/<distribution>/Dockerfile`,
+and can be used to build Docker images to run Shaarli test suites under common
+Linux environments.
+
+Dockerfiles are provided for the following environments:
+
+- `alpine36` - [Alpine 3.6](https://www.alpinelinux.org/downloads/)
+- `debian8` - [Debian 8 Jessie](https://www.debian.org/DebianJessie) (oldstable)
+- `debian9` - [Debian 9 Stretch](https://wiki.debian.org/DebianStretch) (stable)
+- `ubuntu16` - [Ubuntu 16.04 Xenial Xerus](http://releases.ubuntu.com/16.04/) (LTS)
+
+What's behind the curtains:
+
+- each image provides:
+    - a base Linux OS
+    - Shaarli PHP dependencies (OS packages)
+    - test PHP dependencies (OS packages)
+    - Composer
+- the local workspace is mapped to the container's `/shaarli/` directory,
+- the files are rsync'd to so tests are run using a standard Linux user account
+  (running tests as `root` would bypass permission checks and may hide issues)
+- the tests are run inside the container.
+
+### Building test images
+
+```bash
+# build the Debian 9 Docker image
+$ cd /path/to/shaarli
+$ cd docker/test/debian9
+$ docker build -t shaarli-test:debian9 .
+```
+
+### Running tests
+
+```bash
+$ cd /path/to/shaarli
+
+# install/update 3rd-party test dependencies
+$ composer install --prefer-dist
+
+# run tests using the freshly built image
+$ docker run -v $PWD:/shaarli shaarli-test:debian9 docker_test
+
+# run the full test campaign
+$ docker run -v $PWD:/shaarli shaarli-test:debian9 docker_all_tests
+```
diff --git a/docker/test/alpine36/Dockerfile b/docker/test/alpine36/Dockerfile
new file mode 100644 (file)
index 0000000..fa84f6e
--- /dev/null
@@ -0,0 +1,34 @@
+FROM alpine:3.6
+MAINTAINER Shaarli Community
+
+RUN apk --update --no-cache add \
+        ca-certificates \
+        curl \
+        make \
+        php7 \
+        php7-ctype \
+        php7-curl \
+        php7-dom \
+        php7-gd \
+        php7-iconv \
+        php7-intl \
+        php7-json \
+        php7-mbstring \
+        php7-openssl \
+        php7-phar \
+        php7-session \
+        php7-simplexml \
+        php7-tokenizer \
+        php7-xdebug \
+        php7-xml \
+        php7-zlib \
+        rsync
+
+RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
+
+RUN mkdir /shaarli
+WORKDIR /shaarli
+VOLUME /shaarli
+
+ENTRYPOINT ["make"]
+CMD []
diff --git a/docker/test/debian8/Dockerfile b/docker/test/debian8/Dockerfile
new file mode 100644 (file)
index 0000000..eaa34e9
--- /dev/null
@@ -0,0 +1,35 @@
+FROM debian:jessie
+MAINTAINER Shaarli Community
+
+ENV TERM dumb
+ENV DEBIAN_FRONTEND noninteractive
+ENV LANG en_US.UTF-8
+ENV LANGUAGE en_US:en
+
+RUN apt-get update \
+    && apt-get install --no-install-recommends -y \
+       ca-certificates \
+       curl \
+       locales \
+       make \
+       php5 \
+       php5-curl \
+       php5-gd \
+       php5-intl \
+       php5-xdebug \
+       rsync \
+    && apt-get clean
+
+RUN locale-gen en_US.UTF-8 \
+    && locale-gen de_DE.UTF-8 \
+    && locale-gen fr_FR.UTF-8
+
+ADD https://getcomposer.org/composer.phar /usr/local/bin/composer
+RUN chmod 755 /usr/local/bin/composer
+
+RUN mkdir /shaarli
+WORKDIR /shaarli
+VOLUME /shaarli
+
+ENTRYPOINT ["make"]
+CMD []
diff --git a/docker/test/debian9/Dockerfile b/docker/test/debian9/Dockerfile
new file mode 100644 (file)
index 0000000..3ab4b93
--- /dev/null
@@ -0,0 +1,36 @@
+FROM debian:stretch
+MAINTAINER Shaarli Community
+
+ENV TERM dumb
+ENV DEBIAN_FRONTEND noninteractive
+ENV LANG en_US.UTF-8
+ENV LANGUAGE en_US:en
+
+RUN apt-get update \
+    && apt-get install --no-install-recommends -y \
+       ca-certificates \
+       curl \
+       locales \
+       make \
+       php7.0 \
+       php7.0-curl \
+       php7.0-gd \
+       php7.0-intl \
+       php7.0-xml \
+       php-xdebug \
+       rsync \
+    && apt-get clean
+
+RUN locale-gen en_US.UTF-8 \
+    && locale-gen de_DE.UTF-8 \
+    && locale-gen fr_FR.UTF-8
+
+ADD https://getcomposer.org/composer.phar /usr/local/bin/composer
+RUN chmod 755 /usr/local/bin/composer
+
+RUN mkdir /shaarli
+WORKDIR /shaarli
+VOLUME /shaarli
+
+ENTRYPOINT ["make"]
+CMD []
diff --git a/docker/test/ubuntu16/Dockerfile b/docker/test/ubuntu16/Dockerfile
new file mode 100644 (file)
index 0000000..e53ed9e
--- /dev/null
@@ -0,0 +1,36 @@
+FROM ubuntu:16.04
+MAINTAINER Shaarli Community
+
+ENV TERM dumb
+ENV DEBIAN_FRONTEND noninteractive
+ENV LANG en_US.UTF-8
+ENV LANGUAGE en_US:en
+
+RUN apt-get update \
+    && apt-get install --no-install-recommends -y \
+       ca-certificates \
+       curl \
+       language-pack-de \
+       language-pack-en \
+       language-pack-fr \
+       locales \
+       make \
+       php7.0 \
+       php7.0-curl \
+       php7.0-gd \
+       php7.0-intl \
+       php7.0-xml \
+       php-xdebug \
+       rsync \
+    && apt-get clean
+
+ADD https://getcomposer.org/composer.phar /usr/local/bin/composer
+RUN chmod 755 /usr/local/bin/composer
+
+RUN useradd -m dev \
+    && mkdir /shaarli
+USER dev
+WORKDIR /shaarli
+
+ENTRYPOINT ["make"]
+CMD []
index 648d8f67b473ac75fa430108d04c4c9b2c624180..03a7a34e80e3f448e1e8bbffec77cbd76490dc29 100644 (file)
@@ -45,6 +45,7 @@ pages:
     - Static analysis: Static-analysis.md
     - Theming: Theming.md
     - Unit tests: Unit-tests.md
+    - Unit tests inside Docker: Unit-tests-Docker.md
 - About:
     - FAQ: FAQ.md
     - Community & Related software: Community-&-Related-software.md