Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Package application needed to run tests & build the image on next stage
build automation:
variables:
IMAGE_NAME: 'automation' # name of the microservice
IMAGE_NAME_TEST: 'automation-test' # name of the microservice
IMAGE_TAG: '0.0.1' # tag of the container image (production, development, etc)
stage: build
script:
- docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/src/main/docker/Dockerfile.multistage.jvm ./src/$IMAGE_NAME/ --target builder
rules:
- changes:
- src/$IMAGE_NAME/**
- .gitlab-ci.yml
# Run tests, build & push the image
unit_test automation:
variables:
IMAGE_NAME: 'automation' # name of the microservice
IMAGE_NAME_TEST: 'automation-test' # name of the microservice
IMAGE_TAG: '0.0.1' # tag of the container image (production, development, etc)
stage: unit_test
needs:
- build automation
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/src/main/docker/Dockerfile.multistage.jvm ./src/$IMAGE_NAME/ --target unit-test
- docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/src/main/docker/Dockerfile.multistage.jvm ./src/$IMAGE_NAME/ --target release
- docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
- docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
rules:
- changes:
- src/$IMAGE_NAME/**
- .gitlab-ci.yml
# Deployment of automation service in Kubernetes Cluster
deploy automation:
stage: deploy
needs:
- build automation
- unit_test automation
script:
- kubectl version
- kubectl get all
- kubectl apply -f "manifests/automationservice.yaml"
- kubectl delete pods --selector app=automationservice
- kubectl get all