Commit 13765b72 authored by cnguyen2's avatar cnguyen2
Browse files

Refactor gitlab-ci

parent a29a42d9
Pipeline #216756 passed with stages
in 2 minutes and 19 seconds
......@@ -4,16 +4,17 @@ stages:
- push
variables:
CONTAINER_NATIVE_TEMP_IMAGE: $CI_REGISTRY_IMAGE:temp-native-$CI_COMMIT_SHORT_SHA
CONTAINER_JVM_TEMP_IMAGE: $CI_REGISTRY_IMAGE:temp-jvm-$CI_COMMIT_SHORT_SHA
CONTAINER_TEMP_IMAGE: $CONTAINER_JVM_TEMP_IMAGE
BUILD_TYPE:
value: "jvm"
description: "Build type: 'jvm' or 'native'"
IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
build native:
stage: build
when: manual
image: quay.io/quarkus/centos-quarkus-maven:21.0.0-java11
only:
- master
rules:
- if: '$BUILD_TYPE == "native" && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH'
script:
- mvn -f $CI_PROJECT_DIR/pom.xml clean package -Pnative -Dquarkus.container-image.build=false
artifacts:
......@@ -23,8 +24,8 @@ build native:
build jvm:
stage: build
image: quay.io/quarkus/centos-quarkus-maven:21.0.0-java11
only:
- master
rules:
- if: '$BUILD_TYPE == "jvm" && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH'
script:
- mvn -f $CI_PROJECT_DIR/pom.xml clean package -Dquarkus.container-image.build=false
artifacts:
......@@ -33,51 +34,34 @@ build jvm:
- $CI_PROJECT_DIR/target/lib/*
- $CI_PROJECT_DIR/target/quarkus-app/*
containerize native:
containerize:
stage: containerize
when: manual
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
only:
- master
rules:
- if: '$CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH'
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- >
/kaniko/executor
--context $CI_PROJECT_DIR
--dockerfile $CI_PROJECT_DIR/src/main/docker/Dockerfile.native
--destination $CONTAINER_NATIVE_TEMP_IMAGE
containerize jvm:
stage: containerize
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
only:
- master
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- >
/kaniko/executor
--context $CI_PROJECT_DIR
--dockerfile $CI_PROJECT_DIR/src/main/docker/Dockerfile.jvm
--destination $CONTAINER_JVM_TEMP_IMAGE
--dockerfile $CI_PROJECT_DIR/src/main/docker/Dockerfile.$BUILD_TYPE
--destination $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA-$BUILD_TYPE
push latest:
stage: push
image:
name: gcr.io/go-containerregistry/crane:debug
entrypoint: [""]
only:
- master
rules:
- if: '$CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH'
variables:
GIT_STRATEGY: none
script:
- crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- crane cp $CONTAINER_TEMP_IMAGE $CI_REGISTRY_IMAGE:latest
- crane cp $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA-$BUILD_TYPE $CI_REGISTRY_IMAGE:$BUILD_TYPE
push tag:
stage: push
......@@ -90,4 +74,4 @@ push tag:
GIT_STRATEGY: none
script:
- crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- crane cp $CONTAINER_TEMP_IMAGE $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
- crane cp $$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA-$BUILD_TYPE $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
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