Skip to content
Open
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
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ dependencies {

// Monitoring
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'
implementation 'io.micrometer:micrometer-registry-statsd'
Copy link
Contributor

Choose a reason for hiding this comment

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

음..의존성 변경의 의미가 수집하여 반환하는 형식이 변경되었다~ 정도로 이해하고 있는데 맞을까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

맞아요~ 기존에는 Datadog Agent가 WAS에 요청을 보내서 가져가는 형식이었음
이번에는 WAS에서 Datadog Agent로 보내는 형식으로 변경함 (블루-그린 적용해도 로그 수집이 원활이 되도록 함)


// DB schema manager
implementation 'org.flywaydb:flyway-mysql'
Expand All @@ -81,6 +81,10 @@ bootJar {
dependsOn("openapi3")
}

jar {
enabled = false
}

jacoco {
toolVersion = '0.8.9'
}
Expand Down
17 changes: 17 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM eclipse-temurin:17-jdk-alpine AS builder
WORKDIR /workspace
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
RUN java -Djarmode=layertools -jar app.jar extract

FROM eclipse-temurin:17-jre-alpine
WORKDIR /workspace

ADD https://dtdg.co/latest-java-tracer ./dd-java-agent.jar
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

Datadog dd-java-agent latest releases 2025 GitHub

💡 Result:

Latest Datadog dd-java-agent releases in 2025 (as reflected by the DataDog/dd-trace-java GitHub release tags and Maven Central publish dates):

  • v1.56.1Nov 25, 2025 (latest in 2025) [1] [2]
  • v1.55.0Nov 04, 2025 [1] [3]
  • v1.53.0Sep 04, 2025 [1] [4]
  • v1.52.1Aug 14, 2025 [1] [5]
  • v1.52.0Aug 04, 2025 [1] [6]
  • v1.51.1Jul 15, 2025 [1] [7]
  • v1.50.0Jun 20, 2025 [1] [8]
  • v1.48.2Apr 23, 2025 [1] [9]
  • v1.48.0Apr 09, 2025 [1] [10]

Sources: GitHub releases list (DataDog/dd-trace-java) [1] plus per-version Maven Central publish dates via MvnRepository [2]-[10].


🌐 Web query:

Docker ADD checksum verification best practices

💡 Result:

Best practices for checksum verification with ADD

  1. Prefer COPY for local files; use ADD mainly for remote/Git sources. Docker recommends COPY when bringing files from the build context, and using ADD when you intentionally need remote downloads (and want better caching + built-in checksum validation). [2]

  2. Use ADD --checksum for remote artifacts (HTTP) instead of curl/wget | sha256sum in RUN.

    • For HTTP(S) sources, --checksum verifies a SHA-256 digest in the form sha256:<hash> (SHA-256 is the only supported algorithm). [1]
      Example:
    # syntax=docker/dockerfile:1.6
    ADD --checksum=sha256:<expected_sha256> https://example.com/tool.tgz /tmp/tool.tgz

    This makes integrity checking part of the Dockerfile instruction and improves cache correctness versus ad-hoc RUN scripts. [2]

  3. For Git sources, pin by commit and verify with --checksum (commit SHA).
    With BuildKit’s Git URL support, ADD --checksum=<commit_sha> lets you verify the fetched repo state (checksum is the commit SHA; prefix matching is allowed). [1]
    Example:

    # syntax=docker/dockerfile:1.6
    ADD --checksum=<commit_sha> https://github.com/org/repo.git#<ref> /src/repo
  4. Pin the Dockerfile syntax version to ensure --checksum is available and stable.
    ADD --checksum requires Dockerfile syntax 1.6+. Pinning avoids surprises from syntax feature changes. [1]

  5. Combine with multi-stage builds to avoid leaving downloaded installers/tarballs in the final image.
    Docker’s best-practices show downloading with ADD --checksum in a source stage, then extracting/copying only what you need into the final stage. [2]

Notes / gotchas

  • ADD --checksum is specifically designed for remote HTTP and Git resources in the modern Dockerfile reference. [1]
  • ADD has other remote-related behavior (auto-unpacking local tar, Git URL fragments, etc.); use it intentionally to avoid unexpected results. [1]

Sources: Dockerfile ADD --checksum reference and examples [1], Docker Dockerfile best practices guidance and sample pattern [2], Dockerfile release notes (feature graduation around Dockerfile 1.6 / BuildKit) [3].


🏁 Script executed:

#!/bin/bash
# Check if there's any reference to Datadog agent versions in the codebase
cd /tmp && git clone --depth 1 https://github.com/DataDog/dd-trace-java.git 2>/dev/null || true
ls -la dd-trace-java/releases 2>/dev/null | head -20 || echo "Check via web for releases"

Repository: debate-timer/debate-timer-be

Length of output: 54


원격 URL에서 에이전트 다운로드 시 보안 및 재현성 개선 필요

ADD로 단축 URL(dtdg.co)에서 직접 다운로드하면 다음 문제가 발생합니다:

  1. 체크섬 검증 없음 - 무결성 보장 불가
  2. 버전 고정 없음 - 빌드 재현성 없음
  3. 단축 URL 사용 - 리다이렉트 대상 변경 시 예측 불가능
♻️ 개선 제안

특정 버전을 명시하고 체크섬 검증을 추가하세요:

# syntax=docker/dockerfile:1.6
ARG DD_AGENT_VERSION=1.56.1
ADD --checksum=sha256:<hash> https://github.com/DataDog/dd-trace-java/releases/download/v${DD_AGENT_VERSION}/dd-java-agent-${DD_AGENT_VERSION}.jar ./dd-java-agent.jar

GitHub 릴리스에서 각 JAR의 SHA256 해시를 확인하여 <hash>를 치환하세요. --checksum을 사용하려면 Dockerfile 문법 버전을 1.6 이상으로 설정해야 합니다.

🤖 Prompt for AI Agents
In `@docker/Dockerfile` at line 10, The Dockerfile currently uses ADD with a
shortened URL to fetch dd-java-agent.jar, which lacks version pinning and
checksum verification; update the Dockerfile to set the Dockerfile syntax to 1.6
or newer, introduce an ARG like DD_AGENT_VERSION and use the full GitHub release
URL for dd-java-agent-${DD_AGENT_VERSION}.jar, and add the ADD
--checksum=sha256:<expected-hash> ... ./dd-java-agent.jar flag to verify
integrity (replace <expected-hash> with the SHA256 from the GitHub release) so
builds are reproducible and secure.

Choose a reason for hiding this comment

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

medium

ADD 명령어로 latest 버전의 Datadog 에이전트를 직접 다운로드하고 있습니다. latest 태그는 언제든지 변경될 수 있어 빌드의 재현성을 해칠 수 있습니다. 특정 버전을 명시하여 안정성을 높이는 것을 권장합니다. 또한, URL에서 직접 파일을 ADD하는 것보다 RUNwget 또는 curl을 사용하면 캐시 동작을 더 명확하게 제어할 수 있습니다.

RUN wget -O ./dd-java-agent.jar https://dtdg.co/latest-java-tracer


Copy link
Contributor

Choose a reason for hiding this comment

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

문서화할 때 지금 전부다 jar로 마는 거랑 얼마나 효율화되었는지 수치로 나타내봐도 좋을듯!

COPY --from=builder /workspace/dependencies/ ./
COPY --from=builder /workspace/spring-boot-loader/ ./
COPY --from=builder /workspace/snapshot-dependencies/ ./
COPY --from=builder /workspace/application/ ./

ENTRYPOINT ["java", "-javaagent:./dd-java-agent.jar", "org.springframework.boot.loader.launch.JarLauncher"]
30 changes: 30 additions & 0 deletions docker/docker-compose.datadog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
services:
datadog-agent:
image: gcr.io/datadoghq/agent:7

Choose a reason for hiding this comment

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

medium

agent:7 이미지 태그는 7.x.x 버전 중 가장 최신 버전을 가리키는 부동 태그(floating tag)입니다. 이로 인해 의도치 않은 에이전트 버전 업데이트가 발생하여 예기치 않은 문제가 생길 수 있습니다. 7.54.0과 같이 특정 버전을 명시하여 빌드의 재현성과 안정성을 확보하는 것을 권장합니다.

    image: gcr.io/datadoghq/agent:7.54.0

container_name: datadog-agent
environment:
- DD_API_KEY=${DD_API_KEY}
- DD_SITE=us5.datadoghq.com
- DD_APM_ENABLED=true
- DD_APM_NON_LOCAL_TRAFFIC=true
- DD_APM_IGNORE_RESOURCES=/monitoring/health
- DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true
- DD_LOGS_ENABLED=true
- DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true
- DD_PROCESS_AGENT_ENABLED=true
- DD_TAGS=env:${ENV:-dev},project:debate-timer
ports:
- "8125:8125/udp" # Metrics (StatsD)
Copy link
Contributor

Choose a reason for hiding this comment

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

일단 데이터독 docker compose 이미지로 만드니까 확실히 문서화 효과가 있어서 좋은 것 같아유.

그런데 데이터 독 배경지식이 없어서 그런데 메트릭은 udp, apm은 tcp로 소통하는 이유가 있나요? 아니면 데이터 독 자체 스펙인가?

Copy link
Member Author

Choose a reason for hiding this comment

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

추후 문서화 예정이라 대략적인 제미나이의 답변 공유드립니다.

1. 포트 8125 (UDP) - DogStatsD (Metrics)

  • 역할: 메트릭(Metrics) 데이터를 수집하는 입구입니다.
  • 프로토콜: UDP (User Datagram Protocol)
  • 데이터 종류:
    • CPU 사용량, 메모리, 힙 메모리 사용량 (Micrometer가 보내는 데이터)
    • "사용자 로그인 횟수", "게시글 작성 수" 같은 커스텀 카운터/게이지
  • 특징 (Fire and Forget):
    • 애플리케이션은 데이터를 던지기만 하고, Agent가 잘 받았는지 확인하지 않습니다.
  • 이유: 메트릭 수집 때문에 애플리케이션의 성능이 느려지거나 멈추는 것을 방지하기 위함입니다. Agent가 죽어있어도 앱은 에러를 내지 않고 그냥 패킷을 유실시킵니다.

2. 포트 8126 (TCP) - Trace Agent (APM)

  • 역할: 트레이스(Trace/APM) 데이터를 수집하는 입구입니다.
  • 프로토콜: TCP (HTTP)
  • 데이터 종류:
    • API 요청의 흐름 (Controller -> Service -> DB)
    • SQL 쿼리 내용, 에러 스택 트레이스
    • 각 구간별 소요 시간 (Span)
  • 특징 (Reliability):
    • 트레이스 데이터는 JSON 형태의 큰 데이터이며 구조가 중요하기 때문에, 데이터의 신뢰성이 보장되는 TCP 통신을 사용합니다.
    • Java Agent(dd-java-agent.jar)가 내부적으로 이 포트로 HTTP 요청을 보냅니다.

- "8126:8126/tcp" # APM (Trace)
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro # 로그 수집 필수
- /proc/:/host/proc/:ro
- /sys/fs/cgroup/:/host/sys/fs/cgroup/:ro
networks:
- debate-timer-net
healthcheck:
test: ["CMD", "agent", "health"]
interval: 60s
timeout: 10s
retries: 5
start_period: 120s
75 changes: 75 additions & 0 deletions docker/docker-compose.spring.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
x-app-template: &app-template
image: debatetimer/debate_timer:${ENV:-dev}
environment:
- SERVER_FORWARD_HEADERS_STRATEGY=framework
- SPRING_PROFILES_ACTIVE=${PROFILE:-dev,monitor}
- TZ=Asia/Seoul

- DD_AGENT_HOST=datadog-agent
- DD_SERVICE=debate-timer
- DD_ENV=${ENV:-dev}
- DD_VERSION=1.0.0

Choose a reason for hiding this comment

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

medium

Datadog 서비스 버전(DD_VERSION)이 1.0.0으로 하드코딩되어 있습니다. 이 경우 배포 버전이 변경되어도 Datadog 대시보드에서는 항상 동일한 버전으로 표시됩니다. CI/CD 파이프라인에서 Git 태그나 커밋 해시 등을 동적으로 주입하여, 배포된 애플리케이션의 버전을 정확하게 추적할 수 있도록 개선하는 것을 권장합니다.

    - DD_VERSION=${APP_VERSION:-1.0.0}

- DD_LOGS_INJECTION=true
- DD_PROFILING_ENABLED=true
- DD_PROFILING_ALLOCATION_ENABLED=true
- DD_PROFILING_HEAP_ENABLED=true

- MANAGEMENT_STATSD_METRICS_EXPORT_ENABLED=true
- MANAGEMENT_STATSD_METRICS_EXPORT_FLAVOR=datadog
- MANAGEMENT_STATSD_METRICS_EXPORT_HOST=datadog-agent
- MANAGEMENT_STATSD_METRICS_EXPORT_PORT=8125
- MANAGEMENT_STATSD_METRICS_EXPORT_PROTOCOL=UDP

networks:
- debate-timer-net

depends_on:
traefik:
condition: service_healthy
datadog-agent:
condition: service_healthy

healthcheck:
test: [ "CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8083/monitoring/health" ]
interval: 60s
retries: 5
start_period: 300s

services:
app-blue:
<<: *app-template
container_name: app-blue
labels:
- "traefik.enable=true"
- "traefik.http.routers.app-blue.rule=Host(`api.${ENV:-dev}.debate-timer.com`)"
- "traefik.http.routers.app-blue.entrypoints=websecure"
- "traefik.http.routers.app-blue.tls=true"
- "traefik.http.routers.app-blue.tls.certresolver=myresolver"
- "traefik.http.services.app-blue.loadbalancer.server.port=8080"
- "traefik.http.routers.app-blue.service=app-blue"

- "traefik.http.routers.app-blue-monitor.rule=PathPrefix(`/`)"
- "traefik.http.routers.app-blue-monitor.entrypoints=monitoring"
- "traefik.http.routers.app-blue-monitor.service=app-blue-monitor-svc"
- "traefik.http.services.app-blue-monitor-svc.loadbalancer.server.port=8083"

- "com.datadoghq.ad.logs=[{\"source\": \"java\", \"service\": \"debate-timer\"}]"

app-green:
<<: *app-template
container_name: app-green
labels:
- "traefik.enable=true"
- "traefik.http.routers.app-green.rule=Host(`api.${ENV:-dev}.debate-timer.com`)"
- "traefik.http.routers.app-green.entrypoints=websecure"
- "traefik.http.routers.app-green.tls=true"
- "traefik.http.routers.app-green.tls.certresolver=myresolver"
- "traefik.http.services.app-green.loadbalancer.server.port=8080"
- "traefik.http.routers.app-green.service=app-green"

- "traefik.http.routers.app-green-monitor.rule=PathPrefix(`/`)"
- "traefik.http.routers.app-green-monitor.entrypoints=monitoring"
- "traefik.http.routers.app-green-monitor.service=app-green-monitor-svc"
- "traefik.http.services.app-green-monitor-svc.loadbalancer.server.port=8083"

- "com.datadoghq.ad.logs=[{\"source\": \"java\", \"service\": \"debate-timer\"}]"
39 changes: 39 additions & 0 deletions docker/docker-compose.traefik.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
services:
traefik:
image: traefik:v2.11
container_name: traefik
ports:
- "80:80"
- "443:443"
- "8080:8080"
- "8083:8083"
environment:
- DOCKER_API_VERSION=1.44
command:
- "--api.insecure=true"

Choose a reason for hiding this comment

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

critical

Traefik API 및 대시보드를 인증 없이(--api.insecure=true) 활성화하고 포트 8080을 외부에 노출하고 있습니다. 이는 서버의 네트워크 구성, 라우팅 규칙 등 민감한 정보가 외부에 그대로 노출되는 심각한 보안 취약점입니다. 운영 환경에서는 Basic Auth와 같은 인증을 설정하거나, 포트 포워딩(8080:8080)을 제거하여 외부 접근을 차단하는 것을 강력히 권장합니다.

- "--ping=true"
- "--log.level=INFO"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"

- "--entrypoints.web.address=:80"
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
- "--entrypoints.web.http.redirections.entryPoint.scheme=https"
- "--entrypoints.websecure.address=:443"

- "--certificatesresolvers.myresolver.acme.tlschallenge=true"
- "--certificatesresolvers.myresolver.acme.email=debatetimekeeping@gmail.com"

Choose a reason for hiding this comment

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

high

Let's Encrypt 인증서 발급에 사용되는 이메일 주소가 코드에 하드코딩되어 있습니다. 이메일 주소는 민감 정보로 취급될 수 있으므로, 환경 변수로 분리하여 관리하는 것이 안전합니다.

      - "--certificatesresolvers.myresolver.acme.email=${ACME_EMAIL}"

Copy link
Contributor

Choose a reason for hiding this comment

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

내 이메일 주소 ㅠㅠ

Certbot 없이 자동으로 발급받고 관리해주네... 미쳤다.. 확실히 편한듯

Copy link
Member Author

@leegwichan leegwichan Feb 8, 2026

Choose a reason for hiding this comment

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

이거 노출되고 크게 문제 없는 정보니까, 이렇게 그대로 해도 되겠죠?

-> 그대로 가도 괜찮을듯 ㅇㅇ

Choose a reason for hiding this comment

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

medium

Let's Encrypt 인증서 발급에 사용되는 이메일 주소가 하드코딩되어 있습니다. 이메일 주소는 환경에 따라 달라지거나 변경될 수 있으므로, .env 파일과 환경 변수를 사용하여 관리하는 것이 더 유연하고 안전합니다.

      - "--certificatesresolvers.myresolver.acme.email=${ACME_EMAIL}"

- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"

- "--entrypoints.monitoring.address=:8083"
healthcheck:
test: ["CMD", "wget", "--spider", "--quiet", "http://localhost:8080/ping"]
interval: 60s
timeout: 10s
retries: 5
start_period: 120s
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ../letsencrypt:/letsencrypt

Choose a reason for hiding this comment

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

medium

../letsencrypt와 같이 상대 경로를 사용하여 볼륨을 마운트하고 있습니다. docker-compose 명령어를 실행하는 위치에 따라 경로가 달라질 수 있어 오류를 유발할 수 있습니다. Docker의 네임드 볼륨(named volume)을 사용하면 이 문제를 해결하고 더 안정적으로 데이터를 관리할 수 있습니다.

docker-compose.traefik.yml에서 상대 경로 대신 네임드 볼륨을 지정하고, 최상위 docker-compose.yml 파일에 볼륨을 정의하는 것을 권장합니다.

      - letsencrypt:/letsencrypt

networks:
- debate-timer-net
11 changes: 11 additions & 0 deletions docker/docker-compose.yml
Copy link
Contributor

Choose a reason for hiding this comment

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

단순 질문입니다.

  1. 이렇게 각 컴포넌트별로 yaml을 따로 만든 이유가 있나요?
    2.확장자를 yaml로 한 이유가 있나요?

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. 개인적으로는 각 컴포넌트 성격이 다르기 떄문에 분리되어 있어 읽기는 좋았습니다. 수정할 포인트도 더 잘 확인할 수 있을 것 같다는 생각도 들었구요.
  2. 확장자는 저도 궁금하네요

Copy link
Member Author

Choose a reason for hiding this comment

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

yml 하고 yaml 하고 차이 없어서 아무거나 사용했습니다.
Spring에서 appliction.yml 파일 이용하고 있으니까, yml로 통일할께요~

Copy link
Member Author

@leegwichan leegwichan Feb 8, 2026

Choose a reason for hiding this comment

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

이렇게 각 컴포넌트별로 yaml을 따로 만든 이유가 있나요?

  • 각 컴포넌트 별로 파일을 분리해서, 나중에 작업할 때 용이하게 하기 위해서 작업함
  • 일종의 facade 느낌으로 각 컴포넌트를 분리함

비토 의견

  • 코드 결합도 측면에서 너무 과한 분리라고 느껴진다. (스프링 yml에서 depends on으로 다른 컴포넌트도 있는데 한 파일에서 보는 게 더 편하지않나?)
  • 과연 어떤 컴포넌트가 수정됐는지 쉽게 파악하는게 중요한가? 그만큼 빈번하게 바뀔 요소인가?
  • 컴포넌트의 수정사항은 커밋 메시지나 git의 diff만으로 충분히 파악 가능하지 않나?
  • 결국 단일 파일로 실행할 가능성이 얼마나 될까? 하나의 파일로 하면 알아서 이미 띄어져있는 것은 스킵하고 띄울 거고 왠만해선 전체로 돌릴텐데(spring단일로 실행했다가 나머지 의존성 없으면 또 나머지 돌리는 것보단 첨부터 전체가 편할테니)
    • -> 네트워크 설정 때문에 단일로 실행이 안됨

비토/커찬 논의 결론

  • 둘 다 효용성에 있어 크게 차이가 없다고 판단함
  • 비토 : facade 형식이라면, 각각의 컴포넌트가 docker-compose.yml 파일보다는 하위 폴더에 있었으면 좋겠다. (필수는 아님)
  • 커찬 : 저기에 Dockerfile도 같이 있어서 하위 폴더가 들어가면 조금 애매해질 것 같다.

Copy link
Contributor

Choose a reason for hiding this comment

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

개인의견)

