Commit 5a6740e7feb653a07e6528b808edc5757ac27130

Patrick Steinhardt 2019-08-02T09:58:55

azure: build Docker images as part of the pipeline The Docker images used for our continuous integration builds currently live in the libgit2/libgit2-docker repository. To make any changes in them, one has to make a PR there, get it reviewed, re-build the images and publish them to Docker Hub. This process is slow and tedious, making it harder than necessary to perform any updates to our Docker-based build pipeline. To fix this, we include all Dockerfiles used by Azure from the mentioned repository and inline them into our own repo. Instead of having to manually push them to the CI, it will now build the required containers on each pull request, allowing much greater flexibility.

diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index dda7ad5..231981d 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -13,7 +13,9 @@ jobs:
   steps:
   - template: azure-pipelines/docker.yml
     parameters:
-      imageName: 'libgit2/trusty-amd64:latest'
+      docker:
+        image: trusty
+        base: ubuntu:trusty
       environmentVariables: |
        CC=gcc
        CMAKE_GENERATOR=Unix Makefiles
@@ -26,7 +28,9 @@ jobs:
   steps:
   - template: azure-pipelines/docker.yml
     parameters:
-      imageName: 'libgit2/trusty-amd64:latest'
+      docker:
+        image: trusty
+        base: ubuntu:trusty
       environmentVariables: |
        CC=gcc
        CMAKE_GENERATOR=Unix Makefiles
@@ -39,7 +43,9 @@ jobs:
   steps:
   - template: azure-pipelines/docker.yml
     parameters:
-      imageName: 'libgit2/trusty-amd64:latest'
+      docker:
+        image: trusty
+        base: ubuntu:trusty
       environmentVariables: |
        CC=clang
        CMAKE_GENERATOR=Unix Makefiles
@@ -52,7 +58,9 @@ jobs:
   steps:
   - template: azure-pipelines/docker.yml
     parameters:
-      imageName: 'libgit2/trusty-amd64:latest'
+      docker:
+        image: trusty
+        base: ubuntu:trusty
       environmentVariables: |
        CC=clang
        CMAKE_GENERATOR=Unix Makefiles
@@ -137,6 +145,10 @@ jobs:
     vmImage: 'Ubuntu 16.04'
   steps:
   - script: |
+      cd $(Build.SourcesDirectory)/azure-pipelines/docker
+      docker build -t libgit2/docurium --build-arg BASE=ubuntu:trusty -f docurium .
+    displayName: 'Build Docker image'
+  - script: |
       git config user.name 'Documentation Generation'
       git config user.email 'libgit2@users.noreply.github.com'
       git branch gh-pages origin/gh-pages
diff --git a/azure-pipelines/docker.yml b/azure-pipelines/docker.yml
index 2bbe686..ce1e73d 100644
--- a/azure-pipelines/docker.yml
+++ b/azure-pipelines/docker.yml
@@ -4,11 +4,15 @@ steps:
   - script: docker run --rm --privileged multiarch/qemu-user-static:register --reset
     displayName: 'Register Docker QEMU'
 
+- script: |
+    cd $(Build.SourcesDirectory)/azure-pipelines/docker
+    docker build -t libgit2/${{parameters.docker.image}} --build-arg BASE=${{parameters.docker.base}} -f ${{parameters.docker.image}} .
+  displayName: 'Build Docker image'
 - task: docker@0
   displayName: Build
   inputs:
     action: 'Run an image'
-    imageName: ${{ parameters.imageName }}
+    imageName: libgit2/${{ parameters.docker.image }}
     volumes: |
      $(Build.SourcesDirectory):/src
      $(Build.BinariesDirectory):/build
@@ -20,7 +24,7 @@ steps:
   displayName: Test
   inputs:
     action: 'Run an image'
-    imageName: ${{ parameters.imageName }}
+    imageName: libgit2/${{ parameters.docker.image }}
     volumes: |
      $(Build.SourcesDirectory):/src
      $(Build.BinariesDirectory):/build
