Skip to content
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

CD : docker compose 등록 #14

Merged
merged 3 commits into from
Jul 27, 2023
Merged

CD : docker compose 등록 #14

merged 3 commits into from
Jul 27, 2023

Conversation

yooniversal
Copy link
Contributor

Problem

Github Actions를 통해 EC2로 배포된 jar 파일 실행 시 프로젝트 내부 로직 중 redis 캐시 애노테이션이 포함돼 문제가 발생하고 있었습니다.
다음은 발생한 에러 로그 일부입니다.

2023-07-27T05:18:38.762Z  INFO 24269 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface yeolJyeongKong.mall.repository.FavoriteRepository; If you want this repository to be a Redis repository, consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash (preferred), or consider extending one of the following types with your repository: org.springframework.data.keyvalue.repository.KeyValueRepository
2023-07-27T05:18:38.763Z  INFO 24269 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface yeolJyeongKong.mall.repository.RecentRepository; If you want this repository to be a Redis repository, consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash (preferred), or consider extending one of the following types with your repository: org.springframework.data.keyvalue.repository.KeyValueRepository
2023-07-27T05:18:38.763Z  INFO 24269 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface yeolJyeongKong.mall.repository.TopRepository; If you want this repository to be a Redis repository, consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash (preferred), or consider extending one of the following types with your repository: org.springframework.data.keyvalue.repository.KeyValueRepository
2023-07-27T05:18:38.767Z  INFO 24269 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface yeolJyeongKong.mall.repository.CategoryRepository; If you want this repository to be a Redis repository, consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash (preferred), or consider extending one of the following types with your repository: org.springframework.data.keyvalue.repository.KeyValueRepository
...

Github Actions에서 활용될 deploy.yml에서 docker-compose.yml을 빌드 후 실행하는 로직을 추가했었으나 volume 설정에서 문제가 발생했고, docker container를 띄우는 작업을 workflow에서 처리하기 어렵다고 판단했습니다. 다음은 발생했던 에러 로그입니다.

Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/home/ubuntu/app/src/main/resources/prometheus.yml" to rootfs at "/etc/prometheus/prometheus.yml": mount /home/ubuntu/app/src/main/resources/prometheus.yml:/etc/prometheus/prometheus.yml (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
Error: Process completed with exit code 1.

Resolved

redis, prometheus, grafana를 docker container로 한번에 띄울 수 있도록 docker-compose.yml 작성했습니다.
prometheus에서 volumes에 적용된된 prometheus.yml은 프로젝트 내 src/main/resources/prometheus.yml을 의미합니다.

redis:
    image: redis
    container_name: redis-cache
    ports:
      - 6379:6379
    restart: unless-stopped

  grafana:
    image: grafana/grafana
    container_name: grafana-container
    ports:
      - "3000:3000"
    restart: unless-stopped

  prometheus:
    image: prom/prometheus
    container_name: prometheus-container
    ports:
      - "9090:9090"
    volumes:
      - /home/ubuntu/app/src/main/resources/prometheus.yml:/etc/prometheus/prometheus.yml
    restart: unless-stopped

docker compose 실행 관리를 Github Actions에서 처리하지 않고, appspec.yml에 의해 배포할 때마다 실행되는 start.sh, stop.sh를 수정해 docker-compose.yml 실행 및 중단하도록 설정했습니다.

# start.sh
echo "$TIME_NOW > Docker Compose Up" >> $DEPLOY_LOG
cd $PROJECT_ROOT
docker-compose up -d 

# stop.sh
echo "$TIME_NOW > Docker Compose Down" >> $DEPLOY_LOG
cd $PROJECT_ROOT
docker-compose down -v

@yooniversal yooniversal linked an issue Jul 27, 2023 that may be closed by this pull request
@yooniversal yooniversal merged commit b194b78 into main Jul 27, 2023
@yooniversal yooniversal deleted the 13-cicd-docker-compose branch July 27, 2023 13:05
@yooniversal yooniversal added enhancement ✨ Feature 기능 개발 및 개선 🌏 Deploy 배포 관련 and removed enhancement labels Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌏 Deploy 배포 관련 ✨ Feature 기능 개발 및 개선
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI/CD : docker compose 사용
1 participant