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
16 changes: 13 additions & 3 deletions .github/workflows/cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
context: .
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/spot-backend:prod
${{ secrets.DOCKERHUB_USERNAME }}/spot-backend:${{ github.sha }}
${{ secrets.DOCKERHUB_USERNAME }}/realmatch-backend:prod
${{ secrets.DOCKERHUB_USERNAME }}/realmatch-backend:${{ github.sha }}

- name: Deploy
uses: appleboy/ssh-action@v1.0.3
Expand All @@ -46,7 +46,17 @@ jobs:
username: ubuntu
key: ${{ secrets.PROD_SERVER_SSH_KEY }}
script: |
cd /home/ubuntu/spot
cd /home/ubuntu/realmatch
git pull origin main

docker compose pull
docker compose up -d

echo "Waiting for app to start..."
sleep 10

if ! docker compose ps | grep "Up"; then
echo "❌ Container is not running"
docker compose logs
exit 1
fi
22 changes: 12 additions & 10 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ jobs:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:16
mysql:
image: mysql:8.0
env:
POSTGRES_DB: myapp_db
POSTGRES_USER: admin
POSTGRES_PASSWORD: secret
MYSQL_DATABASE: test_db
MYSQL_USER: test_user
MYSQL_PASSWORD: test
MYSQL_ROOT_PASSWORD: test_root
ports:
- 5432:5432
- 3306:3306
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-cmd="mysqladmin ping -h 127.0.0.1 -uroot -ptest_root"
--health-interval=10s
--health-timeout=5s
--health-retries=5


env:
SPRING_PROFILES_ACTIVE: test
Expand Down
3 changes: 0 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ dependencies {

// swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.9'

// postgresql (CI test 용)
runtimeOnly 'org.postgresql:postgresql'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public class SecurityConfig {
private final JwtAuthenticationFilter jwtAuthenticationFilter;

private static final String[] PERMIT_ALL_URL_ARRAY = {
"/api/v1/test",
"/api/test",
"/v3/api-docs/**", "/swagger-ui/**", "/swagger-resources/**", "/swagger-ui.html"
};

private static final String[] REQUEST_AUTHENTICATED_ARRAY = {
"/api/v1/test-auth"
"/api/test-auth"
};

@Value("${cors.allowed-origin}")
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ server:

spring:
application:
name: Spot
name: Realmatch
activate:
on-profile: prod

Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ server:

spring:
application:
name: Spot
name: Realmatch

datasource:
url: jdbc:postgresql://localhost:5432/myapp_db
username: admin
password: secret
driver-class-name: org.postgresql.Driver
url: jdbc:mysql://localhost:3306/test_db
username: test_user
password: test
Comment on lines +16 to +17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

테스트용이라 할지라도 데이터베이스 자격 증명을 소스 코드에 직접 포함하는 것은 보안상 위험할 수 있습니다. 이 정보가 유출될 경우를 대비하여, 환경 변수를 통해 주입하는 방식을 사용하는 것이 좋습니다. application-prod.yml에서 사용하는 방식과 같이 환경 변수를 사용하도록 변경하는 것을 권장합니다.

    username: ${TEST_DB_USERNAME}
    password: ${TEST_DB_PASSWORD}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI에서만 뜨는 임시 MySQL 컨테이너이기 때문에, 유출되어도 크게 보안상 위험하지 않을 것 같습니다.
실제 배포 DB 연결은 CD 워크플로우에서 수행합니다.

driver-class-name: com.mysql.cj.jdbc.Driver
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

데이터베이스 드라이버를 MySQL로 올바르게 변경하셨지만, 관련 설정인 JPA Hibernate dialect가 여전히 PostgreSQL로 되어 있습니다 (31번째 줄: dialect: org.hibernate.dialect.PostgreSQLDialect). 이 설정은 test 프로파일에서 애플리케이션이 시작되지 않거나 쿼리 실행 시 오류를 발생시키는 원인이 됩니다. prod 프로파일과 같이 org.hibernate.dialect.MySQL8Dialect로 수정해야 합니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정 완료

hikari:
maximum-pool-size: 10
minimum-idle: 5
Expand All @@ -28,7 +28,7 @@ spring:
ddl-auto: none
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
dialect: org.hibernate.dialect.MySQL8Dialect
format_sql: true
show-sql: false

Expand Down