diff --git a/Jenkinsfile b/Jenkinsfile index cb54035..575143a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -124,7 +124,7 @@ pipeline { docker build \ --build-arg "VITE_API_BASE_URL=$ADMIN_API_BASE_URL" \ --tag "$ADMIN_IMAGE:$IMAGE_TAG" \ - WonderQ-Admin-UI + WonderQ-Admin-UI-Vue docker run --rm \ --entrypoint nginx \ diff --git a/WonderQ-Admin-UI-Vue/.dockerignore b/WonderQ-Admin-UI-Vue/.dockerignore new file mode 100644 index 0000000..1b963e7 --- /dev/null +++ b/WonderQ-Admin-UI-Vue/.dockerignore @@ -0,0 +1,9 @@ +node_modules/ +dist/ +.git/ +.idea/ +.env +.env.* +coverage/ +.vite/ +*.log diff --git a/WonderQ-Admin-UI-Vue/Dockerfile b/WonderQ-Admin-UI-Vue/Dockerfile new file mode 100644 index 0000000..08ba05d --- /dev/null +++ b/WonderQ-Admin-UI-Vue/Dockerfile @@ -0,0 +1,28 @@ +# syntax=docker/dockerfile:1 + +FROM node:22-bookworm-slim AS build + +WORKDIR /app + +COPY package.json yarn.lock ./ + +# The lock file contains Windows native packages for local development and +# their Linux counterparts for the container build. +RUN yarn install --frozen-lockfile --non-interactive --ignore-platform + +COPY . . + +ARG VITE_API_BASE_URL="" +ENV VITE_API_BASE_URL="${VITE_API_BASE_URL}" + +RUN yarn build + +FROM nginx:1.28-alpine AS runtime + +COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=build /app/dist /usr/share/nginx/html/admin + +EXPOSE 80 + +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD wget -q -O /dev/null http://127.0.0.1/healthz || exit 1 diff --git a/WonderQ-Admin-UI-Vue/nginx.conf b/WonderQ-Admin-UI-Vue/nginx.conf new file mode 100644 index 0000000..96a0032 --- /dev/null +++ b/WonderQ-Admin-UI-Vue/nginx.conf @@ -0,0 +1,46 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + server_name _; + + root /usr/share/nginx/html; + index index.html; + charset utf-8; + server_tokens off; + + add_header X-Content-Type-Options "nosniff" always; + add_header X-Frame-Options "SAMEORIGIN" always; + add_header Referrer-Policy "strict-origin-when-cross-origin" always; + + gzip on; + gzip_min_length 1024; + gzip_types text/css application/javascript application/json image/svg+xml; + + location = /healthz { + access_log off; + default_type text/plain; + return 200 "ok\n"; + } + + location = / { + return 302 /admin/; + } + + location = /admin { + return 301 /admin/; + } + + location = /admin/index.html { + expires -1; + try_files $uri =404; + } + + location /admin/assets/ { + expires 1y; + try_files $uri =404; + } + + location /admin/ { + try_files $uri $uri/ /admin/index.html; + } +} diff --git a/scripts/jenkins-freestyle.sh b/scripts/jenkins-freestyle.sh index f595a1a..4ea6563 100755 --- a/scripts/jenkins-freestyle.sh +++ b/scripts/jenkins-freestyle.sh @@ -89,7 +89,7 @@ log "构建 Admin UI 镜像:$ADMIN_IMAGE:$IMAGE_TAG" docker build \ --build-arg "VITE_API_BASE_URL=$ADMIN_API_BASE_URL" \ --tag "$ADMIN_IMAGE:$IMAGE_TAG" \ - WonderQ-Admin-UI + WonderQ-Admin-UI-Vue log "检查 Admin UI Nginx 配置" docker run --rm \