diff --git a/.gitignore b/.gitignore index b4e4a27..eee9f59 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ docs/.vuepress/.temp package-lock.json .idea .DS_Store +docs/.vuepress/dist \ No newline at end of file diff --git a/BaseImageBuild b/BaseImageBuild new file mode 100644 index 0000000..7f07fc9 --- /dev/null +++ b/BaseImageBuild @@ -0,0 +1,10 @@ +FROM node:18.19.1-alpine3.19 AS build + +# 设置工作目录 +WORKDIR /app + +# 将 package.json 和 package-lock.json 复制到工作目录 +COPY package.json ./ + +# 安装项目依赖 +RUN npm install \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..36b99d8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM registry.cn-hangzhou.aliyuncs.com/idmesh/base:flow-doc-base-v1 as build + +WORKDIR /app + +COPY . . + +# 构建 React 项目 +RUN npm run docs:build + +FROM nginx:latest + +# 复制 React 项目构建结果到 Nginx 的默认静态文件目录 +COPY --from=build /app/docs/.vuepress/dist /usr/share/nginx/html +COPY --from=build /app/nginx.conf /etc/nginx/nginx.conf + +# 暴露 Nginx 默认端口 +EXPOSE 80 + +# Nginx 启动命令 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/deployment.yaml b/deployment.yaml new file mode 100644 index 0000000..1113bdd --- /dev/null +++ b/deployment.yaml @@ -0,0 +1,61 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: flow-doc + namespace: ${NAMESPACE} + labels: + app: flow-doc +spec: + revisionHistoryLimit: 3 + replicas: 1 + selector: + matchLabels: + app: flow-doc + template: + metadata: + labels: + app: flow-doc + annotations: + config.linkerd.io/skip-outbound-ports: 3306,16379,6379 + spec: + containers: + - name: flow-doc + image: ${TAG} + imagePullPolicy: IfNotPresent + readinessProbe: + httpGet: + port: 80 + path: / + resources: + limits: + cpu: 500m + memory: 200Mi + requests: + cpu: 100m + memory: 50Mi + env: + - name: APP_DEBUG + value: "true" + - name: LOG_ALLOCATE + value: "off" + ports: + - containerPort: 80 + - containerPort: 10080 + imagePullSecrets: + - name: docker-registry-public + - name: docker-registry-vpc +--- +apiVersion: v1 +kind: Service +metadata: + name: flow-doc-service + namespace: ${NAMESPACE} + labels: + app: flow-doc +spec: + selector: + app: flow-doc + ports: + - port: 80 + targetPort: 80 + name: http \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..f4dc7a4 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,52 @@ + +user nginx; +worker_processes auto; + +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + # https support + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + ssl_prefer_server_ciphers on; + + 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 off; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + server { + listen 80; + listen [::]:80; + # server_name localhost; + + #access_log /var/log/nginx/host.access.log main; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + + } +}