提交 | 用户 | age
|
c659c1
|
1 |
# node 构建 |
胤 |
2 |
FROM node:16-alpine as build-stage |
|
3 |
# 署名 |
|
4 |
MAINTAINER Adoin 'adoin@qq.com' |
|
5 |
WORKDIR /app |
|
6 |
COPY . ./ |
|
7 |
# 设置 node 阿里镜像 |
dcbe55
|
8 |
RUN npm config set registry https://registry.npmmirror.com |
c659c1
|
9 |
# 设置--max-old-space-size |
胤 |
10 |
ENV NODE_OPTIONS=--max-old-space-size=16384 |
|
11 |
# 设置阿里镜像、pnpm、依赖、编译 |
|
12 |
RUN npm install pnpm -g && \ |
|
13 |
pnpm install --frozen-lockfile && \ |
|
14 |
pnpm build:docker |
|
15 |
# node部分结束 |
|
16 |
RUN echo "🎉 编 🎉 译 🎉 成 🎉 功 🎉" |
|
17 |
# nginx 部署 |
|
18 |
FROM nginx:1.23.3-alpine as production-stage |
|
19 |
COPY --from=build-stage /app/dist /usr/share/nginx/html/dist |
|
20 |
COPY --from=build-stage /app/nginx.conf /etc/nginx/nginx.conf |
|
21 |
EXPOSE 80 |
|
22 |
## 将/usr/share/nginx/html/dist/assets/index.js 和/usr/share/nginx/html/dist/_app.config.js中的"$vg_base_url"替换为环境变量中的VG_BASE_URL,$vg_sub_domain 替换成VG_SUB_DOMAIN,$vg_default_user替换成VG_DEFAULT_USER,$vg_default_password替换成VG_DEFAULT_PASSWORD 而后启动nginx |
dcbe55
|
23 |
CMD sed -i "s|__vg_base_url|$VG_BASE_URL|g" /usr/share/nginx/html/dist/assets/entry/index-*.js /usr/share/nginx/html/dist/_app.config.js && \ |
c659c1
|
24 |
nginx -g 'daemon off;' |
胤 |
25 |
RUN echo "🎉 架 🎉 设 🎉 成 🎉 功 🎉" |