이건 진짜 개인 취향 문제라 생각하긴 하는디... 나는 개인적으로 각 docker compose의 목적이 다르기 때문에 모듈화해두는게 좋다고 생각하기는 하는 것 같아. 단일 파일로 실행할 가능성은 거의 없지만 커밋 내역이나 diff에서도 어떤 파일이 수정되었는지를 기반으로 chnage 추적하기 더 쉬울 것 같기도 함(대충 이 compose 수정되었으면 ~~ 컴포넌트에 수정 있었겠구나를 들어가보지 않고 일단 인지하게 되니까)

또 application-local, application-dev 처럼 하나의 app 컴포넌트 내에서 프로파일이나 성격별로 분리하는게 아니라 각자 별도의 역할을 가진 컴포넌트라는 점에서 분리는 지향되어야 한다고 생각함.

  • traefix : 웹 서버
  • app : 우리가 띄우는 스프링 서버
  • datadog-agent : 모니터링 툴

물론 프로젝트 진행 속도나 인프라 변경이 잦지 않다는 특성을 고려하면 한파일 내에서 모두 모아두어도 추후 유지보수에는 큰 문제는 없을 것 같긴 해서 이건 강하게 주장 못하겠음..


하위폴더:
이건 나도 비토 의견처럼 계층화해두는게 더 좋다고 생각은 하는데 커찬이이야기하는 Dockerfile이 있어서 생기는 하위폴더의 애매모호함이 정확이 어떤 의미인지 캐치를 못해서 한번더 물어보고 싶기도 함..

