..
This commit is contained in:
26
Dockerfile
26
Dockerfile
@@ -7,19 +7,25 @@ COPY . .
|
|||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# 2단계: 실행 (Nginx)
|
# 2단계: 실행 (Nginx)
|
||||||
# 2단계: 실행 (Node.js)
|
FROM nginx:alpine
|
||||||
FROM node:20-alpine
|
WORKDIR /usr/share/nginx/html
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# 프로덕션 의존성만 설치
|
# 기존 기본 파일 제거 및 빌드 결과물 복사
|
||||||
COPY package*.json ./
|
RUN rm -rf ./*
|
||||||
RUN npm install --omit=dev
|
COPY --from=build /app/dist .
|
||||||
|
|
||||||
# 서버 파일 및 빌드 결과물 복사
|
# React Router SPA 라우팅을 위한 Nginx 설정 적용
|
||||||
COPY --from=build /app/dist ./dist
|
RUN echo 'server { \
|
||||||
|
listen 80; \
|
||||||
|
location / { \
|
||||||
|
root /usr/share/nginx/html; \
|
||||||
|
index index.html index.htm; \
|
||||||
|
try_files $uri $uri/ /index.html; \
|
||||||
|
} \
|
||||||
|
}' > /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
# 환경변수 포트 노출
|
# 환경변수 포트 노출
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
# 서버 실행
|
# Nginx 서버 실행
|
||||||
CMD ["node", "server.js"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
Reference in New Issue
Block a user