summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml47
-rwxr-xr-x.gitlab/build.sh24
-rw-r--r--docker/android-emulator/Dockerfile (renamed from docker/android-emulator.dockerfile)0
-rw-r--r--docker/android-ndk/Dockerfile (renamed from docker/android-ndk.dockerfile)0
-rw-r--r--docker/android-sdk/Dockerfile (renamed from docker/android-sdk.dockerfile)0
5 files changed, 66 insertions, 5 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6f8f92c8..a9e43504 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,15 +1,52 @@
-image: "0xacab.org:4567/leap/bitmask_android/android-ndk:latest"
-
+---
stages:
+ - docker_image_sdk
+ - docker_image_other
- build
-before_script:
- - git submodule sync --recursive
- - git submodule update --init --recursive
+# When using dind, it's wise to use the overlayfs driver for
+# improved performance.
+variables:
+ DOCKER_DRIVER: overlay
+
+.job_template: &build_docker_image
+ image: 0xacab.org:4567/leap/docker/debian:stretch_amd64
+ tags:
+ - docker-in-docker
+ services:
+ - docker:dind
+ script:
+ - docker --version
+ - docker info
+ - >
+ export LAST_COMMIT=$(curl -s --header "PRIVATE-TOKEN: ${LEAP_CODE_O_MATIC_PRIVATE_TOKEN}" https://0xacab.org/api/v4/projects/578/pipelines |
+ python -c "import sys, json; print json.load(sys.stdin)[1]['sha']")
+ - .gitlab/build.sh ${DOCKER_IMAGE}
+
+docker_image:sdk:
+ stage: docker_image_sdk
+ variables:
+ DOCKER_IMAGE: android-sdk
+ <<: *build_docker_image
+
+docker_image:ndk:
+ stage: docker_image_other
+ variables:
+ DOCKER_IMAGE: android-ndk
+ <<: *build_docker_image
+
+docker_image:emulator:
+ stage: docker_image_other
+ variables:
+ DOCKER_IMAGE: android-emulator
+ <<: *build_docker_image
build:
+ image: "0xacab.org:4567/leap/bitmask_android/android-ndk:latest"
stage: build
script:
+ - git submodule sync --recursive
+ - git submodule update --init --recursive
- ./gradlew assembleDebug
artifacts:
paths:
diff --git a/.gitlab/build.sh b/.gitlab/build.sh
new file mode 100755
index 00000000..cc63075d
--- /dev/null
+++ b/.gitlab/build.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# Build script for the gitlab ci.
+#
+# usage: build.sh DIR [TAG]
+#
+# Will run docker build in DIR with DIR/Dockerfile or
+# DIR/TAG.dockerfile if TAG is given.
+#
+# Assumes CI specific environment variables to be set:
+# CI_REGISTRY_IMAGE
+# LAST_COMMIT (fetched from the gitlab api in before_script hook)
+#
+
+DIR=$1
+TAG=${2:-latest}
+DOCKERFILE=docker/${DIR}/${2:-Dockerfile}${2:+.dockerfile}
+TARGET=${CI_REGISTRY_IMAGE}/${DIR}:${TAG}
+
+if git diff "$LAST_COMMIT" HEAD --name-only | egrep "($DOCKERFILE|^.gitlab)"; then
+ docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY"
+ docker build -t "$TARGET" -f "$DOCKERFILE" docker/
+ docker push "$TARGET"
+fi
diff --git a/docker/android-emulator.dockerfile b/docker/android-emulator/Dockerfile
index 0201312b..0201312b 100644
--- a/docker/android-emulator.dockerfile
+++ b/docker/android-emulator/Dockerfile
diff --git a/docker/android-ndk.dockerfile b/docker/android-ndk/Dockerfile
index 0a3eabfd..0a3eabfd 100644
--- a/docker/android-ndk.dockerfile
+++ b/docker/android-ndk/Dockerfile
diff --git a/docker/android-sdk.dockerfile b/docker/android-sdk/Dockerfile
index 4044a7ec..4044a7ec 100644
--- a/docker/android-sdk.dockerfile
+++ b/docker/android-sdk/Dockerfile