.gitlab-ci.yml 1.48 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
cnguyen2's avatar
cnguyen2 committed
8

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

containerize native:
  stage: containerize
cnguyen2's avatar
cnguyen2 committed
22
23
24
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
cnguyen2's avatar
cnguyen2 committed
25
26
  only:
    - master
cnguyen2's avatar
cnguyen2 committed
27
28
29
  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
30
31
32
    - >
      /kaniko/executor
      --context $CI_PROJECT_DIR
cnguyen2's avatar
cnguyen2 committed
33
      --dockerfile $CI_PROJECT_DIR/src/main/docker/Dockerfile.native
cnguyen2's avatar
cnguyen2 committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
      --destination $CONTAINER_TEMP_IMAGE

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
54
55
  only:
    - tags
cnguyen2's avatar
cnguyen2 committed
56
57
58
59
60
  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