Skip to content

Commit 2315590

Browse files
微信公众号:储凡mmdapl
微信公众号:储凡
andauthored
perf: 优化bundle脚本,支持Dockerfile构建 (#165)
* perf: 优化`bundle`脚本,支持`Dockerfile`构建 * chore: update --------- Co-authored-by: chufan <mmdapl@163.com>
1 parent 641e0e5 commit 2315590

File tree

4 files changed

+190
-250
lines changed

4 files changed

+190
-250
lines changed

Dockerfile

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,49 @@
66
# CONTAINER_BUILD: 采用容器构建
77
#
88

9-
FROM registry.cn-hangzhou.aliyuncs.com/142vip/node:18.18.0-alpine AS build_base
9+
FROM registry.cn-hangzhou.aliyuncs.com/142vip/node:20.17.0-alpine AS build_base
1010

11-
ARG CONTAINER_BUILD
11+
# 是否
12+
ARG NEED_PROXY=false
1213

1314
## 设置环境变量,支持容器构建时使用layer缓存,参考:https://pnpm.io/zh/docker
1415
ENV PNPM_HOME="/pnpm"
1516
ENV PATH="$PNPM_HOME:$PATH"
1617

18+
## corepack 环境变量
19+
ENV COREPACK_NPM_REGISTRY=https://mirrors.tencent.com/npm/
20+
1721
WORKDIR /apps
1822
COPY . .
1923

24+
RUN ls
25+
2026
## 基于容器自动构建
21-
RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "$CONTAINER_BUILD" = "true" ]; then \
22-
sh ./scripts/ci && pnpm build; \
27+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store sh ./scripts/ci && if [ "$NEED_PROXY" = "false" ]; \
28+
then \
29+
pnpm build; \
30+
else \
31+
pnpm build:proxy; \
2332
fi;
2433

34+
2535
FROM registry.cn-hangzhou.aliyuncs.com/142vip/nginx:1.23.0-alpine
2636

2737

2838
## 自定义镜像的Label信息
2939
ARG APP_NAME
3040
ARG APP_VERSION
41+
ARG APP_DESCRIPTION
3142
ARG AUTHOR
3243
ARG EMAIL
33-
ARG DESCRIPTION
34-
ARG GIT_HASH
35-
ARG GIT_MESSAGE
3644
ARG HOME_PAGE
45+
ARG GIT_HASH
3746

3847
# 作者信息 & 项目信息 & Git信息
3948
LABEL "maintainer"="$AUTHOR <$EMAIL>"
4049
LABEL "repo.name"=$APP_NAME "repo.version"=$APP_VERSION \
41-
"repo.homePage"="$HOME_PAGE" "repo.description"="$DESCRIPTION"
42-
LABEL "git.hash"="$GIT_HASH" "git.message"="$GIT_MESSAGE"
50+
"repo.description"="$DESCRIPTION" "repo.homePage"="$HOME_PAGE"
51+
LABEL "git.hash"="$GIT_HASH"
4352

4453
# 将dist文件中的内容复制到 /usr/share/nginx/html/ 这个目录下面 注意:--from参数
4554
COPY --from=build_base /apps/docs/.vuepress/dist/ /usr/share/nginx/html/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"devDependencies": {
3030
"@142vip/fairy-cli": "^0.0.3-alpha.11",
3131
"@142vip/release-version": "^0.0.1-alpha.9",
32-
"@142vip/utils": "0.0.1-alpha.2",
32+
"@142vip/utils": "^0.0.1-alpha.4",
3333
"@antfu/eslint-config": "^2.27.3",
3434
"@commitlint/cli": "^18.6.1",
3535
"@commitlint/config-conventional": "^18.6.3",

0 commit comments

Comments
 (0)