프론트엔드 서버 기존 Nginx 구성에서 Caddy로 마이그레이션:
Some checks failed
Build Push and Restart Compose / deploy (push) Failing after 1m11s

- Nginx 설정 파일(`nginx.conf`) 제거 및 Caddy 설정 파일(`Caddyfile`) 추가.
- Dockerfile에서 Nginx 이미지 대신 Caddy 이미지 사용하도록 수정.
- 정적 파일 경로(`/usr/share/nginx/html` → `/srv`) 변경 및 관련 설정 업데이트.
- 정적 에셋 캐싱 및 SPA fallback 로직 Caddy에 맞게 재구성.
This commit is contained in:
hayato5246
2026-04-05 20:57:59 +09:00
parent 00ffc6b54c
commit 47bb040eb8
3 changed files with 16 additions and 46 deletions

12
frontend/Caddyfile Normal file
View File

@@ -0,0 +1,12 @@
:80 {
root * /srv
file_server
encode gzip
# 정적 에셋 캐싱 (해시된 파일명)
@immutable path /_app/immutable/*
header @immutable Cache-Control "public, max-age=31536000, immutable"
# SPA fallback
try_files {path} /index.html
}

View File

@@ -12,12 +12,12 @@ COPY . .
RUN npm run build
# ── 실행 스테이지 ──────────────────────────────────────────
FROM nginx:alpine
FROM caddy:alpine
# nginx 설정 복사
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Caddyfile 복사
COPY Caddyfile /etc/caddy/Caddyfile
# 빌드 결과물 복사
COPY --from=builder /app/build /usr/share/nginx/html
COPY --from=builder /app/build /srv
EXPOSE 80

View File

@@ -1,42 +0,0 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# SPA fallback: 파일이 없으면 index.html로
location / {
try_files $uri $uri/ /index.html;
}
# 정적 에셋 캐싱 (해시된 파일명)
location /_app/immutable/ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# API/WS는 백엔드로 프록시 (docker-compose에서 설정)
location /api/ {
proxy_pass http://backend:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /ws {
proxy_pass http://backend:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
location /login {
proxy_pass http://backend:8080;
proxy_set_header Host $host;
}
location /logout {
proxy_pass http://backend:8080;
proxy_set_header Host $host;
}
}