stages: - image - build variables: DOCKER_HOST: tcp://docker:2375 DOCKER_TLS_CERTDIR: "" DOCKER_BUILDKIT: "1" # apt mirror used inside both images (override per pipeline if needed) APT_MIRROR: "http://mirrors.tuna.tsinghua.edu.cn/ubuntu" # Images are shared through Harbor (plain HTTP), never as artifacts. HARBOR_HOST: "192.168.1.11:9090" HARBOR_PROJECT: "openra3" IMAGE: "$HARBOR_HOST/$HARBOR_PROJECT/$CI_PROJECT_NAME" # dind: pull docker.io through the intranet Harbor proxy (plain HTTP -> # --insecure-registry) and enable the containerd snapshotter so the *docker* # driver can export the registry BuildKit cache (the classic overlay2 driver # rejects it). Anchor is an array, so `services: *dind` stays an array. .dind: &dind - name: docker:dind command: - --registry-mirror=http://192.168.1.11:9090/dockerhub - --insecure-registry=192.168.1.11:9090 - --feature=containerd-snapshotter=true # Retry helper for transient network failures (login / build / push / pull). .retry: &retry - | retry() { n=0 until "$@"; do n=$((n + 1)) [ "$n" -ge 5 ] && { echo "failed after $n tries: $*" >&2; return 1; } echo "attempt $n failed, retrying: $*" >&2 sleep 15 done } # --- build the two isolated toolchain images and push them to Harbor ---------- linux_image: stage: image image: docker:latest services: *dind tags: - docker before_script: *retry script: - retry sh -c 'echo "$HARBOR_PASSWORD" | docker login "$HARBOR_HOST" -u "$HARBOR_USERNAME" --password-stdin' - | retry docker build \ --cache-from type=registry,ref=$IMAGE:cache-linux,insecure=true \ --cache-to type=registry,ref=$IMAGE:cache-linux,mode=max,insecure=true \ --build-arg APT_MIRROR=$APT_MIRROR \ --target dev \ -t $IMAGE:$CI_COMMIT_SHORT_SHA-linux \ -f Dockerfile . - retry docker push $IMAGE:$CI_COMMIT_SHORT_SHA-linux windows_image: stage: image image: docker:latest services: *dind tags: - docker before_script: *retry script: - retry sh -c 'echo "$HARBOR_PASSWORD" | docker login "$HARBOR_HOST" -u "$HARBOR_USERNAME" --password-stdin' - | retry docker build \ --cache-from type=registry,ref=$IMAGE:cache-windows,insecure=true \ --cache-to type=registry,ref=$IMAGE:cache-windows,mode=max,insecure=true \ --build-arg APT_MIRROR=$APT_MIRROR \ --target dev \ -t $IMAGE:$CI_COMMIT_SHORT_SHA-windows \ -f Dockerfile.win . - retry docker push $IMAGE:$CI_COMMIT_SHORT_SHA-windows # --- build and test each target ---------------------------------------------- build_linux: stage: build image: docker:latest services: *dind tags: - docker needs: - linux_image before_script: *retry script: - retry sh -c 'echo "$HARBOR_PASSWORD" | docker login "$HARBOR_HOST" -u "$HARBOR_USERNAME" --password-stdin' - retry docker pull $IMAGE:$CI_COMMIT_SHORT_SHA-linux - docker run --rm -v "$(pwd):/work" -w /work $IMAGE:$CI_COMMIT_SHORT_SHA-linux cmake -S . -B build/linux -G Ninja -DCMAKE_BUILD_TYPE=Release - docker run --rm -v "$(pwd):/work" -w /work $IMAGE:$CI_COMMIT_SHORT_SHA-linux cmake --build build/linux -j - docker run --rm -v "$(pwd):/work" -w /work $IMAGE:$CI_COMMIT_SHORT_SHA-linux ctest --test-dir build/linux --output-on-failure - docker run --rm -v "$(pwd):/work" -w /work $IMAGE:$CI_COMMIT_SHORT_SHA-linux bash -c "mkdir -p artifacts/linux && cp build/linux/bin/openra3 artifacts/linux/" artifacts: name: "$CI_PROJECT_NAME-linux-$CI_COMMIT_SHORT_SHA" paths: - artifacts/linux/ expire_in: 7 days build_windows: stage: build image: docker:latest services: *dind tags: - docker needs: - windows_image before_script: *retry script: - retry sh -c 'echo "$HARBOR_PASSWORD" | docker login "$HARBOR_HOST" -u "$HARBOR_USERNAME" --password-stdin' - retry docker pull $IMAGE:$CI_COMMIT_SHORT_SHA-windows - docker run --rm -v "$(pwd):/work" -w /work $IMAGE:$CI_COMMIT_SHORT_SHA-windows cmake -S . -B build/windows -G Ninja -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/llvm-mingw-x86_64.cmake -DCMAKE_BUILD_TYPE=Release - docker run --rm -v "$(pwd):/work" -w /work $IMAGE:$CI_COMMIT_SHORT_SHA-windows cmake --build build/windows -j - docker run --rm -v "$(pwd):/work" -w /work $IMAGE:$CI_COMMIT_SHORT_SHA-windows bash -c "mkdir -p artifacts/windows && cp build/windows/bin/openra3.exe build/windows/bin/SDL3.dll artifacts/windows/" artifacts: name: "$CI_PROJECT_NAME-windows-$CI_COMMIT_SHORT_SHA" paths: - artifacts/windows/ expire_in: 7 days