From 37409bdd7ad5905d45b5f07303d8717bc4d3263a Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Wed, 22 Dec 2021 14:54:55 +0000 Subject: [PATCH] Custom Build Image --- .gitlab-ci.yml | 32 +++++++++++++++++++++++++++----- docker/Dockerfile | 17 +++++++++++++++++ 2 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 docker/Dockerfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fbdfdba..2db771d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: jangrewe/gitlab-ci-android +image: dev.funkwhale.audio:5050/funkwhale/funkwhale-android:latest variables: COBERTURA_REPORT: '$CI_PROJECT_DIR/app/build/reports/cobertura.xml' @@ -6,11 +6,33 @@ variables: JACOCO_XML_LOCATION: '$CI_PROJECT_DIR/app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml' stages: + - build_ci_env - test - visualize - build - deploy +build_ci_image: + stage: build_ci_env + image: egon0/docker-with-buildx-and-git:bash + tags: + - dind + services: + - docker:20-dind + before_script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + script: + - docker build -t $CI_REGISTRY_IMAGE docker + after_script: + - docker push $CI_REGISTRY_IMAGE + rules: + - if: '$BUILD_CI_IMAGE' + variables: + DOCKER_HOST: tcp://docker:2375/ + DOCKER_DRIVER: overlay2 + DOCKER_TLS_CERTDIR: "" + + .gradle-default: before_script: - export GRADLE_USER_HOME=$(pwd)/.gradle @@ -50,7 +72,7 @@ test: except: - tags script: - - ./gradlew test jacocoTestReport + - ./gradlew --no-daemon --stacktrace test jacocoTestReport - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, " instructions covered"; print 100*covered/instructions, "% covered" }' $JACOCO_CSV_LOCATION artifacts: reports: @@ -77,7 +99,7 @@ build-develop: extends: .build script: - echo -n $PREVIEW_SIGNING_KEY_STORE | base64 -d > app/android.keystore - - ./gradlew assembleDebug -Psigning.store=android.keystore -Psigning.store_passphrase=$PREVIEW_SIGNING_KEY_PASS -Psigning.key_passphrase=$PREVIEW_SIGNING_KEY_PASS + - ./gradlew --stacktrace --no-daemon assembleDebug -Psigning.store=android.keystore -Psigning.store_passphrase=$PREVIEW_SIGNING_KEY_PASS -Psigning.key_passphrase=$PREVIEW_SIGNING_KEY_PASS only: - develop @@ -90,14 +112,14 @@ build-release: extends: .build script: - echo -n $SIGNING_KEY_STORE | base64 -d > app/android.keystore - - ./gradlew assembleRelease -Psigning.store=android.keystore -Psigning.store_passphrase=$SIGNING_KEY_PASS -Psigning.key_passphrase=$SIGNING_KEY_PASS + - ./gradlew --stacktrace --no-daemon assembleRelease -Psigning.store=android.keystore -Psigning.store_passphrase=$SIGNING_KEY_PASS -Psigning.key_passphrase=$SIGNING_KEY_PASS only: - tags build-bleeding-edge: extends: .build script: - - ./gradlew assembleDebug + - ./gradlew --stacktrace --no-daemon assembleDebug except: - develop - tags diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..f597c94 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,17 @@ +FROM debian:stable-slim + +ENV ANDROID_COMPILE_SDK=30 +ENV SDK_TOOLS_VERSION=30.0.2 +ENV ANDROID_CMD_TOOLS=7583922 +ENV ANDROID_HOME=/opt/android-sdk-linux +ENV PATH "/opt/android-sdk-linux/cmdline-tools/bin:${PATH}" + +RUN apt-get update && apt-get install --yes openjdk-11-jdk wget tar unzip lib32stdc++6 lib32z1 git +RUN mkdir -p /opt/android-sdk-linux && cd /opt \ + && wget -q https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_CMD_TOOLS}_latest.zip -O android-sdk-tools.zip \ + && unzip -q android-sdk-tools.zip -d ${ANDROID_HOME} \ + && rm -f android-sdk-tools.zip \ + && echo y | sdkmanager --sdk_root=${ANDROID_HOME} "platforms;android-${ANDROID_COMPILE_SDK}" \ + && echo y | sdkmanager --sdk_root=${ANDROID_HOME} "platform-tools" \ + && echo y | sdkmanager --sdk_root=${ANDROID_HOME} "build-tools;${SDK_TOOLS_VERSION}" +