-
Notifications
You must be signed in to change notification settings - Fork 3
101 lines (90 loc) · 3.25 KB
/
SERVER-DEPLOY.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
name: SERVER-DEPLOY
on:
push:
paths:
- "server/**"
branches:
- main
pull_request:
paths:
- "server/**"
branches:
- main
types:
- closed
defaults:
run:
working-directory: "./server"
jobs:
build-image:
name: Deploy MSA
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./server/gateway/Dockerfile
image: jinsungguri/FanUP-gateway
- dockerfile: ./server/services/auth/Dockerfile
image: jinsungguri/FanUP-auth
- dockerfile: ./server/services/core/Dockerfile
image: jinsungguri/FanUP-core
- dockerfile: ./server/services/ticket/Dockerfile
image: jinsungguri/FanUP-ticket
steps:
- name: Checkout source code.
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ matrix.image }}
tags: |
type=raw,value=latest
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
CD:
needs: build-image
name: Continuous-Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: copy file via ssh password
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
source: ./server/docker-compose.yaml
target: /root/fanup
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
script: |
cd ./fanup/server
docker rm -f $(docker ps -aq) && docker image rm -f $(docker image ls -q)
docker pull redis:alpine
docker run --name fanup-redis -p 6379:6379 --network fanup -d redis:alpine redis-server --appendonly yes
docker-compose -f docker-compose.yaml up -d
docker run --env-file /root/fanup/server/auth/.env -p 3001:3001 -p 4001:4001 --network fanup --name fanup-auth -d jinsungguri/fanup-auth:latest
docker run --env-file /root/fanup/server/ticket/.env -p 3003:3003 --network fanup --name fanup-ticket -d jinsungguri/fanup-ticket:latest
docker run -p 3000:3000 --network fanup --name fanup-gateway -d jinsungguri/fanup-gateway:latest
docker run --env-file /root/fanup/server/core/.env -p 3002:3002 -p 4002:4002 --network fanup --name fanup-core -d jinsungguri/fanup-core:latest