Skip to content

Commit 934fd87

Browse files
authored
Merge pull request #15 from samhap-soft/develop
[Infra] - PROD 배포
2 parents 6d47f01 + 8c4caa8 commit 934fd87

94 files changed

Lines changed: 3367 additions & 168 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/cd-api-dev.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: CD API DEV
2+
3+
on:
4+
push:
5+
branches: [ develop ]
6+
7+
jobs:
8+
detect-changes:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
api_changed: ${{ steps.filter.outputs.api }}
12+
steps:
13+
- uses: actions/checkout@v4
14+
- id: filter
15+
uses: dorny/paths-filter@v3
16+
with:
17+
base: develop
18+
filters: |
19+
api:
20+
- 'api/**'
21+
22+
build-api:
23+
needs: detect-changes
24+
if: needs.detect-changes.outputs.api_changed == 'true'
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Set up JDK 17
29+
uses: actions/setup-java@v4
30+
with:
31+
distribution: 'corretto'
32+
java-version: '17'
33+
34+
- name: Grant execute permission for gradlew
35+
run: chmod +x gradlew
36+
37+
- name: Grant execute permission for run-test-mysql-redis.sh
38+
run: chmod +x run-test-mysql-redis.sh
39+
working-directory: ./domain
40+
41+
- name: Run test mysql redis script
42+
run: ./run-test-mysql-redis.sh
43+
working-directory: ./domain
44+
45+
- name: Test & Build api only
46+
run: ./gradlew :api:build
47+
48+
- name: Sign in Dockerhub
49+
uses: docker/login-action@v3
50+
with:
51+
username: ${{ secrets.DOCKER_USERNAME }}
52+
password: ${{ secrets.DOCKER_PASSWORD }}
53+
54+
- name: Build the Docker image
55+
run: docker build -f ./Dockerfile --platform linux/amd64 --no-cache -t samhap/kokomen-notification-api:dev .
56+
working-directory: ./api
57+
58+
- name: Push the Docker Image to Dockerhub
59+
run: docker push samhap/kokomen-notification-api:dev
60+
working-directory: ./api
61+
62+
deploy-api:
63+
needs: build-api
64+
runs-on: [ self-hosted, dev-notification ]
65+
steps:
66+
- name: Stop existing container
67+
run: sudo docker rm -f kokomen-notification-dev-api || true
68+
69+
- name: Remove old API Docker image
70+
run: |
71+
if sudo docker images samhap/kokomen-notification-api:dev -q | grep -q .; then
72+
sudo docker rmi -f samhap/kokomen-notification-api:dev || true
73+
fi
74+
75+
- name: pull docker compose yaml files
76+
working-directory: /home/ubuntu
77+
run: |
78+
[ -d kokomen-notification ] || git clone --filter=blob:none --no-checkout https://github.com/samhap-soft/kokomen-notification.git
79+
cd kokomen-notification
80+
git sparse-checkout init --cone
81+
git fetch origin develop
82+
git checkout develop
83+
git sparse-checkout set docker/dev
84+
git pull origin develop
85+
86+
- name: Docker Image pull
87+
run: sudo docker pull samhap/kokomen-notification-api:dev
88+
89+
- name: Docker run
90+
working-directory: /home/ubuntu
91+
env:
92+
MYSQL_ROOT_PASSWORD_DEV: ${{ secrets.MYSQL_ROOT_PASSWORD_DEV }}
93+
SPRING_DATASOURCE_USERNAME_DEV: ${{ secrets.SPRING_DATASOURCE_USERNAME_DEV }}
94+
SPRING_DATASOURCE_PASSWORD_DEV: ${{ secrets.SPRING_DATASOURCE_PASSWORD_DEV }}
95+
run: |
96+
export HOSTNAME=$(hostname)
97+
cd kokomen-notification/docker/dev
98+
sudo -E docker compose -f docker-compose-dev.yml up -d kokomen-notification-dev-api kokomen-notification-mysql-dev

