.gitlab-ci.yml 1.66 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
  MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN"
cnguyen2's avatar
cnguyen2 committed
9

cnguyen2's avatar
cnguyen2 committed
10
11
12
13
cache:
  paths:
    - .m2/repository

cnguyen2's avatar
cnguyen2 committed
14
15
build native:
  stage: build
cnguyen2's avatar
cnguyen2 committed
16
17
18
19
20
21
22
23
24
25
26
  image: quay.io/quarkus/centos-quarkus-maven:20.3-java11
  only:
    - master
  script:
    - mvn -f $CI_PROJECT_DIR/pom.xml clean install -P native
  artifacts:
    paths:
      - $CI_PROJECT_DIR/target/*-runner

containerize native:
  stage: containerize
cnguyen2's avatar
cnguyen2 committed
27
28
29
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
cnguyen2's avatar
cnguyen2 committed
30
31
  only:
    - master
cnguyen2's avatar
cnguyen2 committed
32
33
34
  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
35
36
37
    - >
      /kaniko/executor
      --context $CI_PROJECT_DIR
cnguyen2's avatar
cnguyen2 committed
38
      --dockerfile $CI_PROJECT_DIR/src/main/docker/Dockerfile.native
cnguyen2's avatar
cnguyen2 committed
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
      --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
59
60
  only:
    - tags
cnguyen2's avatar
cnguyen2 committed
61
62
63
64
65
  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