Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 7 additions & 0 deletions .github/workflows/cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
GEMINI_MODEL: ${{ secrets.GEMINI_MODEL }}
DB_BIND_ADDR: ${{ secrets.DB_BIND_ADDR }}
GF_SECURITY_ADMIN_PASSWORD: ${{ secrets.GF_SECURITY_ADMIN_PASSWORD }}
TOSS_MTLS_HOST_DIR: ${{ secrets.TOSS_MTLS_HOST_DIR }}
TOSS_MTLS_CERT_PATH: ${{ secrets.TOSS_MTLS_CERT_PATH }}
TOSS_MTLS_KEY_PATH: ${{ secrets.TOSS_MTLS_KEY_PATH }}
run: |
umask 077
cat > .env <<EOF
Expand All @@ -45,6 +48,10 @@ jobs:
COMPOSE_PROFILES=monitoring
GF_SECURITY_ADMIN_PASSWORD=$GF_SECURITY_ADMIN_PASSWORD
DB_BIND_ADDR=$DB_BIND_ADDR
COMPOSE_FILE=docker-compose.yml:docker-compose.prod.yml
TOSS_MTLS_HOST_DIR=$TOSS_MTLS_HOST_DIR
TOSS_MTLS_CERT_PATH=$TOSS_MTLS_CERT_PATH
TOSS_MTLS_KEY_PATH=$TOSS_MTLS_KEY_PATH
EOF

- name: Deploy
Expand Down
9 changes: 9 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 운영 서버 전용 설정. cd-prod가 .env의 COMPOSE_FILE로 docker-compose.yml과 함께 적용한다.
services:
app:
environment:
TOSS_MTLS_CERT_PATH: ${TOSS_MTLS_CERT_PATH:?}
TOSS_MTLS_KEY_PATH: ${TOSS_MTLS_KEY_PATH:?}
volumes:
# 앱인토스 mTLS 인증서는 저장소에 두지 않고 운영 서버 호스트에만 보관한다.
- ${TOSS_MTLS_HOST_DIR:?}:/secrets/toss:ro
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.nexters.gotggam.global.config;

import java.net.http.HttpClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.ssl.SslBundle;
import org.springframework.boot.ssl.SslBundles;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.JdkClientHttpRequestFactory;
import org.springframework.web.client.RestClient;

// 앱인토스 API는 mTLS로 호출 주체를 식별하므로, 발급받은 클라이언트 인증서를 TLS 핸드셰이크에 실어 보낸다.
@Configuration
@EnableConfigurationProperties(TossApiProperties.class)
@ConditionalOnProperty(prefix = "toss.api", name = "enabled", havingValue = "true")
public class TossApiClientConfig {

@Bean
public RestClient tossApiRestClient(TossApiProperties properties, SslBundles sslBundles) {
SslBundle sslBundle = sslBundles.getBundle(properties.sslBundle());
HttpClient httpClient = HttpClient.newBuilder()
.sslContext(sslBundle.createSslContext())
.build();

return RestClient.builder()
.baseUrl(properties.baseUrl())
.requestFactory(new JdkClientHttpRequestFactory(httpClient))
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.nexters.gotggam.global.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "toss.api")
public record TossApiProperties(
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
boolean enabled,
String baseUrl,
String sslBundle
) {

public TossApiProperties {
if (baseUrl == null || baseUrl.isBlank()) {
baseUrl = "https://apps-in-toss-api.toss.im";
}
if (sslBundle == null || sslBundle.isBlank()) {
sslBundle = "toss";
}
}
}
14 changes: 14 additions & 0 deletions src/main/resources/application-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ spring:
properties:
hibernate:
format_sql: false
# 앱인토스 mTLS 인증서. 호스트의 TOSS_MTLS_HOST_DIR을 컨테이너 /secrets/toss로 마운트한다. (docker-compose.prod.yml)
ssl:
bundle:
pem:
toss:
keystore:
certificate: file:${TOSS_MTLS_CERT_PATH}
private-key: file:${TOSS_MTLS_KEY_PATH}

springdoc:
api-docs:
Expand All @@ -34,9 +42,15 @@ app:
- https://death-client-nine.vercel.app
- https://gotggam.com
- https://dev-api.gotggam.com
- https://gotggam.apps.tossmini.com # 앱인토스 실제 서비스 환경
- https://gotggam.private-apps.tossmini.com # 앱인토스 콘솔 QR 테스트 환경
swagger:
server-url: ${SWAGGER_SERVER_URL:https://api.gotggam.com}

toss:
api:
enabled: true

logging:
level:
root: warn
Expand Down
Loading