diff --git a/docker-compose.yml b/docker-compose.yml index 09d702bd..d96ecb64 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -104,9 +104,6 @@ services: volumes: - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro - ./nginx/conf.d:/etc/nginx/conf.d:ro - depends_on: - - cockple-app - - cockple-app-staging mem_limit: 64m memswap_limit: 128m diff --git a/nginx/conf.d/prod.conf b/nginx/conf.d/prod.conf index 4f812314..314b3e38 100644 --- a/nginx/conf.d/prod.conf +++ b/nginx/conf.d/prod.conf @@ -1,12 +1,12 @@ server { listen 80; - server_name cockple.shop; + server_name cockple.store; location / { proxy_pass http://cockple-app:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; } } diff --git a/nginx/conf.d/staging.conf b/nginx/conf.d/staging.conf index 7fd60692..2a222c17 100644 --- a/nginx/conf.d/staging.conf +++ b/nginx/conf.d/staging.conf @@ -1,12 +1,12 @@ server { listen 80; - server_name staging.cockple.shop; + server_name staging.cockple.store; location / { proxy_pass http://cockple-app-staging:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; } } diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 132b5a13..12f17ac2 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -40,3 +40,33 @@ sudo docker compose up -d $SERVICE echo "=== 배포 후 상태 ===" sudo docker ps + +echo "=== 헬스체크 ===" +for container in cockple-mysql cockple-redis $SERVICE; do + for i in $(seq 1 12); do + STATUS=$(sudo docker inspect --format='{{.State.Status}}' $container 2>/dev/null) + HEALTH=$(sudo docker inspect --format='{{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}}' $container 2>/dev/null) + + if [ "$STATUS" != "running" ]; then + echo "FAIL: $container 상태 이상 (status=$STATUS)" + sudo docker logs --tail 20 $container + exit 1 + fi + + if [ "$HEALTH" == "healthy" ] || [ "$HEALTH" == "none" ]; then + echo "OK: $container (status=$STATUS, health=$HEALTH)" + break + fi + + if [ $i -eq 12 ]; then + echo "FAIL: $container 헬스체크 타임아웃 (health=$HEALTH)" + sudo docker logs --tail 20 $container + exit 1 + fi + + echo "대기 중: $container ($i/12, health=$HEALTH)..." + sleep 5 + done +done + +echo "=== 배포 성공 ===" diff --git a/src/main/java/umc/cockple/demo/global/config/SecurityConfig.java b/src/main/java/umc/cockple/demo/global/config/SecurityConfig.java index 6aae4a97..52718bf0 100644 --- a/src/main/java/umc/cockple/demo/global/config/SecurityConfig.java +++ b/src/main/java/umc/cockple/demo/global/config/SecurityConfig.java @@ -69,7 +69,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { @Bean public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration config = new CorsConfiguration(); - config.setAllowedOrigins(List.of("http://localhost:5173", "https://cockple.store", "https://cockple-fe.vercel.app")); // 배포 시에는 도메인 지정 권장 + config.setAllowedOrigins(List.of("http://localhost:5173", "https://cockple.store", "https://staging.cockple.store", "https://cockple-fe.vercel.app")); // 배포 시에는 도메인 지정 권장 config.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS")); config.setAllowedHeaders(List.of("*")); config.setAllowCredentials(true); diff --git a/terraform/compute.tf b/terraform/compute.tf index d10c794f..8910e2cf 100644 --- a/terraform/compute.tf +++ b/terraform/compute.tf @@ -36,9 +36,13 @@ resource "google_compute_instance" "prod" { metadata_startup_script = <<-EOF #!/bin/bash apt-get update -y - apt-get install -y docker.io - curl -SL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose - chmod +x /usr/local/bin/docker-compose + apt-get install -y ca-certificates curl gnupg + install -m 0755 -d /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg + chmod a+r /etc/apt/keyrings/docker.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null + apt-get update -y + apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin systemctl enable docker systemctl start docker usermod -aG docker ubuntu diff --git a/terraform/storage.tf b/terraform/storage.tf index 63e9e4a4..78ee5250 100644 --- a/terraform/storage.tf +++ b/terraform/storage.tf @@ -16,7 +16,7 @@ resource "google_storage_bucket" "cockple_assets" { uniform_bucket_level_access = true cors { - origin = ["https://cockple.shop", "https://staging.cockple.shop"] + origin = ["https://cockple.store", "https://staging.cockple.store"] method = ["GET", "PUT", "POST", "DELETE"] response_header = ["Content-Type"] max_age_seconds = 3600 diff --git a/terraform/variables.tf b/terraform/variables.tf index 2f96e69b..27b8c522 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -16,7 +16,7 @@ variable "cloudflare_api_token" { } variable "cloudflare_zone_id" { - description = "cockple.shop Cloudflare Zone ID" + description = "cockple.store Cloudflare Zone ID" type = string }