Copy link
Member Author

Choose a reason for hiding this comment

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

만약에 docker-compose랑 그 하위 파일들까지 전부 나눠서 관리 할 것이라면, Dockerfile 도 다른 폴더로 나눠서 관리하는게 좀 더 통일될 것 같다는 생각이 듦
한 폴더 내에서 관리할 거라면 왠만하면 다 같이 관리하고 폴더를 나눌꺼면 확실하게 나눠 나가는 것을 선호하는 편이라서, 서브 파일들은 하위 폴더로 내리고 또 다른 성격의 파일은 위에서 관리하는게 어색하다고 생각했음

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: debate-timer-server

include:
- docker-compose.traefik.yml
- docker-compose.spring.yml
- docker-compose.datadog.yml

networks:
debate-timer-net:
name: debate-timer-net
driver: bridge
46 changes: 46 additions & 0 deletions scripts/init/auto-swap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

set -e # 스크립트 실행 중 에러 발생 시 즉시 중단 (안전 장치)

# --- 설정 변수 ---
SWAP_FILE="/swapfile"
SWAP_SIZE=${1:-"2G"}
FSTAB_FILE="/etc/fstab"
Comment on lines 5 to 8
Copy link
Contributor

Choose a reason for hiding this comment

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

도커 설치하는 스크립트처럼 최소한 SWAP_SIZE 만이라도 입력으로 받는 건 어떤가요?

Copy link
Member Author

Choose a reason for hiding this comment

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

네, 반영하겠습니다~


# 1. 루트 권한 확인
if [ "$EUID" -ne 0 ]; then
echo "오류: 이 스크립트는 root 권한(sudo)으로 실행해야 합니다."
exit 1
fi

# 2. 기존 스왑 파일 존재 여부 확인
if [ -f "$SWAP_FILE" ]; then
echo "알림: $SWAP_FILE 이 이미 존재합니다."
echo "작업을 중단합니다."
exit 0
fi

echo "=== Swap 메모리 생성 시작 ($SWAP_SIZE) ==="

# 3. Swap 파일 생성
fallocate -l $SWAP_SIZE $SWAP_FILE
echo " -> 파일 생성 완료"

# 4. 권한 설정 (600)
chmod 600 $SWAP_FILE
echo " -> 권한 설정 완료"

# 5. Swap 활성화
mkswap $SWAP_FILE > /dev/null
swapon $SWAP_FILE
echo " -> Swap 활성화 완료"

# 6. /etc/fstab 등록 (재부팅 후에도 유지)
if ! grep -q "$SWAP_FILE" "$FSTAB_FILE"; then
echo "$SWAP_FILE swap swap defaults 0 0" >> "$FSTAB_FILE"
echo " -> fstab 등록 완료 (자동 실행 설정)"
fi

