-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: optimize Dockerfile multi-stage build (#4057)
* ci: optimize Dockerfile multi-stage build Signed-off-by: Ash <[email protected]> * copy scheduler from builder Signed-off-by: Ash <[email protected]> * resolve FROM as warning Signed-off-by: Ash <[email protected]> --------- Signed-off-by: Ash <[email protected]>
- Loading branch information
Showing
2 changed files
with
27 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,32 @@ | ||
# syntax = registry.erda.cloud/retag/dockerfile:latest | ||
FROM registry.erda.cloud/erda-x/node:14 AS build | ||
|
||
WORKDIR /build | ||
|
||
COPY . ./erda-ui | ||
COPY --from=erda-ui-enterprise / /build/erda-ui-enterprise | ||
|
||
RUN cd erda-ui/shell && \ | ||
npm run extra-logic && \ | ||
cd /build/erda-ui && \ | ||
npm cache clean --force && \ | ||
npm install -g --force [email protected] && \ | ||
pnpm install --frozen-lockfile --no-optional --unsafe-perm && \ | ||
pnpm run build-online | ||
|
||
FROM registry.erda.cloud/erda-x/node:14 | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY public ./public | ||
COPY scheduler ./scheduler | ||
COPY --from=build /build/erda-ui/public ./public | ||
COPY --from=build /build/erda-ui/scheduler ./scheduler | ||
|
||
WORKDIR /usr/src/app/scheduler | ||
|
||
ENV NODE_ENV=production | ||
|
||
RUN npm i [email protected] -g | ||
RUN pnpm i --unsafe-perm --reporter append-only | ||
RUN pnpm run build | ||
RUN npm install -g [email protected] && \ | ||
pnpm install --unsafe-perm --reporter append-only && \ | ||
pnpm run build | ||
|
||
CMD pnpm run start:prod | ||
CMD ["pnpm", "run", "start:prod"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,43 +37,14 @@ stages: | |
description: 从 git 代码仓库中解析提交信息,生成仓库版本 | ||
params: | ||
git_dir: ${{ dirs.erda-ui-enterprise }} | ||
- stage: | ||
- js-build: | ||
alias: build-erda-ui | ||
description: 针对 nodejs 工程的编译打包任务 | ||
version: "1.0" | ||
params: | ||
build_cmd: | ||
- cd ${{ dirs.erda-ui }}/shell && npm run extra-logic | ||
- cd ${{ dirs.erda-ui }} | ||
- npm cache clean --force | ||
- npm i -g --force [email protected] | ||
- pnpm i --frozen-lockfile --no-optional --unsafe-perm | ||
- pnpm run build-online | ||
- cp -r ${{ dirs.erda-ui }}/{public,scheduler} $WORKDIR | ||
node_version: 14 | ||
resources: | ||
cpu: 0.5 | ||
mem: 6144 | ||
- js-build: | ||
alias: build-erda-ui-enterprise | ||
description: 针对 nodejs 工程的编译打包任务 | ||
version: "1.0" | ||
params: | ||
build_cmd: | ||
- cd ${{ dirs.erda-ui-enterprise }}/admin && npm ci | ||
- npm run build | ||
- cp -r ${{ dirs.erda-ui-enterprise }}/{public,server} $WORKDIR | ||
node_version: 14 | ||
resources: | ||
cpu: 0.5 | ||
mem: 2048 | ||
- stage: | ||
- dockerfile: | ||
alias: build-erda-ui-image | ||
description: 针对自定义 dockerfile 打包,产出可运行镜像 | ||
version: "1.0" | ||
params: | ||
build_context: | ||
erda-ui-enterprise: ${{ dirs.erda-ui-enterprise }} | ||
image: | ||
name: ui | ||
tag: ${{ outputs.ui-version.image_tag }} | ||
|
@@ -82,8 +53,7 @@ stages: | |
password: ${{ configs.docker_registry_password }} | ||
url: ${{ configs.docker_registry }} | ||
username: ${{ configs.docker_registry_username }} | ||
workdir: ${{ dirs.build-erda-ui }} | ||
image: registry.erda.cloud/erda-actions/dockerfile-action:1.0-20230509080433-9515bd6 | ||
workdir: ${{ dirs.erda-ui }} | ||
resources: | ||
cpu: 0.5 | ||
mem: 2048 | ||
|
@@ -100,8 +70,7 @@ stages: | |
password: ${{ configs.docker_registry_password }} | ||
url: ${{ configs.docker_registry }} | ||
username: ${{ configs.docker_registry_username }} | ||
workdir: ${{ dirs.build-erda-ui-enterprise }} | ||
image: registry.erda.cloud/erda-actions/dockerfile-action:1.0-20230509080433-9515bd6 | ||
workdir: ${{ dirs.erda-ui-enterprise }} | ||
resources: | ||
cpu: 0.5 | ||
mem: 2048 | ||
|