Commit 355bc272 authored by nanahira's avatar nanahira

rework ci

parent b537ff49
stages:
- build
- build2
- combine
- deploy
variables:
GIT_DEPTH: "1"
CONTAINER_TEST_IMAGE_FULL: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-full
CONTAINER_TEST_IMAGE_LITE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-lite
CONTAINER_TEST_IMAGE_X86_FULL: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-x86-full
CONTAINER_TEST_IMAGE_X86_LITE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-x86-lite
CONTAINER_TEST_IMAGE_ARM_FULL: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-arm-full
CONTAINER_TEST_IMAGE_ARM_LITE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-arm-lite
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
CONTAINER_RELEASE_IMAGE_FULL: $CI_REGISTRY_IMAGE:full
CONTAINER_RELEASE_IMAGE_LITE: $CI_REGISTRY_IMAGE:lite
build_lite_x86:
stage: build
tags:
- docker
script:
- TARGET_IMAGE=$CONTAINER_TEST_IMAGE_X86_LITE
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build --pull --no-cache -f ./Dockerfile.lite -t $TARGET_IMAGE .
- docker push $TARGET_IMAGE
build_lite_arm:
stage: build
tags:
- docker-arm
script:
- TARGET_IMAGE=$CONTAINER_TEST_IMAGE_ARM_LITE
.docker-op:
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build --pull --no-cache -f ./Dockerfile.lite -t $TARGET_IMAGE .
- docker push $TARGET_IMAGE
build_full_x86:
stage: build2
.docker-x86:
extends: .docker-op
tags:
- docker
script:
- TARGET_IMAGE=$CONTAINER_TEST_IMAGE_X86_FULL
- SOURCE_IMAGE=$CONTAINER_TEST_IMAGE_X86_LITE
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build --build-arg BASE_IMAGE=$SOURCE_IMAGE --pull --no-cache -t
$TARGET_IMAGE .
- docker push $TARGET_IMAGE
build_full_arm:
stage: build2
variables:
ARCH: x86
.docker-arm:
extends: .docker-op
tags:
- docker-arm
variables:
ARCH: arm
.build_lite:
stage: build
script:
- TARGET_IMAGE=$CONTAINER_TEST_IMAGE_ARM_FULL
- SOURCE_IMAGE=$CONTAINER_TEST_IMAGE_ARM_LITE
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build --build-arg BASE_IMAGE=$SOURCE_IMAGE --pull --no-cache -t
$TARGET_IMAGE .
- docker push $TARGET_IMAGE
combine_lite:
- docker build --pull --no-cache -f ./Dockerfile.lite -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$ARCH-lite .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$ARCH-lite
build_lite_x86:
extends:
- .docker-x86
- .build_lite
build_lite_arm:
extends:
- .docker-arm
- .build_lite
.build_full:
stage: build2
tags:
- docker
script:
- TARGET_IMAGE=$CONTAINER_TEST_IMAGE_LITE
- SOURCE_IMAGE_2=$CONTAINER_TEST_IMAGE_ARM_LITE
- SOURCE_IMAGE_1=$CONTAINER_TEST_IMAGE_X86_LITE
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $SOURCE_IMAGE_1
- docker pull $SOURCE_IMAGE_2
- docker manifest create $TARGET_IMAGE --amend $SOURCE_IMAGE_1 --amend
$SOURCE_IMAGE_2
- docker manifest push $TARGET_IMAGE
combine_full:
stage: combine
tags:
- docker
- docker build --build-arg $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$ARCH-lite--pull --no-cache -t
$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$ARCH-full .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$ARCH-full
build_full_x86:
extends:
- .docker-x86
- .build_full
build_full_arm:
extends:
- .docker-arm
- .build_full
.deploy_image:
stage: deploy
extends: .docker-x86
script:
- TARGET_IMAGE=$CONTAINER_TEST_IMAGE_FULL
- SOURCE_IMAGE_2=$CONTAINER_TEST_IMAGE_ARM_FULL
- SOURCE_IMAGE_1=$CONTAINER_TEST_IMAGE_X86_FULL
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $SOURCE_IMAGE_1
- docker pull $SOURCE_IMAGE_2
- docker manifest create $TARGET_IMAGE --amend $SOURCE_IMAGE_1 --amend
$SOURCE_IMAGE_2
- docker manifest push $TARGET_IMAGE
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-x86-$DEPLOY_TYPE
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-arm-$DEPLOY_TYPE
- docker manifest create $CI_REGISTRY_IMAGE:$DEPLOY_TAG $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-x86-$DEPLOY_TYPE $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-arm-$DEPLOY_TYPE
- docker manifest push $CI_REGISTRY_IMAGE:$DEPLOY_TAG
deploy_lite:
extends: .deploy_image
variables:
DEPLOY_TYPE: lite
DEPLOY_TAG: $CI_COMMIT_REF_SLUG-lite
deploy_full:
extends: .deploy_image
variables:
DEPLOY_TYPE: full
DEPLOY_TAG: $CI_COMMIT_REF_SLUG-full
deploy_branch:
extends: .deploy_image
variables:
DEPLOY_TYPE: full
DEPLOY_TAG: $CI_COMMIT_REF_SLUG
deploy_latest_lite:
extends: .deploy_image
variables:
DEPLOY_TYPE: lite
DEPLOY_TAG: lite
only:
- master
deploy_latest_full:
extends: .deploy_image
variables:
DEPLOY_TYPE: full
DEPLOY_TAG: full
only:
- master
deploy_latest:
extends: .deploy_image
variables:
DEPLOY_TYPE: full
DEPLOY_TAG: latest
only:
- master
upload_stuff_to_minio:
stage: deploy
tags:
- linux
image: $CONTAINER_TEST_IMAGE_FULL
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-x86-full
script:
- apt update ; apt -y install python3-pip
- pip3 install -U -i https://mirrors.aliyun.com/pypi/simple/ awscli
......@@ -102,62 +123,3 @@ upload_stuff_to_minio:
/dist/ygopro-server.tar.gz s3://mycard/srvpro/ygopro-server.tar.gz
only:
- master
deploy_latest_full:
stage: deploy
tags:
- docker
script:
- TARGET_IMAGE_2=$CONTAINER_RELEASE_IMAGE
- TARGET_IMAGE=$CONTAINER_RELEASE_IMAGE_FULL
- SOURCE_IMAGE=$CONTAINER_TEST_IMAGE_FULL
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $SOURCE_IMAGE
- docker tag $SOURCE_IMAGE $TARGET_IMAGE
- docker push $TARGET_IMAGE
- docker tag $SOURCE_IMAGE $TARGET_IMAGE_2
- docker push $TARGET_IMAGE_2
only:
- master
deploy_latest_lite:
stage: deploy
tags:
- docker
script:
- TARGET_IMAGE=$CONTAINER_RELEASE_IMAGE_LITE
- SOURCE_IMAGE=$CONTAINER_TEST_IMAGE_LITE
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $SOURCE_IMAGE
- docker tag $SOURCE_IMAGE $TARGET_IMAGE
- docker push $TARGET_IMAGE
only:
- master
deploy_tag_full:
stage: deploy
tags:
- docker
script:
- TARGET_IMAGE_2=$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
- TARGET_IMAGE=$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG-full
- SOURCE_IMAGE=$CONTAINER_TEST_IMAGE_FULL
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $SOURCE_IMAGE
- docker tag $SOURCE_IMAGE $TARGET_IMAGE
- docker push $TARGET_IMAGE
- docker tag $SOURCE_IMAGE $TARGET_IMAGE_2
- docker push $TARGET_IMAGE_2
only:
- tags
deploy_tag_lite:
stage: deploy
tags:
- docker
script:
- TARGET_IMAGE=$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG-lite
- SOURCE_IMAGE=$CONTAINER_TEST_IMAGE_LITE
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $SOURCE_IMAGE
- docker tag $SOURCE_IMAGE $TARGET_IMAGE
- docker push $TARGET_IMAGE
only:
- tags
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment