Skip to content

Commit 525a866

Browse files
authored
(#45) 인프라 보안 강화 및 데이터 보존 정책 설정
* 인프라 보안 강화 및 데이터 보존 정책 설정 - Prometheus 데이터 보존 기간 30일 명시 설정 - Loki compactor 활성화 및 로그 보존 기간 30일 설정 - Dockerfile 비root 사용자(appuser) 실행 및 management 포트 노출 - 내부 서비스 포트(DB, Prometheus, Loki, Actuator) 127.0.0.1 바인딩 - .dockerignore 추가하여 불필요한 빌드 컨텍스트 제외 - Loki datasource에 editable 속성 추가 * Dockerfile COPY --chown 레이어 최적화 및 Loki delete_request_store 설정 추가
1 parent 1124779 commit 525a866

5 files changed

Lines changed: 36 additions & 7 deletions

File tree

.dockerignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.git
2+
.github
3+
.gitignore
4+
.dockerignore
5+
6+
build/
7+
.gradle/
8+
9+
dashboards/
10+
alerting/
11+
*.yml
12+
!build.gradle
13+
!settings.gradle
14+
15+
README.md
16+
LICENSE

Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ RUN ./gradlew bootJar -x test --no-daemon
1717

1818
FROM eclipse-temurin:21-jre-alpine
1919

20+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
21+
2022
WORKDIR /app
2123

22-
COPY --from=builder /app/build/libs/*.jar app.jar
24+
COPY --chown=appuser:appgroup --from=builder /app/build/libs/*.jar app.jar
25+
26+
USER appuser
2327

24-
EXPOSE 8080
28+
EXPOSE 8080 9090
2529

2630
ENTRYPOINT ["java", "-jar", "app.jar"]

datasource.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ datasources:
1313
type: loki
1414
uid: loki
1515
access: proxy
16-
url: http://loki:3100
16+
url: http://loki:3100
17+
editable: true

docker-compose.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
restart: unless-stopped
66
ports:
77
- "8080:8080"
8-
- "9090:9090"
8+
- "127.0.0.1:9090:9090"
99
environment:
1010
SPRING_PROFILES_ACTIVE: prod
1111
DB_URL: jdbc:mysql://git-ranker-db:3306/${DB_NAME}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul
@@ -49,7 +49,7 @@ services:
4949
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
5050
TZ: Asia/Seoul
5151
ports:
52-
- "3306:3306"
52+
- "127.0.0.1:3306:3306"
5353
volumes:
5454
- mysql_data:/var/lib/mysql
5555
deploy:
@@ -73,12 +73,13 @@ services:
7373
- ./prometheus.yml:/etc/prometheus/prometheus.yml
7474
- prometheus_data:/prometheus
7575
ports:
76-
- "9091:9090"
76+
- "127.0.0.1:9091:9090"
7777
command:
7878
- '--config.file=/etc/prometheus/prometheus.yml'
7979
- '--storage.tsdb.path=/prometheus'
8080
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
8181
- '--web.console.templates=/usr/share/prometheus/consoles'
82+
- '--storage.tsdb.retention.time=30d'
8283
deploy:
8384
resources:
8485
limits:
@@ -94,7 +95,7 @@ services:
9495
container_name: git-ranker-loki
9596
restart: unless-stopped
9697
ports:
97-
- "3100:3100"
98+
- "127.0.0.1:3100:3100"
9899
volumes:
99100
- ./loki-config.yml:/etc/loki/local-config.yml
100101
- loki_data:/loki

loki-config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,19 @@ schema_config:
3131
prefix: index_
3232
period: 24h
3333

34+
compactor:
35+
working_directory: /loki/compactor
36+
retention_enabled: true
37+
compaction_interval: 10m
38+
delete_request_store: filesystem
39+
3440
limits_config:
3541
allow_structured_metadata: true
3642
reject_old_samples: false
3743
reject_old_samples_max_age: 168h
3844
ingestion_rate_mb: 16
3945
ingestion_burst_size_mb: 32
46+
retention_period: 30d
4047

4148
query_range:
4249
results_cache:

0 commit comments

Comments
 (0)