From d7568b133b5ce4428e752984b5ce181066a62ca0 Mon Sep 17 00:00:00 2001 From: Anton Afanasyeu Date: Tue, 2 Jun 2026 17:37:32 +0200 Subject: [PATCH] Fix Docker CI and orchestration deploy reliability for full rebuild flows. Use JDK 17 and make in the CI image, avoid self-overwriting DB init SQL, and make Gradle/native builds use container-local SDK paths and CMake caches. Co-authored-by: Cursor --- Dockerfile | 6 +++--- orchestration/deploy.sh | 27 +++++++++++++++------------ scripts/build-native-codecs.sh | 4 +++- scripts/ci-build-and-publish-ota.sh | 23 ++++++++++++++++++++--- 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index c4f910f..9183a6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,11 +35,11 @@ ENV ANDROID_SDK_ROOT="${ANDROID_SDK_ROOT}" \ ANDROIDCAST_USE_DISTCC=0 \ ANDROIDCAST_CI_VERSION="${ANDROIDCAST_CI_VERSION}" \ GRADLE_USER_HOME=/root/.gradle \ - JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64 + JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 RUN apt-get update && apt-get install -y --no-install-recommends \ - bash ca-certificates curl git openjdk-21-jdk-headless unzip wget \ - ninja-build cmake ccache \ + bash ca-certificates curl git openjdk-17-jdk-headless unzip wget \ + make ninja-build cmake ccache \ && rm -rf /var/lib/apt/lists/* RUN apt-get update && apt-get install -y --no-install-recommends distcc \ diff --git a/orchestration/deploy.sh b/orchestration/deploy.sh index 7394b38..1a653d5 100755 --- a/orchestration/deploy.sh +++ b/orchestration/deploy.sh @@ -111,18 +111,21 @@ return [ EOF cp "$SRC_SCHEMA" "$DB_INIT_DIR/010_schema.sql" -{ - echo "USE \`${MARIADB_DATABASE}\`;" - cat "$SRC_MIG_004" -} >"$DB_INIT_DIR/040_ticket_workflow.sql" -{ - echo "USE \`${MARIADB_DATABASE}\`;" - cat "$SRC_MIG_005" -} >"$DB_INIT_DIR/050_ticket_attachments.sql" -{ - echo "USE \`${MARIADB_DATABASE}\`;" - cat "$SRC_MIG_060" -} >"$DB_INIT_DIR/060_build_ecosystem.sql" +write_migration_with_db() { + local src="$1" + local dest="$2" + local tmp + tmp="$(mktemp)" + { + echo "USE \`${MARIADB_DATABASE}\`;" + cat "$src" + } >"$tmp" + mv "$tmp" "$dest" +} + +write_migration_with_db "$SRC_MIG_004" "$DB_INIT_DIR/040_ticket_workflow.sql" +write_migration_with_db "$SRC_MIG_005" "$DB_INIT_DIR/050_ticket_attachments.sql" +write_migration_with_db "$SRC_MIG_060" "$DB_INIT_DIR/060_build_ecosystem.sql" echo "Pulling images..." docker compose -f "$ROOT_DIR/docker-compose.yml" pull landing-fe gitea-fe crashes-fe build-fe mariadb gitea || true diff --git a/scripts/build-native-codecs.sh b/scripts/build-native-codecs.sh index efc441c..64ca2ac 100755 --- a/scripts/build-native-codecs.sh +++ b/scripts/build-native-codecs.sh @@ -222,7 +222,9 @@ if [[ ! -f "$LIBVPX_A" ]]; then fi cp -f "$LIBVPX_A" "$OUT/libvpx.a" -cp -f "$OUT/libvpx.a" "$PROJECT_OUT/libvpx.a" +if [[ "$OUT" != "$PROJECT_OUT" ]]; then + cp -f "$OUT/libvpx.a" "$PROJECT_OUT/libvpx.a" +fi echo "" echo "Built: $PROJECT_OUT/libvpx.a (size $(ls -lah "${PROJECT_OUT}/libvpx.a" | awk '{print $5}'))" diff --git a/scripts/ci-build-and-publish-ota.sh b/scripts/ci-build-and-publish-ota.sh index 6db1170..1a30b6a 100755 --- a/scripts/ci-build-and-publish-ota.sh +++ b/scripts/ci-build-and-publish-ota.sh @@ -42,10 +42,24 @@ fi export ANDROIDCAST_ROOT="$ROOT" export ANDROIDCAST_CCACHE="${ANDROIDCAST_CCACHE:-1}" +GRADLE_JAVA_OPT=() +if [[ -n "${JAVA_HOME:-}" ]]; then + GRADLE_JAVA_OPT=(-Dorg.gradle.java.home="${JAVA_HOME}") +fi # shellcheck source=android-ndk.sh source "$ROOT/scripts/android-ndk.sh" export ANDROID_NDK_HOME="$(androidcast_find_ndk_root "$ROOT")" export ANDROID_NDK_ROOT="$ANDROID_NDK_HOME" +if [[ -n "${ANDROID_SDK_ROOT:-}" ]]; then + LOCAL_PROPS="$ROOT/local.properties" + LOCAL_PROPS_BACKUP="" + if [[ -f "$LOCAL_PROPS" ]]; then + LOCAL_PROPS_BACKUP="$(mktemp)" + cp -f "$LOCAL_PROPS" "$LOCAL_PROPS_BACKUP" + fi + trap 'if [[ -n "${LOCAL_PROPS_BACKUP:-}" && -f "${LOCAL_PROPS_BACKUP}" ]]; then cp -f "${LOCAL_PROPS_BACKUP}" "$LOCAL_PROPS"; rm -f "${LOCAL_PROPS_BACKUP}"; else rm -f "$LOCAL_PROPS"; fi' EXIT + printf 'sdk.dir=%s\n' "${ANDROID_SDK_ROOT//\\/\\\\}" > "$LOCAL_PROPS" +fi if [[ "$RUN_NATIVE" == "1" && "$RUN_APK" == "1" ]]; then echo "==> Phase: native codecs" @@ -59,16 +73,19 @@ else echo "==> Phase: native codecs (skipped)" fi +# Avoid host-specific CMake cache paths when running in Docker. +rm -rf "$ROOT/app/.cxx" "$ROOT/app/build/.cxx" "$ROOT/app/build/intermediates/cxx" + if [[ "$RUN_APK" == "1" ]]; then echo "==> Phase: gradle ${GRADLE_TASK}" if [[ "$RUN_UNIT_TESTS" == "1" ]]; then - ./gradlew --no-daemon clean "${GRADLE_TASK}" testDebugUnitTest + ./gradlew --no-daemon "${GRADLE_JAVA_OPT[@]}" clean "${GRADLE_TASK}" testDebugUnitTest else - ./gradlew --no-daemon clean "${GRADLE_TASK}" + ./gradlew --no-daemon "${GRADLE_JAVA_OPT[@]}" clean "${GRADLE_TASK}" fi else echo "==> Phase: gradle tests-only" - ./gradlew --no-daemon testDebugUnitTest + ./gradlew --no-daemon "${GRADLE_JAVA_OPT[@]}" testDebugUnitTest fi APK=""