Skip to content

Commit

Permalink
perf(镜像): 使用Layer缓存信息,提高Docker构建、打包速度
Browse files Browse the repository at this point in the history
  • Loading branch information
142vip.cn committed Nov 21, 2023
1 parent 38afb53 commit 1b3c69e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Dockerfile
Expand Up @@ -9,13 +9,18 @@

FROM registry.cn-hangzhou.aliyuncs.com/142vip/node:18.18.0-alpine AS build_base
ARG CONTAINER_BUILD

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

WORKDIR /apps
COPY . .

RUN echo $CONTAINER_BUILD;

## 基于容器自动构建
RUN if [ "$CONTAINER_BUILD" = "true" ]; then \
RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "$CONTAINER_BUILD" = "true" ]; then \
sh ./scripts/ci && pnpm build; \
fi;

Expand Down

0 comments on commit 1b3c69e

Please sign in to comment.