.gitlab-ci.yml 2.47 KB
Newer Older
cnguyen2's avatar
cnguyen2 committed
1
stages:
cnguyen2's avatar
cnguyen2 committed
2
  - build
cnguyen2's avatar
cnguyen2 committed
3
  - containerize
cnguyen2's avatar
cnguyen2 committed
4
  - push
cnguyen2's avatar
cnguyen2 committed
5

cnguyen2's avatar
cnguyen2 committed
6
7
variables:
  CONTAINER_TEMP_IMAGE: $CI_REGISTRY_IMAGE:temp-$CI_COMMIT_SHORT_SHA
8
  CONTAINER_JVM_TEMP_IMAGE: $CI_REGISTRY_IMAGE:temp-jvm-$CI_COMMIT_SHORT_SHA
cnguyen2's avatar
cnguyen2 committed
9

cnguyen2's avatar
cnguyen2 committed
10
11
build native:
  stage: build
12
  image: quay.io/quarkus/centos-quarkus-maven:21.0.0-java11
cnguyen2's avatar
cnguyen2 committed
13
14
15
  only:
    - master
  script:
16
    - mvn -f $CI_PROJECT_DIR/pom.xml clean package -Pnative -Dquarkus.container-image.build=false
cnguyen2's avatar
cnguyen2 committed
17
18
19
20
  artifacts:
    paths:
      - $CI_PROJECT_DIR/target/*-runner

21
22
23
24
25
26
27
28
29
30
31
32
33
34
build jvm:
  stage: build
  image: quay.io/quarkus/centos-quarkus-maven:21.0.0-java11
  when: manual
  only:
    - master
  script:
    - mvn -f $CI_PROJECT_DIR/pom.xml clean package -Dquarkus.container-image.build=false
  artifacts:
    paths:
      - $CI_PROJECT_DIR/target/*-runner.jar
      - $CI_PROJECT_DIR/target/lib/*
      - $CI_PROJECT_DIR/target/quarkus-app/*

cnguyen2's avatar
cnguyen2 committed
35
36
containerize native:
  stage: containerize
cnguyen2's avatar
cnguyen2 committed
37
38
39
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
cnguyen2's avatar
cnguyen2 committed
40
41
  only:
    - master
cnguyen2's avatar
cnguyen2 committed
42
43
44
  script:
    - mkdir -p /kaniko/.docker
    - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
cnguyen2's avatar
cnguyen2 committed
45
46
47
    - >
      /kaniko/executor
      --context $CI_PROJECT_DIR
cnguyen2's avatar
cnguyen2 committed
48
      --dockerfile $CI_PROJECT_DIR/src/main/docker/Dockerfile.native
cnguyen2's avatar
cnguyen2 committed
49
50
      --destination $CONTAINER_TEMP_IMAGE

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
containerize jvm:
  stage: containerize
  when: manual
  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

cnguyen2's avatar
cnguyen2 committed
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
push latest:
  stage: push
  image:
    name: gcr.io/go-containerregistry/crane:debug
    entrypoint: [""]
  only:
    - master
  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

push tag:
  stage: push
  image:
    name: gcr.io/go-containerregistry/crane:debug
    entrypoint: [""]
cnguyen2's avatar
cnguyen2 committed
86
87
  only:
    - tags
cnguyen2's avatar
cnguyen2 committed
88
89
90
91
92
  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:$CI_COMMIT_TAG