forked from MobiDataLab/mdl-geo-enrichment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
69 lines (63 loc) · 2.05 KB
/
.travis.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
sudo: true
dist: jammy #ubuntu 22.04 lts
language: java
jdk: openjdk17
services:
- docker
stages:
- build
- test
- package
- deploy
env:
global:
- M2_HOME: ".m2/repository"
- MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
- SPRING_PROFILES_ACTIVE: integration-test
- REPO: mdl-geo-enrichment
# cache maven repo
cache:
directories:
- target/
- $HOME/.m2
- $HOME/.npm
before_install:
- chmod +x mvnw # required to run maven
jobs:
include:
- stage: build
script:
- echo "Compiling the code..."
- mvn install -B -DskipTests
- echo "Compile complete!"
- stage: test
before_script:
- curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - # install nodejs
- sudo apt-get install nodejs
- node -v
- sudo npm install -g osmtogeojson # install osmtogeojson module
- sudo npm install -g --unsafe-perm gtfs-to-geojson # install gtfs-to-geojson module
script:
- echo "Running unit tests..."
- mvn verify
- echo "Unit tests execution complete."
- stage: package
if: branch = main AND type IN (push, pull_request)
script:
- echo "Packaging application..."
- mvn clean package -B -Dspring.profiles.active=prod -DskipTests
- echo "Application packaged !"
- stage: deploy
if: branch = main AND type IN (push, pull_request)
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login --username "$CI_REGISTRY_USER" --password-stdin
script:
- echo "Deploying application..."
- docker build -t wanam/$REPO:latest .
- docker push wanam/$REPO:latest
- echo "Application pushed to docker registry!"
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 wanam/$REPO
- docker logout