-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
79 lines (70 loc) · 1.65 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
variables:
APP_NAME: sdal-touch
APP_PORT: 3000
DEPLOY_PUBLIC_PORT: 8000
DEPLOY_NETWORK_NAME: proxy
DOCKER_IMAGE_NAME: $DOCKER_ORGANIZATION/$APP_NAME
DOCKER_DRIVER: overlay2
GIT_STRATEGY: clone
GIT_SUBMODULE_STRATEGY: recursive
DEPLOY_BASE_HREF: /touch/
stages:
- build
- publish
- deploy
cache:
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
paths:
- client/node_modules/
- server/node_modules/
# BUILD
build_client:
stage: build
image: node:16-alpine
before_script:
- cd client
script:
- yarn install --frozen-lockfile
- yarn build --base-href $DEPLOY_BASE_HREF
artifacts:
paths:
- client/dist
expire_in: 1 day
build_server:
stage: build
image: node:16-alpine
before_script:
- cd server
script:
- yarn install --frozen-lockfile
- yarn build
artifacts:
paths:
- server/dist
expire_in: 1 day
# PUBLISH
publish:
stage: publish
image: docker
services:
- docker:dind
script:
- docker build -t $DOCKER_IMAGE_NAME .
after_script:
- docker login --username=$DOCKER_USER --password=$DOCKER_TOKEN
- docker push $DOCKER_IMAGE_NAME
needs:
- build_server
- build_client
# DEPLOY
deploy:
stage: deploy
image: ictu/sshpass
needs:
- publish
before_script:
- alias ssh-pass-server='sshpass -p "$SDAL_DEFAULT_PASSWORD" ssh -oStrictHostKeyChecking=no $SDAL_DEFAULT_USERNAME@$SDAL_DEFAULT_IP'
script:
- ssh-pass-server docker pull $DOCKER_IMAGE_NAME
- ssh-pass-server docker rm -f $APP_NAME || true
- ssh-pass-server docker run -d -p $DEPLOY_PUBLIC_PORT:$APP_PORT --network=$DEPLOY_NETWORK_NAME --name $APP_NAME $DOCKER_IMAGE_NAME