-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
78 lines (70 loc) · 2.05 KB
/
.gitlab-ci.yml
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
image: alpine:3.16.0
before_script: # install required packages for build and execution
- apk add openjdk11 maven nodejs npm
- npm install -g osmtogeojson # install osmtogeojson module
- npm install -g gtfs-to-geojson # install gtfs-to-geojson module
stages:
- build
- test
- package
- deploy
# cache maven repo
cache:
paths:
- .m2/repository
- target/
variables:
M2_HOME: ".m2/repository"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
SPRING_PROFILES_ACTIVE: integration-test
REPO: mdl-geo-enrichment
build-job:
stage: build
tags:
- elksiba-local
script:
- echo "Compiling the code..."
- mvn install -B -DskipTests
- echo "Compile complete!"
unit-test-job: # This job runs integration tests
stage: test
tags:
- elksiba-local
script:
- echo "Running unit tests..."
- mvn verify
- echo "Unit tests execution complete."
artifacts:
paths:
- target/
package-job: # This job runs in the test stage.
stage: package # It only starts when the job in the build stage completes successfully.
tags:
- elksiba-local
script:
- echo "Packaging application..."
- mvn clean package -B -Dspring.profiles.active=prod -DskipTests
- echo "Application packaged !"
only:
- main
deploy-job:
stage: deploy
image: docker:stable
services:
- docker:stable-dind
tags:
- elksiba-local
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login registry.gitlab.com -u "$CI_REGISTRY_USER" --password-stdin
script:
- echo "Deploying application..."
- docker build -t registry.gitlab.com/wanam/$REPO .
- docker push registry.gitlab.com/wanam/$REPO
- echo "Application successfully deployed."
only:
- main
after_script:
- docker stop mdl-geo-enrichment || true # stop the container of the old image if running
- docker rm -f mdl-geo-enrichment || true # force remove the container if it is still running
- docker run --name mdl-geo-enrichment --restart always -d -p 62080:80 -p 443:443 registry.gitlab.com/wanam/$REPO
- docker logout