From 85aba6647b688a2ff3376fca69c56ed35310c04e Mon Sep 17 00:00:00 2001 From: Song367 <601337784@qq.com> Date: Mon, 9 Mar 2026 14:53:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E7=BD=B2=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 22 ++++++++++++++++++++++ nginx.conf | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 Dockerfile create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2bbca33 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM node:22.14.0-alpine3.21 as build-stage +COPY ./ /app +WORKDIR /app + +ENV YARN_REGISTRY https://registry.npmmirror.com/ +RUN yarn install +COPY . . +ARG DEPLOY_ENV=prod +RUN if [ "$DEPLOY_ENV" = "test" ]; then \ + yarn build ; \ + else \ + yarn build ; \ + fi + + +# production stage +FROM nginx:1.27.4-alpine3.21 as production-stage +RUN mkdir /app +COPY --from=build-stage /app/dist /app +COPY nginx.conf /etc/nginx/nginx.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..211d566 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,36 @@ +user nginx; +worker_processes 1; +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; +events { + worker_connections 1024; +} +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + access_log /var/log/nginx/access.log main; + sendfile on; + keepalive_timeout 65; + server { + listen 80; + server_name localhost; + location = /creation-flow-app { + return 301 https://$host/creation-flow-app/login; + } + location = /creation-flow-app/ { + return 301 https://$host/creation-flow-app/login; + } + location / { + root /app; + index index.html; + try_files $uri $uri/ /index.html; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + } +}