ci: fix dind anchor (services must be an array); push images to Docker Hub instead of docker-save artifacts
This commit is contained in:
+38
-29
@@ -9,17 +9,18 @@ variables:
|
|||||||
DOCKER_BUILDKIT: "1"
|
DOCKER_BUILDKIT: "1"
|
||||||
# apt mirror used inside both images (override per pipeline if needed)
|
# apt mirror used inside both images (override per pipeline if needed)
|
||||||
APT_MIRROR: "http://mirrors.tuna.tsinghua.edu.cn/ubuntu"
|
APT_MIRROR: "http://mirrors.tuna.tsinghua.edu.cn/ubuntu"
|
||||||
|
# Images are shared through Docker Hub (never as artifacts).
|
||||||
|
IMAGE: "docker.io/$DOCKERHUB_USERNAME/$CI_PROJECT_NAME"
|
||||||
|
|
||||||
|
# dind pulls docker.io images through the intranet Harbor pull-through cache.
|
||||||
|
# NOTE: anchor only the *array* so `services: *dind` stays an array.
|
||||||
.dind: &dind
|
.dind: &dind
|
||||||
services:
|
|
||||||
- name: docker:dind
|
- name: docker:dind
|
||||||
# Pull docker.io images through the intranet Harbor pull-through cache;
|
|
||||||
# plain HTTP registry, hence --insecure-registry.
|
|
||||||
command:
|
command:
|
||||||
- --registry-mirror=http://192.168.1.11:9090/dockerhub
|
- --registry-mirror=http://192.168.1.11:9090/dockerhub
|
||||||
- --insecure-registry=192.168.1.11:9090
|
- --insecure-registry=192.168.1.11:9090
|
||||||
|
|
||||||
# --- build the two isolated toolchain images ---------------------------------
|
# --- build the two isolated toolchain images and push them --------------------
|
||||||
linux_image:
|
linux_image:
|
||||||
stage: image
|
stage: image
|
||||||
image: docker:latest
|
image: docker:latest
|
||||||
@@ -27,13 +28,18 @@ linux_image:
|
|||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
script:
|
script:
|
||||||
- docker build --target dev -t openra3-linux:local --build-arg APT_MIRROR=$APT_MIRROR .
|
- echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
|
||||||
- docker save openra3-linux:local -o linux-image.tar
|
# Registry cache export needs the docker-container driver, not the default
|
||||||
artifacts:
|
# docker driver ("Cache export is not supported for the docker driver").
|
||||||
name: "linux-image-$CI_COMMIT_SHORT_SHA"
|
- docker buildx create --use --name ci-builder --driver docker-container
|
||||||
paths:
|
- |
|
||||||
- linux-image.tar
|
docker buildx build \
|
||||||
expire_in: 1 day
|
--cache-from type=registry,ref=$IMAGE:cache-linux \
|
||||||
|
--cache-to type=registry,ref=$IMAGE:cache-linux,mode=max \
|
||||||
|
--build-arg APT_MIRROR=$APT_MIRROR \
|
||||||
|
--target dev \
|
||||||
|
-t $IMAGE:$CI_COMMIT_SHORT_SHA-linux \
|
||||||
|
--push -f Dockerfile .
|
||||||
|
|
||||||
windows_image:
|
windows_image:
|
||||||
stage: image
|
stage: image
|
||||||
@@ -42,13 +48,16 @@ windows_image:
|
|||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
script:
|
script:
|
||||||
- docker build -f Dockerfile.win --target dev -t openra3-windows:local --build-arg APT_MIRROR=$APT_MIRROR .
|
- echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
|
||||||
- docker save openra3-windows:local -o windows-image.tar
|
- docker buildx create --use --name ci-builder --driver docker-container
|
||||||
artifacts:
|
- |
|
||||||
name: "windows-image-$CI_COMMIT_SHORT_SHA"
|
docker buildx build \
|
||||||
paths:
|
--cache-from type=registry,ref=$IMAGE:cache-windows \
|
||||||
- windows-image.tar
|
--cache-to type=registry,ref=$IMAGE:cache-windows,mode=max \
|
||||||
expire_in: 1 day
|
--build-arg APT_MIRROR=$APT_MIRROR \
|
||||||
|
--target dev \
|
||||||
|
-t $IMAGE:$CI_COMMIT_SHORT_SHA-windows \
|
||||||
|
--push -f Dockerfile.win .
|
||||||
|
|
||||||
# --- build and test each target ----------------------------------------------
|
# --- build and test each target ----------------------------------------------
|
||||||
build_linux:
|
build_linux:
|
||||||
@@ -59,13 +68,13 @@ build_linux:
|
|||||||
- docker
|
- docker
|
||||||
needs:
|
needs:
|
||||||
- linux_image
|
- linux_image
|
||||||
before_script:
|
|
||||||
- docker load -i linux-image.tar
|
|
||||||
script:
|
script:
|
||||||
- docker run --rm -v "$(pwd):/work" -w /work openra3-linux:local cmake -S . -B build/linux -G Ninja -DCMAKE_BUILD_TYPE=Release
|
- echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
|
||||||
- docker run --rm -v "$(pwd):/work" -w /work openra3-linux:local cmake --build build/linux -j
|
- docker pull $IMAGE:$CI_COMMIT_SHORT_SHA-linux
|
||||||
- docker run --rm -v "$(pwd):/work" -w /work openra3-linux:local ctest --test-dir build/linux --output-on-failure
|
- 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 openra3-linux:local bash -c "mkdir -p artifacts/linux && cp build/linux/bin/openra3 artifacts/linux/"
|
- 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:
|
artifacts:
|
||||||
name: "$CI_PROJECT_NAME-linux-$CI_COMMIT_SHORT_SHA"
|
name: "$CI_PROJECT_NAME-linux-$CI_COMMIT_SHORT_SHA"
|
||||||
paths:
|
paths:
|
||||||
@@ -80,15 +89,15 @@ build_windows:
|
|||||||
- docker
|
- docker
|
||||||
needs:
|
needs:
|
||||||
- windows_image
|
- windows_image
|
||||||
before_script:
|
|
||||||
- docker load -i windows-image.tar
|
|
||||||
script:
|
script:
|
||||||
- docker run --rm -v "$(pwd):/work" -w /work openra3-windows:local
|
- echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
|
||||||
|
- 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
|
cmake -S . -B build/windows -G Ninja
|
||||||
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/llvm-mingw-x86_64.cmake
|
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/llvm-mingw-x86_64.cmake
|
||||||
-DCMAKE_BUILD_TYPE=Release
|
-DCMAKE_BUILD_TYPE=Release
|
||||||
- docker run --rm -v "$(pwd):/work" -w /work openra3-windows:local cmake --build build/windows -j
|
- 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 openra3-windows:local bash -c "mkdir -p artifacts/windows && cp build/windows/bin/openra3.exe build/windows/bin/SDL3.dll artifacts/windows/"
|
- 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:
|
artifacts:
|
||||||
name: "$CI_PROJECT_NAME-windows-$CI_COMMIT_SHORT_SHA"
|
name: "$CI_PROJECT_NAME-windows-$CI_COMMIT_SHORT_SHA"
|
||||||
paths:
|
paths:
|
||||||
|
|||||||
Reference in New Issue
Block a user