Skip to content

refactor: docker-compose.dev.yml에 mysql 컨테이너 추가#690

Merged
Hexeong merged 2 commits intosolid-connection:developfrom
Hexeong:refactor/689-move-stage-db-from-rds-to-mysql-container
Mar 3, 2026
Merged

refactor: docker-compose.dev.yml에 mysql 컨테이너 추가#690
Hexeong merged 2 commits intosolid-connection:developfrom
Hexeong:refactor/689-move-stage-db-from-rds-to-mysql-container

Conversation

@Hexeong
Copy link
Contributor

@Hexeong Hexeong commented Mar 3, 2026

관련 이슈

작업 내용

  • refactor: docker-compose.dev.yml에 mysql 컨테이너 추가

특이 사항

  1. 처음 작업할 때 dev-cd에도 영향이 갈 것 같았지만, paramter store로 secret들을 옮기고 나니 굳이, cd 스크립트를 변경할 필요가 없을 것 같아. docker-compose-dev.yml만 변경하여 작업하였습니다.
  2. 이후의 작업 순서는 다음과 같습니다.
    • 머지 이후, 생겨난 mysql 컨테이너에 user 생성 및 권한 추가(볼륨을 설정하여 재배포해도 user 정보는 사라지지 않습니다.)
    • paramter store의 dev.datasource 값을 localhost:3306을 바라보게 수정
    • 이후, 다시 dev-cd 액션을 실행하여 stage 환경의 springboot app이 mysql 컨테이너를 바라보도록 변경
    • stage rds 제거

리뷰 요구사항 (선택)

  • 해당 작업 반영을 위한 제 계획을 위에 써두었습니다. 해당 작업 계획에 대해서 더 나은 방법이 있다면 가감 없이 부탁드립니다.

@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 358690d and 54d9464.

📒 Files selected for processing (1)
  • docker-compose.dev.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • docker-compose.dev.yml

Walkthrough

1. MySQL 이미지 기반 서비스 추가 — 개발용 Docker Compose에 mysql:8.0 이미지를 사용하는 새로운 서비스가 추가되었습니다.
2. 컨테이너 식별 설정 — 새 서비스의 컨테이너 이름은 solid-connection-dev-mysql로 지정되었습니다.
3. 데이터베이스 초기 구성 — MYSQL_DATABASE=solid_connectionMYSQL_ALLOW_EMPTY_PASSWORD 환경변수가 설정되었습니다.
4. 포트 노출 — 서비스는 호스트와 통신을 위해 포트 3306을 노출합니다.
5. 데이터 영속성 확보 — 로컬 디렉토리 ./mysql_data_dev가 컨테이너의 /var/lib/mysql로 마운트됩니다.
6. 자동 재시작 정책 — restart: always로 서비스가 항상 재시작되도록 설정되어 있습니다.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • wibaek
  • whqtker
  • JAEHEE25
  • lsy1307
  • sukangpunch
  • Gyuhyeok99
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 제목은 주요 변경사항인 docker-compose.dev.yml에 mysql 컨테이너 추가를 명확하게 요약하고 있습니다.
Description check ✅ Passed PR 설명은 필수 섹션(관련 이슈, 작업 내용, 특이 사항)을 모두 포함하고 있으며, 이후 작업 계획까지 상세히 기술되어 있습니다.
Linked Issues check ✅ Passed PR에서 구현한 docker-compose.dev.yml의 MySQL 컨테이너 추가는 #689의 핵심 요구사항을 충족합니다. MYSQL_ALLOW_EMPTY_PASSWORD 설정 추가도 컨테이너 초기화에 필요합니다.
Out of Scope Changes check ✅ Passed 변경사항은 docker-compose.dev.yml에 MySQL 컨테이너 추가로 제한되어 있으며, #689의 요구사항 범위 내에서 진행되었습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
docker-compose.dev.yml (1)

17-26: 레이스 컨디션 방지를 위해 헬스체크와 조건부 의존성 추가를 권장합니다.

