-
Notifications
You must be signed in to change notification settings - Fork 20
feat : 컨테이너 테스트 환경 구축을 위한 docker-compose 작성 #887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # 1. Zulu OpenJDK 17 기반 이미지 사용 | ||
| FROM azul/zulu-openjdk-alpine:17 | ||
|
|
||
| # 2. 작업 디렉토리 생성 | ||
| WORKDIR /app | ||
|
|
||
| # 3. jar 파일 복사 (빌드 결과물에 맞게 경로 조정) | ||
| COPY app-main/build/libs/*.jar app.jar | ||
|
|
||
| # 4. 리소스 및 환경 파일 복사 | ||
| COPY /app-main/src/main/resources/application-local.yml /app/src/main/resources/application.yml | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기서 local.yml이 복사되는게 맞나요?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵! 맞습니다 |
||
| COPY /app-main/src/main/resources/dongnae_firebase_key.json /app/src/main/resources/dongnae_firebase_key.json | ||
|
Comment on lines
+11
to
+12
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| # 5. 애플리케이션 실행 | ||
| ENTRYPOINT ["java", "-jar", "app.jar"] | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| services: | ||
| mysql: | ||
| image: mysql:8.0 | ||
| container_name: db_caucse_mysql | ||
| environment: | ||
| MYSQL_ROOT_PASSWORD: 1234 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
프로젝트 루트에 |
||
| MYSQL_DATABASE: db_caucse | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이부분은 패스워드가 담겨있는데 민감정보류는 제외하고 작성해주셔야할 것 같습니다.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 서버에 배포하기 위한 값이 아닌 로컬에서 테스트를 위해 사용하는 것이기 때문에 크게 문제가 되진 않을 것 같습니다. 추가로 패스워드의 경우도 직접 설정을 바꿔서 사용도 가능합니다.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 로컬 테스트용이면 괜찮을 것 같습니다. |
||
| TZ: Asia/Seoul | ||
| ports: | ||
| - "3308:3306" | ||
| volumes: | ||
| - ./mysql_data:/var/lib/mysql | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "mysqladmin ping -h localhost -u root -p1234"] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 5 | ||
|
|
||
| redis: | ||
| image: redis:latest | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| container_name: db_caucse_redis | ||
| ports: | ||
| - "6379:6379" | ||
| volumes: | ||
| - ./redis_data:/data | ||
| healthcheck: | ||
| test: ["CMD", "redis-cli", "ping"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 5 | ||
|
|
||
| app: | ||
| build: | ||
| context: . | ||
| dockerfile: app-main/Dockerfile | ||
| container_name: db_caucse_app | ||
| depends_on: | ||
| mysql: | ||
| condition: service_healthy | ||
| redis: | ||
| condition: service_healthy | ||
| ports: | ||
| - "8080:8080" | ||
| environment: | ||
GY102912 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| SPRING_DATA_REDIS_HOST: redis | ||
| SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/db_caucse?serverTimezone=Asia/Seoul&characterEncoding=UTF-8 | ||
| SPRING_PROFILES_ACTIVE: local | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -57,3 +57,28 @@ | |||||
| ## Contact | ||||||
|
|
||||||
| **Email** : <a href="mailto:caucsedongne@gmail.com">caucsedongne@gmail.com</a> | ||||||
|
|
||||||
| ## Docker Compose를 이용한 테스트 환경 구축 및 사용법 | ||||||
|
|
||||||
| ### 1. app-main 빌드 | ||||||
|
|
||||||
| > 변경된 코드나 의존성이 있을 경우 이미지를 다시 빌드해야 합니다. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "app-main 빌드" 섹션에서 코드 변경 시 이미지를 다시 빌드해야 한다고 설명하고 있지만, 구체적인 명령어가 없어 사용자에게 혼동을 줄 수 있습니다. 이미지 재빌드를 포함하여 컨테이너를 실행하는
Suggested change
|
||||||
|
|
||||||
| ### 2. 컨테이너 및 볼륨 정리 (선택 사항) | ||||||
|
|
||||||
| > docker compose down -v | ||||||
|
|
||||||
| - **설명:** | ||||||
| 모든 컨테이너와 네트워크, **그리고 연결된 볼륨까지 모두 삭제**할 때 사용합니다. | ||||||
| - DB를 초기화하거나, 깨끗한 환경에서 테스트를 진행하고 싶을 때 유용합니다. | ||||||
| - 일부 데이터(예: DB 볼륨)를 보존하려면 `-v` 옵션 없이 `docker compose down`만 실행하세요. | ||||||
|
|
||||||
| ### 3. 컨테이너 실행 | ||||||
|
|
||||||
| > docker compose up | ||||||
|
|
||||||
| - **설명:** | ||||||
| `docker-compose.yml`에 정의된 모든 서비스가 실행됩니다. | ||||||
| - 백그라운드(Detached) 모드로 실행하려면: | ||||||
|
|
||||||
| > docker compose up -d | ||||||
Uh oh!
There was an error while loading. Please reload this page.