Skip to content

Commit 7182adc

Browse files
committed
[Feat] Deploy backend server using Naver Cloud Platform
1 parent 49fd29b commit 7182adc

6 files changed

Lines changed: 50 additions & 17 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: boombim CI/CD
1+
name: boombimapi CI/CD
22

33
on:
44
push:
55
branches:
6-
- main
6+
- feat#3
77

88
jobs:
99
build-and-deploy:
@@ -14,13 +14,13 @@ jobs:
1414
- name: Check out repository
1515
uses: actions/checkout@v2
1616

17-
# (2) ENV 파일 생성
17+
# (2) .env 파일 생성
1818
- name: Create env files
1919
run: |
2020
mkdir -p env
2121
echo "${{ secrets.ENV_VARS }}" > env/prod.env
2222
23-
# (3) JDK 17 세팅
23+
# (3) JDK 17 설치
2424
- name: Set up JDK 17
2525
uses: actions/setup-java@v2
2626
with:
@@ -31,7 +31,7 @@ jobs:
3131
- name: Grant execute permission for gradlew
3232
run: chmod +x gradlew
3333

34-
# (5) Gradle 빌드 (테스트 스킵)
34+
# (5) Gradle 빌드 (테스트 제외)
3535
- name: Build with Gradle (skip tests)
3636
run: ./gradlew clean build -x test
3737

@@ -50,8 +50,8 @@ jobs:
5050
run: |
5151
docker push ${{ secrets.DOCKERFILE_USERNAME }}/${{ secrets.DOCKERFILE_REPO_NAME }}:latest
5252
53-
# (8.5) EC2에 boombim 디렉토리 생성
54-
- name: Create directory on EC2
53+
# (9) NCP 인스턴스에 boombim 디렉토리 생성
54+
- name: Create directory on NCP Instance
5555
uses: appleboy/ssh-action@master
5656
with:
5757
host: ${{ secrets.SERVER_HOST }}
@@ -60,8 +60,8 @@ jobs:
6060
script: |
6161
mkdir -p /home/ubuntu/boombim
6262
63-
# (8.6) docker-compose.yml 파일 EC2로 복사
64-
- name: Copy docker-compose.yml to EC2
63+
# (10) docker-compose.yml 복사
64+
- name: Copy docker-compose.yml to NCP Instance
6565
uses: appleboy/scp-action@master
6666
with:
6767
host: ${{ secrets.SERVER_HOST }}
@@ -70,8 +70,8 @@ jobs:
7070
source: "docker-compose.yml"
7171
target: "/home/ubuntu/boombim"
7272

73-
# (8.7) .env 파일 EC2로 복사
74-
- name: Copy .env file to EC2
73+
# (11) .env 파일 복사
74+
- name: Copy .env file to NCP Instance
7575
uses: appleboy/scp-action@master
7676
with:
7777
host: ${{ secrets.SERVER_HOST }}
@@ -80,8 +80,8 @@ jobs:
8080
source: "env/prod.env"
8181
target: "/home/ubuntu/boombim/.env"
8282

83-
# (9) SSH로 서버 접속 후 컨테이너 실행
84-
- name: Deploy to Server
83+
# (12) Docker 컨테이너 실행
84+
- name: Deploy on NCP Instance
8585
uses: appleboy/ssh-action@master
8686
with:
8787
host: ${{ secrets.SERVER_HOST }}

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM openjdk:17
2+
ARG JAR_FILE=build/libs/*.jar
3+
COPY ${JAR_FILE} /app.jar
4+
COPY env/prod.env /env/prod.env
5+
EXPOSE 8080
6+
ENTRYPOINT ["java", "-jar", "/app.jar"]

docker-compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
image: chltmdgh522/boombimapi:latest
6+
ports:
7+
- "8080:8080"
8+
environment:
9+
- SPRING_PROFILES_ACTIVE=prod
10+
- REDIS_HOST=redis # 컨테이너 이름으로 설정
11+
- REDIS_PORT=6379
12+
- REDIS_PASSWORD=${REDIS_PASSWORD}
13+
depends_on:
14+
- redis
15+
16+
redis:
17+
image: redis
18+
command: ["redis-server", "--requirepass", "${REDIS_PASSWORD}"]
19+
ports:
20+
- "6379:6379"
21+
environment:
22+
- REDIS_PASSWORD=${REDIS_PASSWORD}

src/main/java/boombimapi/domain/user/domain/entity/User.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
@Entity
1515
@NoArgsConstructor
1616
@DynamicUpdate
17+
@Table(name = "member")
1718
public class User {
1819
@Id
1920
@Column(unique = true, nullable = false)

src/main/resources/application-prod.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ spring:
77
- file:env/prod.env[.properties]
88

99
datasource:
10-
url: ${MYSQL_URL}
11-
username: ${MYSQL_USER}
12-
password: ${MYSQL_PASSWORD}
10+
url: ${DB_URL}
11+
username: ${DB_USER}
12+
password: ${DB_PASSWORD}
1313
jpa:
1414
hibernate:
1515
ddl-auto: update
16+
properties:
17+
hibernate:
18+
default_schema: boombim
19+
1620

1721
servlet:
1822
multipart:

src/main/resources/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
spring:
22
profiles:
3-
active: dev
3+
active: prod

0 commit comments

Comments
 (0)