-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
75 lines (71 loc) · 3.11 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
stages:
- build
- docker-image
- deploy
variables:
DEPLOY_HOST: 95.179.186.83
PROJECT_NAME: registry.gitlab.com/msv1/universal-miner
build:
image: microsoft/dotnet:latest
stage: build
script:
- dotnet publish Msv.AutoMiner/Msv.AutoMiner.CoinInfoService/Msv.AutoMiner.CoinInfoService.csproj -o ../binaries/coin-info -c Release
- dotnet publish Msv.AutoMiner/Msv.AutoMiner.ControlCenterService/Msv.AutoMiner.ControlCenterService.csproj -o ../binaries/control-center -c Release
- dotnet publish Msv.AutoMiner/Msv.AutoMiner.FrontEnd/Msv.AutoMiner.FrontEnd.csproj -o ../binaries/frontend -c Release
artifacts:
paths:
- Msv.AutoMiner/binaries/coin-info/
- Msv.AutoMiner/binaries/control-center/
- Msv.AutoMiner/binaries/frontend/
only:
- master
docker-image:
image: docker:stable
services:
- docker:dind
stage: docker-image
before_script:
- docker login -u gitlab-ci-token -p $REGISTRY_TOKEN registry.gitlab.com
script:
- docker build -t $PROJECT_NAME/coin-info -f Msv.AutoMiner/Msv.AutoMiner.CoinInfoService/Dockerfile .
- docker push $PROJECT_NAME/coin-info
- docker build -t $PROJECT_NAME/control-center -f Msv.AutoMiner/Msv.AutoMiner.ControlCenterService/Dockerfile .
- docker push $PROJECT_NAME/control-center
- docker build -t $PROJECT_NAME/frontend -f Msv.AutoMiner/Msv.AutoMiner.FrontEnd/Dockerfile .
- docker push $PROJECT_NAME/frontend
after_script:
- docker logout registry.gitlab.com
only:
- master
dependencies:
- build
deploy:
image: kroniak/ssh-client
stage: deploy
variables:
GIT_STRATEGY: none
before_script:
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh $DEPLOY_HOST "docker login -u gitlab-ci-token -p ${REGISTRY_TOKEN} registry.gitlab.com"
script:
- ssh $DEPLOY_HOST 'docker container rm -f um-coin-info || true'
- ssh $DEPLOY_HOST 'docker container rm -f um-control-center || true'
- ssh $DEPLOY_HOST 'docker container rm -f um-frontend || true'
- ssh $DEPLOY_HOST 'docker system prune -af'
- ssh $DEPLOY_HOST "docker pull ${PROJECT_NAME}/coin-info:latest"
- ssh $DEPLOY_HOST "docker pull ${PROJECT_NAME}/control-center:latest"
- ssh $DEPLOY_HOST "docker pull ${PROJECT_NAME}/frontend:latest"
- ssh $DEPLOY_HOST "docker run -d --name um-coin-info --network host --restart always -e ASPNETCORE_ENVIRONMENT='Staging' -v /var/log/um-coin-info:/app/Logs ${PROJECT_NAME}/coin-info:latest"
- ssh $DEPLOY_HOST "docker run -d --name um-control-center --network host --restart always -e ASPNETCORE_ENVIRONMENT='Staging' -v /var/log/um-control-center:/app/Logs ${PROJECT_NAME}/control-center:latest"
- ssh $DEPLOY_HOST "docker run -d --name um-frontend --network host --restart always -e ASPNETCORE_ENVIRONMENT='Staging' -v /var/log/um-frontend:/app/Logs ${PROJECT_NAME}/frontend:latest"
after_script:
- ssh $DEPLOY_HOST 'docker logout registry.gitlab.com'
environment:
name: staging
only:
- master
dependencies: []