nex_buddy/docker/Dockerfile.web

26 lines
662 B
Docker

# 基础镜像可通过 build arg 覆盖(例如使用本地已有镜像或私有仓库镜像)。
ARG NODE_IMAGE=node:22-alpine
ARG NGINX_IMAGE=nginx:latest
FROM ${NODE_IMAGE} AS build
# npm 国内加速;可通过 build arg 覆盖。
ARG NPM_REGISTRY=https://registry.npmmirror.com
WORKDIR /app/web
COPY web/package.json web/package-lock.json ./
RUN npm config set registry "$NPM_REGISTRY" \
&& npm config set replace-registry-host always \
&& npm ci --no-audit --no-fund
COPY web/ ./
RUN npm run build
FROM ${NGINX_IMAGE}
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/web/dist /usr/share/nginx/html
EXPOSE 80