Files
AI-Testing/frontend/Dockerfile
2026-04-18 20:20:38 +08:00

27 lines
874 B
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# builderDebian bookworm + glibc避免 Alpine 下 Vite/esbuild 段错误
FROM node:22-bookworm-slim AS builder
WORKDIR /app
ARG NPM_REGISTRY=https://registry.npmmirror.com
ARG DEBIAN_MIRROR_HOST=mirrors.aliyun.com
RUN sed -i "s/deb.debian.org/${DEBIAN_MIRROR_HOST}/g; s/security.debian.org/${DEBIAN_MIRROR_HOST}/g" /etc/apt/sources.list.d/debian.sources
RUN npm config set registry "${NPM_REGISTRY}"
COPY package.json package-lock.json /app/
RUN npm ci
COPY . /app
RUN npm run build \
&& test -f /app/dist/index.html \
&& ls -la /app/dist
# 运行阶段Nginx Alpineapk 使用国内镜像加速
FROM nginx:1.27-alpine
ARG ALPINE_MIRROR_HOST=mirrors.aliyun.com
RUN sed -i "s/dl-cdn.alpinelinux.org/${ALPINE_MIRROR_HOST}/g" /etc/apk/repositories
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80