From a0ebf7a48d86672cfab0eff1c29c52d043470c4a Mon Sep 17 00:00:00 2001 From: Lectom C Han Date: Mon, 2 Feb 2026 11:05:25 +0900 Subject: [PATCH] =?UTF-8?q?gateway=20=EB=B6=84=EB=A6=AC=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compose.infra.yaml | 22 ++++++++++++++++++++++ docker-compose.yaml | 22 ---------------------- gateway/entrypoint.sh | 31 +++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 22 deletions(-) create mode 100644 gateway/entrypoint.sh diff --git a/compose.infra.yaml b/compose.infra.yaml index 5e88b917..368b8911 100644 --- a/compose.infra.yaml +++ b/compose.infra.yaml @@ -48,6 +48,24 @@ services: networks: - baron_net + gateway: + build: + context: ./gateway + dockerfile: Dockerfile + container_name: baron_gateway + restart: always + ports: + - "${USERFRONT_PORT:-5000}:5000" + networks: + - baron_net + - public_net + healthcheck: + test: ["CMD", "wget", "-qO-", "http://127.0.0.1:5000/"] + interval: 10s + timeout: 5s + retries: 3 + start_period: 10s + volumes: postgres_data: clickhouse_data: @@ -58,3 +76,7 @@ networks: name: baron_net external: true driver: bridge + public_net: + name: public_net + external: true + diff --git a/docker-compose.yaml b/docker-compose.yaml index 09e9897a..981831c9 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -82,28 +82,6 @@ services: networks: - baron_net - gateway: - build: - context: ./gateway - dockerfile: Dockerfile - container_name: baron_gateway - restart: always - ports: - - "${USERFRONT_PORT:-5000}:5000" - networks: - - baron_net - - public_net - depends_on: - backend: - condition: service_healthy - userfront: - condition: service_healthy - healthcheck: - test: ["CMD", "wget", "-qO-", "http://127.0.0.1:5000/"] - interval: 10s - timeout: 5s - retries: 3 - start_period: 10s userfront: build: context: ./userfront diff --git a/gateway/entrypoint.sh b/gateway/entrypoint.sh new file mode 100644 index 00000000..c54fac71 --- /dev/null +++ b/gateway/entrypoint.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +# 대상 호스트와 포트가 준비될 때까지 대기하는 함수 +wait_for_host() { + host=$1 + port=$2 + name=$3 + + echo "Waiting for $name ($host:$port)..." + + # 최대 30초 동안 대기 + count=0 + until nc -z $host $port || [ $count -eq 30 ]; do + sleep 1 + count=$((count + 1)) + done + + if [ $count -eq 30 ]; then + echo "Timeout waiting for $name" + else + echo "$name is ready!" + fi +} + +# 백엔드와 유저프론트 대기 (Oathkeeper는 인프라 레벨이므로 함께 뜰 가능성이 높지만 안전을 위해 포함) +wait_for_host "baron_backend" 3000 "Backend" +wait_for_host "baron_userfront" 5000 "UserFront" +wait_for_host "oathkeeper" 4455 "Oathkeeper" + +echo "All dependencies are up. Starting Nginx..." +exec nginx -g 'daemon off;'