[Feat] SSL 인증서 자동 갱신 로직 개선 (certbot-renew 추가 및 certbot 수정) #104
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



1. PR 설명
기존
docker-compose.yml설정은certbot서비스가 자체적으로 갱신 스케줄링을 시도하고, 새로 추가하려는certbot-renew서비스가 별도로 갱신을 시도하는 중복/충돌 문제가 있었습니다.가장 치명적인 문제는, 만약
certbot의 자체 스케줄러가 먼저 갱신에 성공할 경우, Nginx를 리로드(reload)하는 로직이 없어 실제 서비스에 새 인증서가 적용되지 않는 심각한 오류가 발생할 수 있다는 점입니다.이 PR은
certbot-renew를 전용 스케줄러로 사용하고, 기존certbot은 단순 실행기로 역할을 변경하여 이러한 문제를 근본적으로 해결하고 SSL 갱신 프로세스를 안정화합니다.2. 주요 변경 사항
A.
certbot-renew서비스 추가 (신규)docker:cli이미지와docker.sock을 사용해 다른 컨테이너(certbot, nginx)를 오케스트레이션하는 헬퍼 컨테이너를 추가합니다.B.
certbot서비스 수정 (변경)certbot서비스의entrypoint에서 자체 스케줄링 로직을 제거하고, 단순히 컨테이너가 대기 상태로 살아있도록 변경합니다.certbot: image: certbot/certbot:latest container_name: certbot restart: always logging: driver: json-file options: max-size: "10m" max-file: "5" tag: "{{.Name}}" depends_on: nginx: condition: service_healthy volumes: - ./certbot/data:/var/www/certbot:rw - ./certbot/conf:/etc/letsencrypt/:rw # ... (최초 발급 관련 주석) ... - entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12d & wait $${!}; done;'" + entrypoint: "tail -f /dev/null"3. 변경된 동작 방식 (Architecture)
certbot(실행기):entrypoint가tail -f /dev/null로 변경되었습니다.certbot-renew(스케줄러):while루프가 실행됩니다.docker exec certbot certbot renewcertbot컨테이너 내부에서 갱신 명령을 실행합니다.&& docker exec nginx nginx -s reloadnginx컨테이너에게nginx -s reload명령을 내려 새 인증서를 적용시킵니다.sleep 12d4. 기대 효과
certbot은 파일/프로그램 저장소,certbot-renew는 자동화 스케줄러로 역할이 명확해집니다.