diff --git a/azure-pipelines/docker/bionic b/azure-pipelines/docker/bionic
new file mode 100644
index 0000000..7cd906b
--- /dev/null
+++ b/azure-pipelines/docker/bionic
@@ -0,0 +1,7 @@
+ARG BASE
+FROM $BASE
+ARG CACHEBUST=1
+RUN apt-get update
+RUN apt-get -y install pkgconf clang git cmake curl libssl-dev libcurl4 libcurl4-openssl-dev libssh2-1-dev libz-dev valgrind openssh-client openssh-server
+RUN if [ "$ARCH" != "armhf" -a "$ARCH" != "arm64" ]; then apt-get -y install openjdk-11-jre-headless; fi
+RUN mkdir /var/run/sshd
diff --git a/azure-pipelines/docker/docurium b/azure-pipelines/docker/docurium
new file mode 100644
index 0000000..15d10a7
--- /dev/null
+++ b/azure-pipelines/docker/docurium
@@ -0,0 +1,6 @@
+FROM debian:jessie-slim
+ARG CACHEBUST=1
+RUN apt-get update
+RUN apt install -y cmake pkg-config ruby ruby-dev llvm libclang-3.5-dev libssl-dev python-pygments
+ARG CACHEBUST=1
+RUN gem install docurium
diff --git a/azure-pipelines/docker/trusty b/azure-pipelines/docker/trusty
new file mode 100644
index 0000000..67e6ec1
--- /dev/null
+++ b/azure-pipelines/docker/trusty
@@ -0,0 +1,20 @@
+ARG BASE
+FROM $BASE
+ARG CACHEBUST=1
+
+RUN apt-get update
+RUN apt-get install -y curl apt-transport-https software-properties-common
+RUN curl -sSL "https://bintray.com/user/downloadSubjectPublicKey?username=bintray" | apt-key add -
+RUN echo "deb https://dl.bintray.com/libgit2/ci-dependencies trusty libgit2deps" >> /etc/apt/sources.list
+RUN add-apt-repository ppa:openjdk-r/ppa -y
+RUN apt-get update
+RUN apt-get -y install clang git cmake libssl-dev libcurl3 libcurl3-gnutls libcurl4-gnutls-dev libssh2-1-dev valgrind openssh-client openssh-server openjdk-8-jre libpcre3 libpcre3-dev
+
+RUN git clone --branch mbedtls-2.6.1 https://github.com/ARMmbed/mbedtls.git /tmp/mbedtls
+RUN (cd /tmp/mbedtls && scripts/config.pl set MBEDTLS_MD4_C 1)
+RUN (cd /tmp/mbedtls && CFLAGS=-fPIC cmake -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DUSE_STATIC_MBEDTLS_LIBRARY=ON .)
+RUN (cd /tmp/mbedtls && cmake --build .)
+RUN (cd /tmp/mbedtls && make install)
+RUN rm -rf /tmp/mbedtls
+
+RUN mkdir /var/run/sshd
diff --git a/azure-pipelines/docker/xenial b/azure-pipelines/docker/xenial
new file mode 100644
index 0000000..f82f272
--- /dev/null
+++ b/azure-pipelines/docker/xenial
@@ -0,0 +1,6 @@
+ARG BASE
+FROM $BASE
+ARG CACHEBUST=1
+RUN apt-get update
+RUN apt-get -y install pkgconf clang git cmake curl libssl-dev libcurl3 libcurl3-gnutls libcurl4-gnutls-dev valgrind openssh-client openssh-server openjdk-8-jre
+RUN mkdir /var/run/sshd
diff --git a/azure-pipelines/nightly.yml b/azure-pipelines/nightly.yml
index 96cc3e5..8bcccd7 100644
--- a/azure-pipelines/nightly.yml
+++ b/azure-pipelines/nightly.yml
@@ -9,7 +9,9 @@ jobs:
   steps:
   - template: docker.yml
     parameters:
-      imageName: 'libgit2/trusty-amd64:latest'
+      docker:
+        image: trusty
+        base: ubuntu:trusty
       environmentVariables: |
        CC=gcc
        CMAKE_GENERATOR=Unix Makefiles
@@ -23,7 +25,9 @@ jobs:
   steps:
   - template: docker.yml
     parameters:
-      imageName: 'libgit2/trusty-amd64:latest'
+      docker:
+        image: trusty
+        base: ubuntu:trusty
       environmentVariables: |
        CC=gcc
        CMAKE_GENERATOR=Unix Makefiles
@@ -37,7 +41,9 @@ jobs:
   steps:
   - template: docker.yml
     parameters:
-      imageName: 'libgit2/trusty-amd64:latest'
+      docker:
+        image: trusty
+        base: ubuntu:trusty
       environmentVariables: |
        CC=clang
        CMAKE_GENERATOR=Unix Makefiles
@@ -51,7 +57,9 @@ jobs:
   steps:
   - template: docker.yml
     parameters:
-      imageName: 'libgit2/trusty-amd64:latest'
+      docker:
+        image: trusty
+        base: ubuntu:trusty
       environmentVariables: |
        CC=clang
        CMAKE_GENERATOR=Unix Makefiles
@@ -144,7 +152,9 @@ jobs:
   - template: docker.yml
     parameters:
       qemu: 'true'
-      imageName: 'libgit2/bionic-x86:latest'
+      docker:
+        image: bionic
+        base: multiarch/ubuntu-core:x86-bionic
       environmentVariables: |
        CC=gcc
        CMAKE_GENERATOR=Unix Makefiles
@@ -159,7 +169,9 @@ jobs:
   - template: docker.yml
     parameters:
       qemu: 'true'
-      imageName: 'libgit2/bionic-x86:latest'
+      docker:
+        image: bionic
+        base: multiarch/ubuntu-core:x86-bionic
       environmentVariables: |
        CC=clang
        CMAKE_GENERATOR=Unix Makefiles
@@ -174,7 +186,9 @@ jobs:
   - template: docker.yml
     parameters:
       qemu: 'true'
-      imageName: 'libgit2/bionic-arm32:latest'
+      docker:
+        image: bionic
+        base: multiarch/ubuntu-core:armhf-bionic
       environmentVariables: |
        CC=gcc
        CMAKE_GENERATOR=Unix Makefiles
@@ -190,7 +204,9 @@ jobs:
   - template: docker.yml
     parameters:
       qemu: 'true'
-      imageName: 'libgit2/bionic-arm64:latest'
+      docker:
+        image: bionic
+        base: multiarch/ubuntu-core:arm64-bionic
       environmentVariables: |
        CC=gcc
        CMAKE_GENERATOR=Unix Makefiles