diff --git a/.github/workflows/frontend-ci-cd.yml b/.github/workflows/frontend-ci-cd.yml index a98981f9..76cd5057 100644 --- a/.github/workflows/frontend-ci-cd.yml +++ b/.github/workflows/frontend-ci-cd.yml @@ -32,5 +32,8 @@ jobs: docker run -d \ --name you-quiz-fe \ --env-file packages/client/.env \ - -p 80:4173 \ + -v /etc/letsencrypt/live/www.you-quiz.site/fullchain.pem:/etc/nginx/ssl/fullchain.pem \ + -v /etc/letsencrypt/live/www.you-quiz.site/privkey.pem:/etc/nginx/ssl/privkey.pem \ + -p 80:80 \ + -p 443:443 \ you-quiz-fe:${{ github.run_number }} diff --git a/Dockerfile.fe b/Dockerfile.fe index b9855241..d9032f73 100644 --- a/Dockerfile.fe +++ b/Dockerfile.fe @@ -16,28 +16,16 @@ RUN yarn install WORKDIR /app/packages/client RUN yarn build -# 실행 스테이지 -FROM node:22.9.0-alpine AS runner +#Nginx 스테이지 +FROM nginx:alpine AS nginx -WORKDIR /app - -# 필요한 파일 복사 순서 변경 및 종속성 설치 추가 -COPY --from=builder /app/package.json ./ -COPY --from=builder /app/tsconfig.json ./ -COPY --from=builder /app/yarn.lock ./ -COPY --from=builder /app/.yarnrc.yml ./ -COPY --from=builder /app/.yarn ./.yarn -COPY --from=builder /app/packages ./packages +COPY --from=builder /app/packages/client/dist /usr/share/nginx/html -# 종속성 설치 추가 -RUN yarn install +COPY nginx.conf /etc/nginx/conf.d/default.conf -# 환경 변수 설정 -ENV NODE_ENV production -ENV PORT 4173 +RUN mkdir -p /etc/nginx/ssl -# 포트 설정 -EXPOSE 4173 +EXPOSE 80 +EXPOSE 443 -# 실행 명령어 -CMD ["yarn", "workspace", "client", "preview", "--host", "0.0.0.0"] +CMD ["nginx", "-g", "daemon off;"] diff --git a/packages/client/src/nginx.conf b/packages/client/src/nginx.conf new file mode 100644 index 00000000..675f924b --- /dev/null +++ b/packages/client/src/nginx.conf @@ -0,0 +1,23 @@ +server { + listen 80; + server_name www.you-quiz.site; + return 301 https://$server_name$request_uri; +} + +server { + listen 443 ssl; + server_name www.you-quiz.site; + + ssl_certificate /etc/nginx/ssl/fullchain.pem; + ssl_certificate_key /etc/nginx/ssl/privkey.pem; + + ssl_protocols TLSv1.2 TLSv1.3; + ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384'; + ssl_prefer_server_ciphers off; + + location / { + root /usr/share/nginx/html; + index index.html; + try_files $uri $uri/ /index.html;try_files $uri $uri/ /index.html; + } +} \ No newline at end of file