Open jiminchur opened 1 week ago
name: Deploy to EC2
on:
push:
branches:
- #DEV-cicd # 배포할 브랜치 설정.
paths:
- ./BOOT/gateway/**
- ./BOOT/user/**
- ./BOOT/hub/**
- ./BOOT/delivery/**
- ./BOOT/order/**
- ./BOOT/product/**
- ./CLOUD/eureka/**
- ./BOOT/ainoti/**
jobs:
build:
runs-on: ubuntu-latest
- name: Generate application.yml
run: |
declare -A services=(
["gateway"]="${{ secrets.GATEWAY_YML }}"
["user"]="${{ secrets.USER_YML }}"
["hub"]="${{ secrets.HUB_YML }}"
["delivery"]="${{ secrets.DELIVERY_YML }}"
["order"]="${{ secrets.ORDER_YML }}"
["product"]="${{ secrets.PRODUCT_YML }}"
["eureka"]="${{ secrets.EUREKA_YML }}"
["ainoti"]="${{ secrets.AINOTI_YML }}"
)
for service in "${!services[@]}"; do
if [[ "${{ github.event.head_commit.message }}" == *"$service"* ]]; then
echo "${services[$service]}" > "./BOOT/$service/src/main/resources/application.yml"
fi
done
- name: Build and Push Docker Images to Docker Hub
run: |
for service in "gateway" "user" "hub" "delivery" "order" "product" "eureka" "ainoti"; do
if [[ "${{ github.event.head_commit.message }}" == *"$service"* ]]; then
# Gradle 빌드
./gradlew BOOT:$service:build -x test
# Docker 이미지 빌드
docker build -t ${{ docker_username}}/$service:latest ./BOOT/$service
# Docker 이미지 푸시
docker push ${{ docker_username}}/$service:latest
fi
done
- name: Manage Docker Compose on EC2
run: |
echo "${{ secrets.EC2_SSH_KEY }}" > foodtogo.pem
chmod 600 foodtogo.pem
ssh -i foodtogo.pem ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF'
for service in "gateway" "user" "hub" "delivery" "order" "product" "eureka" "ainoti"; do
if [[ "${{ github.event.head_commit.message }}" == *"$service"* ]]; then
echo "Stopping and removing containers for $service"
docker-compose -f "/server/$service/docker-compose.yml" down
echo "Pulling the latest image for $service"
docker-compose -f "/server/$service/docker-compose.yml" pull
echo "Starting containers for $service"
docker-compose -f "/server/$service/docker-compose.yml" up -d
fi
done
EOF
docker buildx build --platform linux/amd64 -t ttlcc13/eureka:latest ./CLOUD/eureka/ --load
15:43:58,070 |-ERROR in com.github.loki4j.client.pipeline.AsyncBufferPipeline@233f01c7 - Retry #2. Error while sending Batch #1d01912b4f3c (337,862 bytes) to Loki (http://localhost:3100/loki/api/v1/push) java.net.ConnectException
at java.net.ConnectException
loki와의 연결 문제
Todo