Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions nginx/conf.d/prod.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}
4 changes: 2 additions & 2 deletions nginx/conf.d/staging.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}
30 changes: 30 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "=== 배포 성공 ==="
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 7 additions & 3 deletions terraform/compute.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion terraform/storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down