Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CD

on:
push:
branches: [ main ]

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Amazon ECR
uses: aws-actions/amazon-ecr-login@v2

- name: Build Docker image
run: |
docker build -t focussu-backend:latest ./backend
docker tag focussu-backend:latest ${{ secrets.ECR_REPO_URI }}:latest

- name: Push Docker image
run: docker push ${{ secrets.ECR_REPO_URI }}:latest

- name: Run deploy script
run: bash ./deploy/deploy-prod.sh
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ap-northeast-2
BACKEND_IMAGE: ${{ secrets.ECR_REPO_URI }}:latest
SPRING_PROFILES_ACTIVE: prod
RDS_ENDPOINT: ${{ secrets.RDS_ENDPOINT }}
RDS_PORT: ${{ secrets.RDS_PORT }}
RDS_DATABASE: ${{ secrets.RDS_DATABASE }}
RDS_USER: ${{ secrets.RDS_USER }}
RDS_PASSWORD: ${{ secrets.RDS_PASSWORD }}
KAFKA_BOOTSTRAP_SERVERS: ${{ secrets.KAFKA_BOOTSTRAP_SERVERS }}

29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
pull_request:
branches: [ main ]

jobs:
build-only:
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./backend

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin

- name: Grant execute permission to Gradle wrapper
run: chmod +x gradlew

- name: Build without tests
run: ./gradlew build -x test --no-daemon
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# === Secret Config Files (DO NOT COMMIT) ===
/.env
/backend/src/main/resources/application-secret.yml
/backend/src/main/resources/application-dev.yml
/backend/.idea/


Expand Down
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ RUN gradle clean build -x test --no-daemon
FROM openjdk:17-slim
WORKDIR /app
COPY --from=builder /app/build/libs/*.jar app.jar
EXPOSE 8080
EXPOSE 80
ENTRYPOINT ["java", "-jar", "app.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDateTime;

@MappedSuperclass
@Getter
@Setter
public abstract class BaseEntity {

@CreationTimestamp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public class SwaggerConfig {
@Bean
public OpenAPI openAPI() {
Server localServer = new Server()
.url("http://localhost:8080")
.url("http://localhost:80")
.description("Local 서버");

Server prodServer = new Server()
.url("https://focussu-api.life")
.description("개발 서버");
.url("https://focussu-api.com")
.description("프로덕션 서버");

// Bearer 토큰을 위한 스키마 설정
SecurityScheme bearerScheme = new SecurityScheme()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ public class StudyRoomQueryService {
private final StudyRoomRepository studyRoomRepository;

public StudyRoomCreateResponse getStudyRoom(Long id) {
// TODO: 예외 커스텀
StudyRoom studyRoom = studyRoomRepository.findById(id)
.orElseThrow(() -> new IllegalArgumentException("존재하지 않는 회원입니다."));
.orElseThrow(() -> new IllegalArgumentException("존재하지 않는 스터디룸입니다."));
return StudyRoomCreateResponse.from(studyRoom);
}
}
19 changes: 10 additions & 9 deletions backend/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# src/main/resources/application-dev.yml

server:
port: 8080
port: 80

spring:
config:
import: optional:classpath:application-secret.yml

application:
name: focussu-backend

datasource:
url: jdbc:mysql://focussu-mysql:3306/focussu-db?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
username: admin
password: wlqwndgo1!
driver-class-name: com.mysql.cj.jdbc.Driver

jpa:
Expand All @@ -31,14 +32,14 @@ spring:
listener:
missing-topics-fatal: false

data:
redis:
port: 6379
host: redis

springdoc:
default-produces-media-type: application/json
api-docs:
resolve-schema-properties: true
swagger-ui:
path: /docs

security:
jwt:
secret-key: de740246db0e808088253b1bbd8afb062dfcf5e661f20cb41cc7283366d1d8fcccbdbacf3ef8af9ac7159c9ac3a4302fc2321dba0d510a5695a62dd9728ea1ade417542d25e6d80312bc66b13852621f3be0a0188c9e122fedb30186455a4ee2f6ad6bf6daac10db65e9386f3bdf099bee7a18f2e1ef572ab212d7c3a87248d5f1e55243559adfc539df7a2d9110840a825ef27d14899ce630eed7e5366485b642d0f516f468b20af3a6bd67051f00be7a27f122c785f80091bcff6e510330a6f3f30629397a4439281559647cd9c6922d560fd2bd158b527357ff01377eb5333ea9e77f48908b9f96781eaa0fc5f67e7fa4d54d6088ef26c61e43ffb647412b
expiration-time: 86400
40 changes: 40 additions & 0 deletions backend/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# src/main/resources/application-prod.yml

spring:
config:
import: optional:application-secret.yml

application:
name: focussu-backend

datasource:
url: jdbc:mysql://${RDS_ENDPOINT}:${RDS_PORT}/${RDS_DATABASE}?serverTimezone=UTC
driver-class-name: com.mysql.cj.jdbc.Driver

jpa:
hibernate:
ddl-auto: none
show-sql: false
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL8Dialect

kafka:
bootstrap-servers: ${KAFKA_BOOTSTRAP_SERVERS}
properties:
security.protocol: SSL

server:
port: 80

springdoc:
default-produces-media-type: application/json
api-docs:
resolve-schema-properties: true
swagger-ui:
path: /docs

security:
jwt:
secret-key: ${JWT_SECRET_KEY}
expiration-time: ${JWT_EXPIRATION_TIME}
7 changes: 7 additions & 0 deletions backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# src/main/resources/application.yml

spring:
profiles:
active: prod
config:
import: optional:classpath:application-secret.yml