diff --git a/Dockerfile.prod b/Dockerfile.prod index 829d7d2..0c44f58 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -1,28 +1,25 @@ -# Stage 1: Build the React app FROM node:lts AS build WORKDIR /app -COPY package.json package-lock.json ./ +COPY package.json . -RUN npm install +RUN npm i COPY . . RUN npm run build -# Stage 2: Serve with Nginx FROM nginx:stable-alpine -# Remove default Nginx configuration and copy custom config +# nginx의 기본 설정을 삭제하고 앱에서 설정한 파일을 복사 RUN rm -rf /etc/nginx/conf.d COPY conf /etc/nginx -# Copy built files to Nginx +# 위 스테이지에서 생성한 빌드 결과를 nginx의 샘플 앱이 사용하던 폴더로 이동 COPY --from=build /app/build /usr/share/nginx/html -# Expose HTTP port EXPOSE 80 -# Run Nginx -CMD ["nginx", "-g", "daemon off;"] +# nginx 실행 +CMD [ "nginx", "-g", "daemon off;" ] \ No newline at end of file diff --git a/conf/conf.d/default.conf b/conf/conf.d/default.conf index cc4b2d5..78811fd 100644 --- a/conf/conf.d/default.conf +++ b/conf/conf.d/default.conf @@ -1,12 +1,9 @@ server { listen 80; - server_name syluv.store www.syluv.store; location / { - proxy_pass http://localhost:3000; - 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; + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; } -} +} \ No newline at end of file