q'weqwe
This commit is contained in:
19
Dockerfile
19
Dockerfile
@ -1,9 +1,17 @@
|
|||||||
# 构建阶段
|
# 构建阶段 - 使用阿里云Node镜像
|
||||||
FROM node:20-alpine AS builder
|
FROM registry.cn-hangzhou.aliyuncs.com/nodejs/node:20-alpine AS builder
|
||||||
|
|
||||||
# 设置工作目录
|
# 设置工作目录
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# 配置npm使用淘宝镜像源(解决国内网络问题)
|
||||||
|
RUN npm config set registry https://registry.npmmirror.com
|
||||||
|
RUN npm config set disturl https://npm.taobao.org/dist
|
||||||
|
RUN npm config set electron_mirror https://npm.taobao.org/mirrors/electron/
|
||||||
|
RUN npm config set puppeteer_download_host https://npm.taobao.org/mirrors
|
||||||
|
RUN npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/
|
||||||
|
RUN npm config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs/
|
||||||
|
|
||||||
# 复制package.json和package-lock.json
|
# 复制package.json和package-lock.json
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
@ -16,8 +24,11 @@ COPY . .
|
|||||||
# 构建应用
|
# 构建应用
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# 生产阶段
|
# 生产阶段 - 使用阿里云Nginx镜像
|
||||||
FROM nginx:alpine
|
FROM registry.cn-hangzhou.aliyuncs.com/library/nginx:alpine
|
||||||
|
|
||||||
|
# 配置Alpine使用国内镜像源
|
||||||
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||||
|
|
||||||
# 复制构建产物到nginx的html目录
|
# 复制构建产物到nginx的html目录
|
||||||
COPY --from=builder /app/out /usr/share/nginx/html
|
COPY --from=builder /app/out /usr/share/nginx/html
|
||||||
|
|||||||
Reference in New Issue
Block a user