-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
44 lines (41 loc) · 1.38 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
variables:
TAG_LATEST: $CI_REGISTRY_IMAGE:latest
TAG_COMMIT: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
build:
when: manual
image: docker:19.03.12
only:
- main
stage: build
services:
- docker:19.03.12-dind
variables:
DOCKER_BUILDKIT: 1
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $TAG_LATEST || true
script:
- docker build
--cache-from $TAG_LATEST
--build-arg BUILDKIT_INLINE_CACHE=1
--build-arg DEBUG=$DEBUG
--build-arg ALLOWED_HOST=$ALLOWED_HOST
-t $TAG_LATEST
-t $TAG_COMMIT .
after_script:
- docker push $TAG_LATEST
- docker push $TAG_COMMIT
deploy:
when: manual
image: alpine:latest
stage: deploy
only:
- main
before_script:
- apk update && apk add openssh-client
- chmod og= $ID_RSA
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "if [! -d "nft-main"]; then git clone $CI_REPOSITORY_URL fi"
script:
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "sudo docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "cd nft-main && sudo docker compose up --pull always --force-recreate --remove-orphans -d"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "sudo docker image prune -f"