echo "=== 모든 작업이 완료되었습니다 ==="
echo "[현재 메모리 상태]"
free -h
45 changes: 45 additions & 0 deletions scripts/init/init-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

set -e # 스크립트 실행 중 에러 발생 시 즉시 중단 (안전 장치)

DOCKER_USER=$1
DOCKER_TOKEN=$2

echo "=== Docker 설치를 시작합니다 ==="

echo "1. 필수 패키지 설치 및 GPG 키 설정 진행"
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg --yes
sudo chmod a+r /etc/apt/keyrings/docker.gpg

echo "2. 리포지토리 설정 진행"
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

echo "3. Docker Engine 설치 진행"
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

echo "4. 사용자 권한 설정 진행"
sudo usermod -aG docker $USER

echo "5. 로그인 진행 (변수 입력했을 경우에만)"
if [ -n "$DOCKER_USER" ] && [ -n "$DOCKER_TOKEN" ]; then
echo "입력된 정보로 Docker Hub 로그인을 시도합니다..."

if echo "$DOCKER_TOKEN" | sg docker -c "docker login -u \"$DOCKER_USER\" --password-stdin"; then
echo "✅ 로그인 성공! (config.json이 생성되었습니다)"
else
echo "❌ 로그인 실패. 아이디/토큰을 확인하거나 'newgrp docker' 후 다시 시도하세요."
fi
else
echo "로그인 정보가 입력되지 않아 로그인을 건너뜁니다."
echo "추후 'docker login' 명령어로 로그인하세요."
fi

echo "6. Docker 권한이 적용된 새로운 쉘로 전환"
exec newgrp docker
9 changes: 9 additions & 0 deletions scripts/init/init-letsencrypt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

cd "$(dirname "$0")" || exit 1

mkdir -p ../../letsencrypt
touch ../../letsencrypt/acme.json
chmod 600 ../../letsencrypt/acme.json

echo "✅ 스크립트 위치($(pwd))에 letsencrypt 폴더를 생성했습니다."
9 changes: 9 additions & 0 deletions src/main/resources/application-monitor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
management:
statsd:
metrics:
export:
enabled: true
flavor: datadog
host: ${MANAGEMENT_STATSD_METRICS_EXPORT_HOST:localhost}
port: 8125
protocol: UDP

server:
port: 8083

Expand Down