Skip to content

Commit 3ff0da4

Browse files
authored
Merge pull request #5 from Nexters/feat/add-dev-server
feat: 개발 환경 서버 CICD 설정 추가
2 parents ee1cd94 + 3f6c665 commit 3ff0da4

File tree

4 files changed

+98
-1
lines changed

4 files changed

+98
-1
lines changed

.github/workflows/claude-code-review.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
on:
22
pull_request:
33
types: [opened, synchronize]
4+
branches:
5+
- main
46

57
jobs:
68
claude-review:

.github/workflows/deploy-dev.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
Deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Get Github Repository Files
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Docker Buildx
16+
uses: docker/setup-buildx-action@v3
17+
18+
- name: Login to Docker Hub
19+
uses: docker/login-action@v3
20+
with:
21+
username: ${{secrets.DOCKER_USERNAME}}
22+
password: ${{secrets.DOCKER_TOKEN}}
23+
24+
- name: Build and Push Docker Image
25+
uses: docker/build-push-action@v5
26+
with:
27+
context: .
28+
platforms: linux/amd64,linux/arm64
29+
push: true
30+
tags: ${{secrets.DOCKER_USERNAME}}/climbup-server:dev-latest
31+
32+
- name: Prepare Server Directory
33+
uses: appleboy/[email protected]
34+
with:
35+
host: ${{secrets.DEV_HOST}}
36+
username: ${{secrets.USERNAME}}
37+
# password: ${{secrets.PASSWORD}}
38+
key: ${{secrets.DEV_KEY}}
39+
script: mkdir -p ~/apps/climbup-server/
40+
41+
- name: Copy Project Files to Server
42+
uses: appleboy/scp-action@v1
43+
with:
44+
host: ${{secrets.DEV_HOST}}
45+
username: ${{secrets.USERNAME}}
46+
# password: ${{secrets.PASSWORD}}
47+
key: ${{secrets.DEV_KEY}}
48+
source: "docker-compose.dev.yaml"
49+
target: "~/apps/climbup-server/"
50+
strip_components: 0
51+
52+
- name: Deploy Application
53+
uses: appleboy/[email protected]
54+
with:
55+
host: ${{secrets.DEV_HOST}}
56+
username: ${{secrets.USERNAME}}
57+
# password: ${{secrets.PASSWORD}}
58+
key: ${{secrets.DEV_KEY}}
59+
script_stop: true
60+
script: |
61+
cd ~/apps/climbup-server
62+
echo "${{secrets.ENV}}" > .env
63+
source .env
64+
docker compose -f docker-compose.dev.yaml down
65+
docker compose -f docker-compose.dev.yaml pull
66+
docker compose -f docker-compose.dev.yaml up -d

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Deploy
33
on:
44
push:
55
branches:
6-
- main
6+
- prod
77

88
jobs:
99
Deploy:

docker-compose.dev.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
services:
2+
db:
3+
image: postgres:latest
4+
environment:
5+
- POSTGRES_DB=${POSTGRES_DB:-db}
6+
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-password}
7+
- POSTGRES_USER=${POSTGRES_USER:-root}
8+
volumes:
9+
- ./climbup-db-data:/var/lib/postgresql/data
10+
ports:
11+
- 5433:5432
12+
healthcheck:
13+
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-root} -d ${POSTGRES_DB:-db}"]
14+
interval: 10s
15+
timeout: 5s
16+
retries: 5
17+
18+
server:
19+
image: ${DOCKER_USERNAME}/climbup-server:dev-latest
20+
environment:
21+
- DB_URL=jdbc:postgresql://db:5432/${POSTGRES_DB:-db}
22+
- DB_USERNAME=${POSTGRES_USER:-root}
23+
- DB_PASSWORD=${POSTGRES_PASSWORD:-password}
24+
ports:
25+
- 9090:8080
26+
depends_on:
27+
db:
28+
condition: service_healthy
29+
restart: unless-stopped

0 commit comments

Comments
 (0)