mirror of
https://github.com/headporter81/specialsource-homepage-frontend.git
synced 2026-08-08 15:21:11 +09:00
30 lines
977 B
Docker
30 lines
977 B
Docker
# 1단계: Node.js 환경에서 Vue 소스 코드를 빌드합니다.
|
|
FROM node:20-alpine AS build-stage
|
|
WORKDIR /app
|
|
COPY package*.json ./
|
|
RUN npm install
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# 2단계: 빌드된 결과물(HTML/JS)만 가벼운 Nginx 서버로 옮겨 담습니다.
|
|
FROM nginx:stable-alpine AS production-stage
|
|
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
|
|
|
# ⭐ 핵심: Vue 라우터(SPA) 지원 + 백엔드 API(18080 포트) 자동 연결 프록시 설정
|
|
RUN echo 'server { \
|
|
listen 80; \
|
|
location / { \
|
|
root /usr/share/nginx/html; \
|
|
index index.html; \
|
|
try_files $uri $uri/ /index.html; \
|
|
} \
|
|
location /api { \
|
|
proxy_pass http://192.168.0.215:18080/api; \
|
|
proxy_set_header Host $host; \
|
|
proxy_set_header X-Real-IP $remote_addr; \
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; \
|
|
} \
|
|
}' > /etc/nginx/conf.d/default.conf
|
|
|
|
EXPOSE 80
|
|
CMD ["nginx", "-g", "daemon off;"] |