.github/workflows/cd-api-prod.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: CD API PROD
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
detect-changes:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
api_changed: ${{ steps.filter.outputs.api }}
12+
steps:
13+
- uses: actions/checkout@v4
14+
- id: filter
15+
uses: dorny/paths-filter@v3
16+
with:
17+
base: main
18+
filters: |
19+
api:
20+
- 'api/**'
21+
22+
build-api:
23+
needs: detect-changes
24+
if: needs.detect-changes.outputs.api_changed == 'true'
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Set up JDK 17
29+
uses: actions/setup-java@v4
30+
with:
31+
distribution: 'corretto'
32+
java-version: '17'
33+
34+
- name: Grant execute permission for gradlew
35+
run: chmod +x gradlew
36+
37+
- name: Grant execute permission for run-test-mysql-redis.sh
38+
run: chmod +x run-test-mysql-redis.sh
39+
working-directory: ./domain
40+
41+
- name: Run test mysql redis script
42+
run: ./run-test-mysql-redis.sh
43+
working-directory: ./domain
44+
45+
- name: Test & Build api only
46+
run: ./gradlew :api:build
47+
48+
- name: Sign in Dockerhub
49+
uses: docker/login-action@v3
50+
with:
51+
username: ${{ secrets.DOCKER_USERNAME }}
52+
password: ${{ secrets.DOCKER_PASSWORD }}
53+
54+
- name: Build the Docker image
55+
run: docker build -f ./Dockerfile --platform linux/arm64 --no-cache -t samhap/kokomen-notification-api:prod .
56+
working-directory: ./api
57+
58+
- name: Push the Docker Image to Dockerhub
59+
run: docker push samhap/kokomen-notification-api:prod
60+
working-directory: ./api
61+
62+
deploy-api:
63+
needs: build-api
64+
runs-on: [ self-hosted, prod-notification ]
65+
66+
strategy:
67+
matrix:
68+
runner: [ prod-notification-a, prod-notification-b ]
69+
70+
steps:
71+
- name: Stop existing container
72+
run: sudo docker rm -f kokomen-notification-api || true
73+
74+
- name: Remove old API Docker image
75+
run: |
76+
if sudo docker images samhap/kokomen-notification-api:prod -q | grep -q .; then
77+
sudo docker rmi -f samhap/kokomen-notification-api:prod || true
78+
fi
79+
80+
- name: pull docker compose yaml files
81+
working-directory: /home/ubuntu
82+
run: |
83+
[ -d kokomen-notification ] || git clone --filter=blob:none --no-checkout https://github.com/samhap-soft/kokomen-notification.git
84+
cd kokomen-notification
85+
git sparse-checkout init --cone
86+
git fetch origin main
87+
git checkout main
88+
git sparse-checkout set docker/prod
89+
git pull origin main
90+
91+
- name: Docker Image pull
92+
run: sudo docker pull samhap/kokomen-notification-api:prod
93+
94+
- name: Docker run
95+
working-directory: /home/ubuntu
96+
run: |
97+
export HOSTNAME=$(hostname)
98+
cd kokomen-notification/docker/prod
99+
sudo -E docker compose -f docker-compose-prod.yml up -d kokomen-notification-api
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: CD INTERNAL DEV
2+
3+
on:
4+
push:
5+
branches: [ develop ]
6+
7+
jobs:
8+
detect-changes:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
internal_changed: ${{ steps.filter.outputs.internal }}
12+
steps:
13+
- uses: actions/checkout@v4
14+
- id: filter
15+
uses: dorny/paths-filter@v3
16+
with:
17+
base: develop
18+
filters: |
19+
internal:
20+
- 'internal/**'
21+
22+
build-internal:
23+
needs: detect-changes
24+
if: needs.detect-changes.outputs.internal_changed == 'true'
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Set up JDK 17
29+
uses: actions/setup-java@v4
30+
with:
31+
distribution: 'corretto'
32+
java-version: '17'
33+
34+
- name: Grant execute permission for gradlew
35+
run: chmod +x gradlew
36+
37+
- name: Grant execute permission for run-test-mysql-redis.sh
38+
run: chmod +x run-test-mysql-redis.sh
39+
working-directory: ./domain
40+
41+
- name: Run test mysql redis script
42+
run: ./run-test-mysql-redis.sh
43+
working-directory: ./domain
44+
45+
- name: Test & Build internal only
46+
run: ./gradlew :internal:build
47+
48+
- name: Sign in Dockerhub
49+
uses: docker/login-action@v3
50+
with:
51+
username: ${{ secrets.DOCKER_USERNAME }}
52+
password: ${{ secrets.DOCKER_PASSWORD }}
53+
54+
- name: Build the Docker image
55+
run: docker build -f ./Dockerfile --platform linux/amd64 --no-cache -t samhap/kokomen-notification-internal:dev .
56+
working-directory: ./internal
57+
58+
- name: Push the Docker Image to Dockerhub
59+
run: docker push samhap/kokomen-notification-internal:dev
60+
working-directory: ./internal
61+
62+
deploy-internal:
63+
needs: build-internal
64+
runs-on: [ self-hosted, dev-notification ]
65+
steps:
66+
- name: Stop existing container
67+
run: sudo docker rm -f kokomen-notification-dev-internal || true
68+
69+
- name: Remove old INTERNAL Docker image
70+
run: |
71+
if sudo docker images samhap/kokomen-notification-internal:dev -q | grep -q .; then
72+
sudo docker rmi -f samhap/kokomen-notification-internal:dev || true
73+
fi
74+
75+
- name: pull docker compose yaml files
76+
working-directory: /home/ubuntu
77+
run: |
78+
[ -d kokomen-notification ] || git clone --filter=blob:none --no-checkout https://github.com/samhap-soft/kokomen-notification.git
79+
cd kokomen-notification
80+
git sparse-checkout init --cone
81+
git fetch origin develop
82+
git checkout develop
83+
git sparse-checkout set docker/dev
84+
git pull origin develop
85+
86+
- name: Docker Image pull
87+
run: sudo docker pull samhap/kokomen-notification-internal:dev
88+
89+
- name: Docker run
90+
working-directory: /home/ubuntu
91+
env:
92+
MYSQL_ROOT_PASSWORD_DEV: ${{ secrets.MYSQL_ROOT_PASSWORD_DEV }}
93+
SPRING_DATASOURCE_USERNAME_DEV: ${{ secrets.SPRING_DATASOURCE_USERNAME_DEV }}
94+
SPRING_DATASOURCE_PASSWORD_DEV: ${{ secrets.SPRING_DATASOURCE_PASSWORD_DEV }}
95+
run: |
96+
export HOSTNAME=$(hostname)
97+
cd kokomen-notification/docker/dev
98+
sudo -E docker compose -f docker-compose-dev.yml up -d kokomen-notification-dev-internal kokomen-notification-mysql-dev
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: CD INTERNAL PROD
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
detect-changes:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
internal_changed: ${{ steps.filter.outputs.internal }}
12+
steps:
13+
- uses: actions/checkout@v4
14+
- id: filter
15+
uses: dorny/paths-filter@v3
16+
with:
17+
base: main
18+
filters: |
19+
internal:
20+
- 'internal/**'
21+
22+
build-internal:
23+
needs: detect-changes
24+
if: needs.detect-changes.outputs.internal_changed == 'true'
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Set up JDK 17
29+
uses: actions/setup-java@v4
30+
with:
31+
distribution: 'corretto'
32+
java-version: '17'
33+
34+
- name: Grant execute permission for gradlew
35+
run: chmod +x gradlew
36+
37+
- name: Grant execute permission for run-test-mysql-redis.sh
38+
run: chmod +x run-test-mysql-redis.sh
39+
working-directory: ./domain
40+
41+
- name: Run test mysql redis script
42+
run: ./run-test-mysql-redis.sh
43+
working-directory: ./domain
44+
45+
- name: Test & Build internal only
46+
run: ./gradlew :internal:build
47+
48+
- name: Sign in Dockerhub
49+
uses: docker/login-action@v3
50+
with:
51+
username: ${{ secrets.DOCKER_USERNAME }}
52+
password: ${{ secrets.DOCKER_PASSWORD }}
53+
54+
- name: Build the Docker image
55+
run: docker build -f ./Dockerfile --platform linux/arm64 --no-cache -t samhap/kokomen-notification-internal:prod .
56+
working-directory: ./internal
57+
58+
- name: Push the Docker Image to Dockerhub
59+
run: docker push samhap/kokomen-notification-internal:prod
60+
working-directory: ./internal
61+
62+
deploy-internal:
63+
needs: build-internal
64+
runs-on: [ self-hosted, prod-notification ]
65+
66+
strategy:
67+
matrix:
68+
runner: [ prod-notification-a, prod-notification-b ]
69+
70+
steps:
71+
- name: Stop existing container
72+
run: sudo docker rm -f kokomen-notification-internal || true
73+
74+
- name: Remove old INTERNAL Docker image
75+
run: |
76+
if sudo docker images samhap/kokomen-notification-internal:prod -q | grep -q .; then
77+
sudo docker rmi -f samhap/kokomen-notification-internal:prod || true
78+
fi
79+
80+
- name: pull docker compose yaml files
81+
working-directory: /home/ubuntu
82+
run: |
83+
[ -d kokomen-notification ] || git clone --filter=blob:none --no-checkout https://github.com/samhap-soft/kokomen-notification.git
84+
cd kokomen-notification
85+
git sparse-checkout init --cone
86+
git fetch origin main
87+
git checkout main
88+
git sparse-checkout set docker/prod
89+
git pull origin main
90+
91+
- name: Docker Image pull
92+
run: sudo docker pull samhap/kokomen-notification-internal:prod
93+
94+
- name: Docker run
95+
working-directory: /home/ubuntu
96+
run: |
97+
export HOSTNAME=$(hostname)
98+
cd kokomen-notification/docker/prod
99+
sudo -E docker compose -f docker-compose-prod.yml up -d kokomen-notification-internal

0 commit comments

Comments
 (0)