-
Notifications
You must be signed in to change notification settings - Fork 0
[HSC-290] 로그 서버 적재 구조와 중앙 배포 연결 #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| .git | ||
| .github | ||
| .gradle | ||
| build | ||
| node_modules | ||
| coverage |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| name: main-deploy-dispatch | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: log-server-main-deploy-dispatch | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| dispatch: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Request central deployment | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: ${{ secrets.CENTRAL_REPO_TOKEN }} | ||
| script: | | ||
| await github.rest.repos.createDispatchEvent({ | ||
| owner: "one-year-gap", | ||
| repo: "infra", | ||
| event_type: "log-server-main-deploy-request", | ||
| client_payload: { | ||
| source_repo: `${context.repo.owner}/${context.repo.repo}`, | ||
| source_sha: context.sha | ||
| } | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| FROM gradle:8.14.3-jdk17 AS builder | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY gradlew gradlew | ||
| COPY gradle gradle | ||
| COPY build.gradle settings.gradle ./ | ||
| COPY src src | ||
|
|
||
| RUN chmod +x gradlew | ||
| RUN ./gradlew bootJar --no-daemon | ||
|
|
||
| FROM eclipse-temurin:17-jre | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY --from=builder /app/build/libs/*.jar app.jar | ||
|
|
||
| EXPOSE 8080 | ||
|
|
||
| ENTRYPOINT ["java", "-jar", "/app/app.jar"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,13 +3,16 @@ | |
| import com.holliverse.logserver.config.properties.KafkaAppProperties; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import org.apache.kafka.clients.CommonClientConfigs; | ||
| import org.apache.kafka.clients.producer.ProducerConfig; | ||
| import org.apache.kafka.common.config.SaslConfigs; | ||
| import org.apache.kafka.common.serialization.StringSerializer; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.kafka.core.DefaultKafkaProducerFactory; | ||
| import org.springframework.kafka.core.KafkaTemplate; | ||
| import org.springframework.kafka.core.ProducerFactory; | ||
| import org.springframework.util.StringUtils; | ||
|
|
||
| @Configuration | ||
| public class KafkaDlqProducerConfig { | ||
|
|
@@ -23,12 +26,34 @@ public KafkaDlqProducerConfig(KafkaAppProperties kafkaAppProperties) { | |
| @Bean | ||
| public ProducerFactory<String, String> dlqProducerFactory() { | ||
| Map<String, Object> props = new HashMap<>(); | ||
| // 브로커 주소 | ||
| props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaAppProperties.getBootstrapServers()); | ||
| // 키 직렬화 | ||
| props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); | ||
| // 값 직렬화 | ||
| props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class); | ||
| // 보안 프로토콜 | ||
| props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, kafkaAppProperties.getSecurity().getProtocol()); | ||
|
|
||
| // 에러 로그는 전송 성공이 중요하므로 기본값 acks=all, retries=3 | ||
| if (StringUtils.hasText(kafkaAppProperties.getSecurity().getSaslMechanism())) { | ||
| // SASL 메커니즘 | ||
| props.put(SaslConfigs.SASL_MECHANISM, kafkaAppProperties.getSecurity().getSaslMechanism()); | ||
| } | ||
| if (StringUtils.hasText(kafkaAppProperties.getSecurity().getSaslJaasConfig())) { | ||
| // JAAS 설정 | ||
| props.put(SaslConfigs.SASL_JAAS_CONFIG, kafkaAppProperties.getSecurity().getSaslJaasConfig()); | ||
| } | ||
| if (StringUtils.hasText(kafkaAppProperties.getSecurity().getSaslCallbackHandlerClass())) { | ||
| // 콜백 핸들러 | ||
| props.put( | ||
| SaslConfigs.SASL_CLIENT_CALLBACK_HANDLER_CLASS, | ||
| kafkaAppProperties.getSecurity().getSaslCallbackHandlerClass() | ||
| ); | ||
| } | ||
|
Comment on lines
+38
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kafka 보안 설정을 구성하는 로직이 |
||
|
|
||
| // DLQ ack 설정 | ||
| props.put(ProducerConfig.ACKS_CONFIG, kafkaAppProperties.getProducer().getDlqAcks()); | ||
| // DLQ retry 설정 | ||
| props.put(ProducerConfig.RETRIES_CONFIG, kafkaAppProperties.getProducer().getDlqRetries()); | ||
|
|
||
| return new DefaultKafkaProducerFactory<>(props); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,14 @@ | |
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
|
|
||
| @SpringBootTest | ||
| @SpringBootTest(properties = { | ||
| "spring.datasource.url=jdbc:h2:mem:logserver;MODE=PostgreSQL;DB_CLOSE_DELAY=-1", | ||
| "spring.datasource.username=sa", | ||
| "spring.datasource.password=", | ||
| "spring.datasource.driver-class-name=org.h2.Driver", | ||
| "spring.jpa.hibernate.ddl-auto=none", | ||
| "app.kafka.listener.auto-startup=false" | ||
| }) | ||
|
Comment on lines
+6
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| class LogServerApplicationTests { | ||
|
|
||
| @Test | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docker 이미지 빌드 시 레이어 캐시를 더 효율적으로 사용하기 위해
COPY명령어의 순서를 조정하는 것이 좋습니다.build.gradle과 같은 의존성 관련 파일을 먼저 복사하고 의존성을 다운로드한 후, 소스 코드를 복사하면 소스 코드만 변경되었을 때 빌드 시간을 단축할 수 있습니다. 예를 들어,build.gradle,settings.gradle,gradlew,gradle디렉토리를 먼저 복사하고RUN ./gradlew dependencies --no-daemon등으로 의존성을 해결한 뒤, 마지막에COPY src src를 하는 방식입니다. 이렇게 하면src디렉토리의 내용이 변경되어도 의존성 레이어는 캐시된 상태로 유지됩니다.