chore: clean up Dockerfile#69
Conversation
|
Warning Review limit reached
More reviews will be available in 38 minutes and 32 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
libvirt-dev/pkg-config설치 제거CGO_ENABLED=0정적 빌드 +-trimpath -ldflags="-s -w"로 바이너리 경량화gcr.io/distroless/static-debian12:nonroot로 교체EXPOSE 8080->EXPOSE 8081, docker compose에서 기대하는 값으로 수정Motivation
libvirt-dev/pkg-config빌드 때, 설치 진행하니 시간과 용량만 잡아먹고 있었습니다.config.yaml의port: 8081로 리스닝하는데EXPOSE 8080이었습니다. 왜 불일치가 났었는지는 모르겠네요.Approach
CGO_ENABLED=0으로 완전 정적 바이너리를 빌드하도록.distroless/static만으로 실행 가능golang:1.24)에서 빌드, runtime(distroless static:nonroot)에 산출물만 복사, uid 65532(nonroot)로 실행해 보안 강화resources/config.yaml)를 위해resources/복사logs/에 로그를 기록하므로 nonroot가 쓸 수 있게--chown=nonroot:nonroot로logs/디렉토리 포함go.mod/go.sum을 먼저 복사해 의존성 레이어 캐시 활용.dockerignore추가로 빌드 컨텍스트에서.git,*.md,logs/,main제외Type of Change
Testing
로컬에서 실제 검증 완료:
docker build성공, 최종 이미지 14.2MBlogs/쓰기 가능.resources/config.yaml폴백 경로를 그대로 사용함을 확인.Checklist