-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
75 lines (64 loc) · 1.88 KB
/
.gitlab-ci.yml
File metadata and controls
75 lines (64 loc) · 1.88 KB
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
stages:
- build
- deploy
workflow:
auto_cancel:
on_new_commit: interruptible
variables:
IMAGE_NAME: parhom/pyramid-app
PROD_PATH: /home/docker/pyramid-sync-data
.buildkit-template:
stage: build
tags: [cloud2-docker-runner]
image:
name: moby/buildkit:latest
entrypoint: [""]
interruptible: true
before_script:
- echo "🛠 set up docker"
- mkdir -p ~/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$REGISTRY_ACCESS_KEY\"}}}" > ~/.docker/config.json
script:
- echo "🚀 build image $IMAGE_NAME"
- buildctl-daemonless.sh build
--frontend dockerfile.v0
--local context=.
--local dockerfile=.
--output type=image,name=$CI_REGISTRY/$IMAGE_NAME:$TAG,push=true
--export-cache type=inline
--import-cache type=registry,ref=$CI_REGISTRY/$IMAGE_NAME:buildcache
--secret id=dockerconfig,src=$HOME/.docker/config.json
build-prod:
extends: .buildkit-template
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
variables:
TAG: latest
build-dev:
extends: .buildkit-template
rules:
- if: '$CI_COMMIT_BRANCH == "dev"'
variables:
TAG: dev
deploy_prod:
stage: deploy
image: alpine:3.21
tags: [docker]
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
before_script:
- apk add --no-cache openssh-client-default
- mkdir -p ~/.ssh
- chmod og= "$DATALENS_SSH_KEY"
- echo -e "Host *\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
- echo "SSH setup complete"
script:
- |
ssh -T -i "$DATALENS_SSH_KEY" "$DATALENS_USER@$DATALENS_HOST_FOR_DOCKER_RUNNER" <<EOF
echo "$ACCESS_TOKEN_REPO"
echo '${ACCESS_TOKEN_REPO}' | docker login '${CI_REGISTRY}' -u '${DEPLOY_BOT_AT}' --password-stdin
cd $PROD_PATH
docker compose pull
docker compose up -d --force-recreate
docker restart nginx
EOF