MySQL이 완전히 준비되기 전에 앱이 시작되는 것을 방지하려면 다음과 같이 설정하세요:

  1. MySQL 서비스에 헬스체크 추가

    • mysqladmin ping 명령으로 TCP 연결 여부를 주기적으로 확인합니다.
    • start_period: 30s로 초기 부팅 시간을 충분히 확보합니다 (MySQL 초기화 완료 대기).
  2. 앱 서비스에 조건부 의존성 설정

    • depends_on에서 condition: service_healthy를 사용하면, MySQL 헬스체크가 성공할 때까지만 앱 컨테이너를 시작합니다.
제안 diff
 services:
   solid-connection-dev:
     image: ghcr.io/${OWNER_LOWERCASE}/solid-connection-dev:${IMAGE_TAG:-latest}
     container_name: solid-connection-dev
     network_mode: "host"
+    depends_on:
+      mysql:
+        condition: service_healthy
     environment:
       - SPRING_PROFILES_ACTIVE=dev
       - AWS_REGION=ap-northeast-2
@@
   mysql:
     image: mysql:8.0
     container_name: solid-connection-dev-mysql
     environment:
       MYSQL_DATABASE: solid_connection
     ports:
       - "3306:3306"
     volumes:
       - ./mysql_data_dev:/var/lib/mysql
+    healthcheck:
+      test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--protocol=TCP", "--silent"]
+      interval: 10s
+      timeout: 5s
+      retries: 10
+      start_period: 30s
     restart: always

참고: Docker Compose v2는 Compose Specification을 따르므로, compose file 버전 3.8에서도 condition: service_healthy 문법을 완벽하게 지원합니다. 재배포 시 안정성을 크게 높일 수 있습니다.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docker-compose.dev.yml` around lines 17 - 26, Add a healthcheck to the mysql
service using a mysqladmin ping command with a generous start_period (e.g.,
start_period: 30s) and appropriate interval/retries so Compose can mark mysql
healthy only after it’s ready, and update your application service’s depends_on
to use condition: service_healthy referencing the mysql service (i.e., add
depends_on: mysql: condition: service_healthy in your app service) so the app
container waits for the mysql service healthcheck to succeed before starting.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docker-compose.dev.yml`:
- Around line 22-23: The MySQL port mapping in the docker-compose service
currently exposes 0.0.0.0 via the ports entry ("3306:3306"); change the ports
mapping for the MySQL service to bind to loopback (e.g., "127.0.0.1:3306:3306")
so the container only listens on localhost. Locate the MySQL service's ports
stanza (the line containing "3306:3306") and replace that mapping with a
loopback-bound mapping, then restart the compose stack to apply the change.
- Around line 20-21: The docker-compose service's environment block currently
only sets MYSQL_DATABASE and is missing the required root password variables;
update the environment for the MySQL service by adding one of the required vars
(preferably MYSQL_ROOT_PASSWORD with a secure value), or for dev-only
alternatives add MYSQL_RANDOM_ROOT_PASSWORD: 'yes' or
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' to satisfy the mysql:8.0 initializer; ensure
the change is placed in the same environment section alongside MYSQL_DATABASE so
the container can initialize correctly.

---

Nitpick comments:
In `@docker-compose.dev.yml`:
- Around line 17-26: Add a healthcheck to the mysql service using a mysqladmin
ping command with a generous start_period (e.g., start_period: 30s) and
appropriate interval/retries so Compose can mark mysql healthy only after it’s
ready, and update your application service’s depends_on to use condition:
service_healthy referencing the mysql service (i.e., add depends_on: mysql:
condition: service_healthy in your app service) so the app container waits for
the mysql service healthcheck to succeed before starting.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 61aba25 and 358690d.

📒 Files selected for processing (1)
  • docker-compose.dev.yml

@Hexeong Hexeong merged commit cd40ddd into solid-connection:develop Mar 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: stage 환경에 대해서 CD 스크립트 할때 DB를 rds가 아닌 docker-compose의 mysql 컨테이너에 의존하도록 수정

2 participants