diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 09774e92..926871a5 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -26,8 +26,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - with: - ref: prod #Setting JDK - name: Set up JDK 17 @@ -47,13 +45,13 @@ jobs: chmod +x ./weather-service/gradlew #Setting yml - - name: Settings for config service - run: | - cd ./config-service/src/main/resources - touch ./bootstrap.yml - echo "${{ secrets.CONFIG_APPLICATION_YML }}" > ./bootstrap.yml - cd - +# - name: Settings for config service +# run: | +# cd ./config-service/src/main/resources +# touch ./bootstrap.yml +# echo "${{ secrets.CONFIG_APPLICATION_YML }}" > ./bootstrap.yml +# cat bootstrap.yml + # DockerHub Login - name: Docker Hub Login uses: docker/login-action@v2 @@ -87,7 +85,7 @@ jobs: run: | cd apiGateway-service ./gradlew clean build -x test - docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-gateway . + docker build --no-cache -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-gateway . docker push ${{ secrets.DOCKERHUB_USERNAME }}/waither-gateway cd .. @@ -104,8 +102,9 @@ jobs: - name: Build with Gradle - noti-service run: | cd noti-service + cat src/main/resources/bootstrap.yml ./gradlew clean build -x test - docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-noti . + docker build --no-cache -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-noti . docker push ${{ secrets.DOCKERHUB_USERNAME }}/waither-noti cd .. @@ -114,7 +113,7 @@ jobs: run: | cd user-service ./gradlew clean build -x test - docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-user . + docker build --no-cache -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-user . docker push ${{ secrets.DOCKERHUB_USERNAME }}/waither-user cd .. @@ -123,7 +122,7 @@ jobs: run: | cd weather-service ./gradlew clean build -x test - docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-weather . + docker build --no-cache -t ${{ secrets.DOCKERHUB_USERNAME }}/waither-weather . docker push ${{ secrets.DOCKERHUB_USERNAME }}/waither-weather cd .. @@ -147,8 +146,17 @@ jobs: export CONFIG_PASSPHRASE=${{ secrets.CONFIG_PASSPHRASE }} export DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }} - bash /home/docker_init.sh - bash /home/common.sh - bash /home/deploy.sh + cd /home + + docker-compose pull + docker pull ${{ secrets.DOCKERHUB_USERNAME }}/waither-config + docker pull ${{ secrets.DOCKERHUB_USERNAME }}/waither-gateway + docker pull ${{ secrets.DOCKERHUB_USERNAME }}/waither-noti + docker pull ${{ secrets.DOCKERHUB_USERNAME }}/waither-user + docker pull ${{ secrets.DOCKERHUB_USERNAME }}/waither-weather + + bash ./docker_init.sh + bash ./common.sh + bash ./deploy.sh docker image prune -f diff --git a/apiGateway-service/src/main/resources/bootstrap.yml b/apiGateway-service/src/main/resources/bootstrap.yml index f36f218a..7a865b57 100644 --- a/apiGateway-service/src/main/resources/bootstrap.yml +++ b/apiGateway-service/src/main/resources/bootstrap.yml @@ -8,10 +8,10 @@ spring: active: dev cloud: config: - uri: http://config:8888 + uri: http://localhost:8888 name: database-apiGateway, redis, jwt kafka: - bootstrap-servers: "localhost:9092" + bootstrap-servers: "http://localhost:9092" consumer: group-id: "GroupId" diff --git a/config-service/src/main/resources/bootstrap.yml b/config-service/src/main/resources/bootstrap.yml index f312c907..785bba95 100644 --- a/config-service/src/main/resources/bootstrap.yml +++ b/config-service/src/main/resources/bootstrap.yml @@ -3,9 +3,9 @@ server: spring: profiles: - active: dev + active: prod application: - name: config-service + name: config-services cloud: config: server: @@ -13,4 +13,58 @@ spring: uri: ${CONFIG_GIT_URI} ignore-local-ssh-settings: true passphrase: ${CONFIG_PASSPHRASE} - private-key: ${CONFIG_PRIVATE_KEY} + private-key: | + -----BEGIN RSA PRIVATE KEY----- + Proc-Type: 4,ENCRYPTED + DEK-Info: AES-128-CBC,58151ECC53694263F35EEA88FBFA6406 + + 2cstlc5/bYHUAJW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7oqI8jR/+8rM2ymFG9WUDieRPmOJoU4MP58P8UQG2OrjiVfvUNlx/g4xgB92rYfV + jns/HON1U1pmMRaTS9gjnujo1Lx7PggY1uCgDt4iGtuq8PwWmZYjKDoUw3gE/Sma + qKy8ZJirRYLAN4BDuTSnb6cahtt7nB1ZiSMKy1WBSMcI1zMYGF1jpTh8Y1mnIH6r + bLa2wnmWeolxtm4D/TSTxOEedvlKqubADxgOs1lfBwuPXMHJBQurRgiYiTEtBOFK + j0pHK85nXHTuPAYyGjZTf5q4+XHLeInqOgvFJBkfzj+7aQ5NnFzA4KDHJWp+Cjsi + 45get7THkze1+8oEDI1i9CFR4lAl9aTnsoPJLG4ufKE6HZ/gM8jwbOgxUM9fzv1O + 3Jrr6Fjz7QSKajZGgJg4gzBVfhI7qMLuCYpIYb/tJ3Piwe9SjTMfJxQ02n1w9vu6 + FvWasxcPAfhf5lKRc1cojg9w+E37G9qdwWYRAKWXiL4Fctfd05uLorXDLed16Cji + bK6/6X1xyH8o7uzxQigzct1TGk/rgaONMSv3fO+8vWJ0bj+TZOMwl4IAMD/QnR6a + Hkr5T8KjSeytETyoCRHcn3rUSX7SW9EPKxfI805SvkmETl5gtCWh1Ebj8KlO8KG/ + riReQi9WCOII3v4d8+m3PgDODG7uu49zKYUnnbABqER2ONp3W4IkQXUfJbY1vmZW + XvyYMOEW42ZXs58groe299LNdUG02etMPyU6vfRaFJbAWx6cv9cUuw90A2I1I9RD + CEmp0e4aLr2JHZxuCp2sR8F2he5JEMawWgwrdp+YNkeJMLq1UEgzX7pqkpvxa06a + JS3AF8O2A++BkxE8toSQb95arbaAWC0G+ZR26FwSuMVSR2SYsyPv/72CRmuLROyG + wFwfI0YMgWCHWGli8L7Nzae/aVnPpM8rxj2QXGjcN/sdUWdGDfps63/ZDLRUuUD5 + nfTYJLdW2wN67cExKjVOEJRJ01l75sCoqlZWtjuzTdoS7uFEgw9avZYtu8dqE7+R + -----END RSA PRIVATE KEY----- diff --git a/docker-compose.yml b/docker-compose.yml index 68baabe3..aeb998bb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,36 +2,31 @@ version: '3' services: -# nginx: -# container_name: nginx -# image: nginx:latest -# ports: -# - "80:80" -# volumes: -# - /home/ec2-user/nginx.conf:/etc/nginx/nginx.conf -# depends_on: -# - "db" -# restart: always #항상 재실행 - api-gateway: container_name: api-gateway - image: ${DOCKERHUB_USERNAME}/waither-gateway - expose: - - "8000" + image: ${DOCKERHUB_USERNAME}/waither-gateway:latest + network_mode: host + depends_on: + - config + ports: + - "8000:8000" # restart: always restart: no volumes: - /home/ec2-user/logs/api-gateway:/logs + config: container_name: config - image: ${DOCKERHUB_USERNAME}/waither-config - expose: - - "8888" + image: ${DOCKERHUB_USERNAME}/waither-config:latest + network_mode: host + ports: + - "8888:8888" + depends_on: + - eureka environment: CONFIG_GIT_URI : ${CONFIG_GIT_URI} CONFIG_PASSPHRASE : ${CONFIG_PASSPHRASE} -# CONFIG_PRIVATE_KEY_DIR : ${CONFIG_PRIVATE_KEY_DIR} # restart: always restart: no volumes: @@ -39,9 +34,10 @@ services: eureka: container_name: eureka - image: ${DOCKERHUB_USERNAME}/waither-eureka - expose: - - "8761" + image: ${DOCKERHUB_USERNAME}/waither-eureka:latest + network_mode: host + ports: + - "8761:8761" # restart: always restart: no volumes: @@ -49,9 +45,12 @@ services: user-service: container_name: user-service - image: ${DOCKERHUB_USERNAME}/waither-user - expose: - - "8080" + image: ${DOCKERHUB_USERNAME}/waither-user:latest + network_mode: host + depends_on: + - config + ports: + - "8080:8080" # restart: unless-stopped #수동으로 중지되지 않는 이상 항상 재실행 restart: no volumes: @@ -59,19 +58,25 @@ services: weather-service: container_name: weather-service - image: ${DOCKERHUB_USERNAME}/waither-weather - expose: - - "8081" + image: ${DOCKERHUB_USERNAME}/waither-weather:latest + network_mode: host + depends_on: + - config + ports: + - "8081:8081" # restart: unless-stopped restart: no volumes: - - /home/ec2-user/logs/weather-service:/logs + - /home/ec2-user/logs/weather-service:/logs:latest noti-service: container_name: noti-service - image: ${DOCKERHUB_USERNAME}/waither-noti - expose: - - "8082" + image: ${DOCKERHUB_USERNAME}/waither-noti:latest + network_mode: host + depends_on: + - config + ports: + - "8082:8082" # restart: unless-stopped restart: no volumes: @@ -93,3 +98,9 @@ services: KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 volumes: - /var/run/docker.sock:/var/run/docker.sock + + redis: + image: redis + container_name: redis + ports: + - "6379:6379" diff --git a/noti-service/src/main/resources/bootstrap.yml b/noti-service/src/main/resources/bootstrap.yml index 71055d41..f16d9764 100644 --- a/noti-service/src/main/resources/bootstrap.yml +++ b/noti-service/src/main/resources/bootstrap.yml @@ -8,7 +8,7 @@ spring: active: dev cloud: config: - uri: http://config:8888 + uri: http://localhost:8888 name: database-noti,redis kafka: bootstrap-servers: "localhost:9092" @@ -19,4 +19,4 @@ eureka: register-with-eureka: true # register to eureka server fetch-registry: true # Getting instances' information from eureka server service-url: - defaultZone : http://127.0.0.1:8761/eureka #Eureka Server's address \ No newline at end of file + defaultZone : http://localhost:8761/eureka #Eureka Server's address \ No newline at end of file diff --git a/script/common.sh b/script/common.sh index 25f2e6ac..c4825a3d 100644 --- a/script/common.sh +++ b/script/common.sh @@ -3,6 +3,7 @@ RUNNING_EUREKA=$(docker ps | grep eureka) RUNNING_CONFIG=$(docker ps | grep config) RUNNING_ZOOKEEPER=$(docker ps | grep zookeeper) RUNNING_KAFKA=$(docker ps | grep kafka) +RUNNING_REDIS=$(docker ps | grep redis) # Eureka 검색 if [ -z "$RUNNING_EUREKA" ]; then @@ -22,6 +23,14 @@ else echo "Config Service is already running" fi +# Redis 검색 +if [ -z "$RUNNING_REDIS" ]; then + echo "Starting Redis ..." + docker-compose -f /home/docker-compose.yml up -d redis +else + echo "Redis is already running" +fi + # Zookeeper 검색 if [ -z "$RUNNING_ZOOKEEPER" ]; then echo "Starting Zookeeper ..." diff --git a/script/deploy.sh b/script/deploy.sh index 188626f8..76bc3064 100644 --- a/script/deploy.sh +++ b/script/deploy.sh @@ -10,10 +10,10 @@ # -d : detached 모드. 컨테이너를 백그라운드에서 실행 echo "api-gateway server start..." -docker-compose -f /home/docker-compose.yml up -d api-gateway +docker-compose -f /home/docker-compose.yml up -d api-gateway --build echo "noti-service server start..." -docker-compose -f /home/docker-compose.yml up -d noti-service +docker-compose -f /home/docker-compose.yml up -d noti-service --build echo "user-service server start..." -docker-compose -f /home/docker-compose.yml up -d user-service +docker-compose -f /home/docker-compose.yml up -d user-service --build echo "weather-service server start..." -docker-compose -f /home/docker-compose.yml up -d weather-service +docker-compose -f /home/docker-compose.yml up -d weather-service --build diff --git a/user-service/src/main/resources/bootstrap.yml b/user-service/src/main/resources/bootstrap.yml index c7977aa7..305e9c55 100644 --- a/user-service/src/main/resources/bootstrap.yml +++ b/user-service/src/main/resources/bootstrap.yml @@ -8,7 +8,7 @@ spring: active: dev cloud: config: - uri: http://config:8888 + uri: http://localhost:8888 name: database-user,redis, jwt, smtp, apiDocs-user kafka: bootstrap-servers: "localhost:9092" @@ -21,7 +21,7 @@ eureka: register-with-eureka: true # register to eureka server fetch-registry: true # Getting instances' information from eureka server service-url: - defaultZone : http://127.0.0.1:8761/eureka #Eureka Server's address + defaultZone : http://localhost:8761/eureka #Eureka Server's address #management: # Actuator # endpoints: diff --git a/weather-service/src/main/resources/bootstrap.yml b/weather-service/src/main/resources/bootstrap.yml index 4abbfad6..9b2bc164 100644 --- a/weather-service/src/main/resources/bootstrap.yml +++ b/weather-service/src/main/resources/bootstrap.yml @@ -8,7 +8,7 @@ spring: active: dev cloud: config: - uri: http://config:8888 + uri: http://localhost:8888 name: database-weather kafka: bootstrap-servers: "localhost:9092" @@ -21,7 +21,7 @@ eureka: register-with-eureka: true # register to eureka server fetch-registry: true # Getting instances' information from eureka server service-url: - defaultZone : http://127.0.0.1:8761/eureka #Eureka Server's address + defaultZone : http://localhost:8761/eureka #Eureka Server's address management: # Actuator endpoints: