diff --git a/.github/workflows/dev_deply.yml b/.github/workflows/dev_deply.yml index 03dce12..3fb7ca9 100644 --- a/.github/workflows/dev_deply.yml +++ b/.github/workflows/dev_deply.yml @@ -55,31 +55,37 @@ jobs: host: ${{ secrets.EC2_SERVER_HOST }} username: ubuntu key: ${{ secrets.EC2_PRIVATE_KEY}} - script : | + script: | + # Docker 이미지 pull sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/bill-api:latest - if [ $(docker ps -a -q -f name=bill-api) ]; then + + # 기존 컨테이너 중지 및 제거 + if [ $(sudo docker ps -a -q -f name=bill-api) ]; then sudo docker stop bill-api sudo docker rm bill-api fi - sudo docker tag jainefer/bill-api:latest bill-api + # Docker 이미지 태그 설정 및 실행 + sudo docker tag ${{ secrets.DOCKERHUB_USERNAME }}/bill-api:latest bill-api sudo docker run --name bill-api -d -p 80:8080 \ - -e SPRING_DATASOURCE_URL=${{ secrets.SPRING_DATASOURCE_URL }} \ - -e SPRING_DATASOURCE_USERNAME=${{ secrets.SPRING_DATASOURCE_USERNAME }} \ - -e SPRING_DATASOURCE_PASSWORD=${{ secrets.SPRING_DATASOURCE_PASSWORD }} \ - -e SPRING_DATASOURCE_DRIVER_CLASS_NAME=${{ secrets.SPRING_DATASOURCE_DRIVER_CLASS_NAME }} \ - -e JWT_BILL_SECRET_KEY=${{ secrets.JWT_BILL_SECRET_KEY }} \ - -e JWT_BILL_ACCESS_TOKEN_EXPIRED=${{ secrets.JWT_BILL_ACCESS_TOKEN_EXPIRED }} \ - -e JWT_BILL_REFRESH_TOKEN_EXPIRED=${{ secrets.JWT_BILL_REFRESH_TOKEN_EXPIRED }} \ - -e SPRINGDOC_API_DOCS_PATH=${{ secrets.SPRINGDOC_API_DOCS_PATH }} \ - -e SPRINGDOC_CACHE_DISABLED=${{ secrets.SPRINGDOC_CACHE_DISABLED }} \ - -e SPRINGDOC_DEFAULT_CONSUMES_MEDIA_TYPE=${{ secrets.SPRINGDOC_DEFAULT_COMSUMES_MEDIA_TYPE }} \ - -e SPRINGDOC_DEFAULT_PRODUCES_MEDIA_TYPE=${{ secrets.SPRINGDOC_DEFAULT_PRODUCES_MEDIA_TYPE }} \ - -e SPRINGDOC_PACKAGES_TO_SCAN=${{ secrets.SPRINGDOC_PACKAGES_TO_SCAN }} \ - -e SPRINGDOC_SWAGGER_UI_DISABLE_SWAGGER_DEFAULT_URL=${{ secrets.SPRINGDOC_SWAGGER_UI_DISABLE_SWAGGER_DEFAULT_URL }} \ - -e SPRINGDOC_SWAGGER_UI_OPERATIONS_SORTER=${{ secrets.SPRINGDOC_SWAGGER_UI_OPERATIONS_SORTER }} \ - -e SPRINGDOC_SWAGGER_UI_PATH=${{ secrets.SPRINGDOC_SWAGGER_UI_PATH }} \ - -e SPRING_DEVTOOLS_LIVERELOAD_ENABLE=${{ secrets.SPRING_DEVTOOLS_LIVERELOAD_ENABLE }} \ + -e SPRING_DATASOURCE_URL="${SPRING_DATASOURCE_URL}" \ + -e SPRING_DATASOURCE_USERNAME="${SPRING_DATASOURCE_USERNAME}" \ + -e SPRING_DATASOURCE_PASSWORD="${SPRING_DATASOURCE_PASSWORD}" \ + -e SPRING_DATASOURCE_DRIVER_CLASS_NAME="${SPRING_DATASOURCE_DRIVER_CLASS_NAME}" \ + -e JWT_BILL_SECRET_KEY="${JWT_BILL_SECRET_KEY}" \ + -e JWT_BILL_ACCESS_TOKEN_EXPIRED="${JWT_BILL_ACCESS_TOKEN_EXPIRED}" \ + -e JWT_BILL_REFRESH_TOKEN_EXPIRED="${JWT_BILL_REFRESH_TOKEN_EXPIRED}" \ + -e SPRINGDOC_API_DOCS_PATH="${SPRINGDOC_API_DOCS_PATH}" \ + -e SPRINGDOC_CACHE_DISABLED="${SPRINGDOC_CACHE_DISABLED}" \ + -e SPRINGDOC_DEFAULT_CONSUMES_MEDIA_TYPE="${SPRINGDOC_DEFAULT_CONSUMES_MEDIA_TYPE}" \ + -e SPRINGDOC_DEFAULT_PRODUCES_MEDIA_TYPE="${SPRINGDOC_DEFAULT_PRODUCES_MEDIA_TYPE}" \ + -e SPRINGDOC_PACKAGES_TO_SCAN="${SPRINGDOC_PACKAGES_TO_SCAN}" \ + -e SPRINGDOC_SWAGGER_UI_DISABLE_SWAGGER_DEFAULT_URL="${SPRINGDOC_SWAGGER_UI_DISABLE_SWAGGER_DEFAULT_URL}" \ + -e SPRINGDOC_SWAGGER_UI_OPERATIONS_SORTER="${SPRINGDOC_SWAGGER_UI_OPERATIONS_SORTER}" \ + -e SPRINGDOC_SWAGGER_UI_PATH="${SPRINGDOC_SWAGGER_UI_PATH}" \ + -e SPRING_DEVTOOLS_LIVERELOAD_ENABLE="${SPRING_DEVTOOLS_LIVERELOAD_ENABLE}" \ ${{ secrets.DOCKERHUB_USERNAME }}/bill-api:latest + + # 사용하지 않는 컨테이너 및 이미지 정리 sudo docker rm $(sudo docker ps --filter 'status=exited' -a -q) sudo docker image prune -a -f \ No newline at end of file