-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
114 lines (105 loc) · 3.13 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
image: docker:latest
services:
- docker:dind
stages:
- test-backend
- build-backend
- package-backend
- deploy-backend
- package-frontend
- deploy-frontend
test-backend:
stage: test-backend
tags:
- deployment
image: maven:3.8.5-openjdk-17
script:
- pwd
- echo $BACKEND_DIR
- cd $BACKEND_DIR
- mvn -version
- mvn clean test
only:
- main
build-backend:
stage: build-backend
tags:
- deployment
image: maven:3.8.5-openjdk-17
script:
- pwd
- cd $BACKEND_DIR
- mvn clean package -Dspring.profiles.active=prod -DskipTests
artifacts:
paths:
- $BACKEND_DIR/target/*.jar
only:
- main
package-backend:
image: docker:latest
variables:
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: "tcp://docker:2375"
services:
- docker:dind
stage: package-backend
tags:
- deployment
script:
- pwd
- ls -la TourAssist-backend/
- docker build -t docker.io/sumitx28/test:$CI_COMMIT_SHORT_SHA $BACKEND_DIR
- docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PWD docker.io
- docker push docker.io/sumitx28/test:$CI_COMMIT_SHORT_SHA
only:
- main
deploy-backend:
stage: deploy-backend
tags:
- deployment
script:
- chmod og= $ID_RSA
- apk update && apk add openssh-client
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PWD docker.io"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker pull docker.io/sumitx28/test:$CI_COMMIT_SHORT_SHA"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker container rm -f my-app || true"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker run -d -p 8073:8080 --name my-app docker.io/sumitx28/test:$CI_COMMIT_SHORT_SHA"
environment:
name: production
url: http://172.17.0.148:8073
only:
- main
package-frontend:
image: docker:latest
variables:
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: "tcp://docker:2375"
services:
- docker:dind
stage: package-frontend
tags:
- deployment
script:
- pwd
- ls -la TourAssist-frontend/
- docker build -t docker.io/sumitx28/test:$CI_COMMIT_SHORT_SHA-fe $FRONTEND_DIR
- docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PWD docker.io
- docker push docker.io/sumitx28/test:$CI_COMMIT_SHORT_SHA-fe
only:
- main
deploy-frontend:
stage: deploy-frontend
tags:
- deployment
script:
- chmod og= $ID_RSA
- apk update && apk add openssh-client
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PWD docker.io"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker pull docker.io/sumitx28/test:$CI_COMMIT_SHORT_SHA-fe"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker container rm -f fe-app || true"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker run -d -p 8074:5173 --name fe-app docker.io/sumitx28/test:$CI_COMMIT_SHORT_SHA-fe"
environment:
name: production-fe
url: http://172.17.0.148:8074
only:
- main