Skip to content

Commit 9bfc827

Browse files
authored
Improve docker build performance (#5578)
* Performance improve with using BUILDPLATFORM for web build Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev> * Use inline cache in Docker build Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev> --------- Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
1 parent 14f3d0b commit 9bfc827

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

.github/workflows/build_tool.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ jobs:
4040
context: tool/${{ matrix.image }}
4141
tags: ${{ env.REGISTRY }}/pipe-cd/${{ matrix.image }}:${{ env.PIPECD_VERSION }}
4242
platforms: linux/amd64,linux/arm64
43+
# parameter to use inline cache. ref; https://docs.docker.com/build/ci/github-actions/cache/#inline-cache
44+
cache-from: type=registry,ref=${{ env.REGISTRY }}/pipe-cd/${{ matrix.image }}:latest
45+
cache-to: type=inline

.github/workflows/publish_image_chart.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ jobs:
9393
file: ${{ matrix.dockerfile }}
9494
platforms: linux/amd64,linux/arm64
9595
tags: ${{ matrix.container_registry }}/${{ matrix.image }}:${{ env.PIPECD_VERSION }}
96+
# parameter to use inline cache. ref; https://docs.docker.com/build/ci/github-actions/cache/#inline-cache
97+
cache-from: type=registry,ref=${{ matrix.container_registry }}/${{ matrix.image }}:latest
98+
cache-to: type=inline
9699

97100
# Building and pushing Helm charts.
98101
- name: Install helm

.github/workflows/publish_site.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ jobs:
5555
context: docs
5656
file: docs/Dockerfile
5757
tags: ${{ env.GHCR }}/pipe-cd/site:${{ env.PIPECD_VERSION }}
58+
# parameter to use inline cache. ref; https://docs.docker.com/build/ci/github-actions/cache/#inline-cache
59+
cache-from: type=registry,ref=${{ env.GHCR }}/pipe-cd/site:latest
60+
cache-to: type=inline
5861

5962
# Building and pushing Helm charts.
6063
- name: Install helm

.github/workflows/publish_tool.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ jobs:
5151
tags: ${{ env.GHCR }}/pipe-cd/${{ matrix.image }}:${{ env.PIPECD_VERSION }}
5252
platforms: linux/amd64,linux/arm64
5353
push: true
54+
# parameter to use inline cache. ref; https://docs.docker.com/build/ci/github-actions/cache/#inline-cache
55+
cache-from: type=registry,ref=${{ env.GHCR }}/pipe-cd/${{ matrix.image }}:latest
56+
cache-to: type=inline

cmd/pipecd/Dockerfile

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
# syntax=docker/dockerfile:1
22
# web builder
3-
# because of this issue, we choose node 18
4-
# https://github.com/pipe-cd/pipecd/issues/5422
5-
# https://github.com/nodejs/docker-node/issues/1335#issuecomment-2024344411
6-
FROM node:18.20.5-alpine3.21 AS web
3+
# because this stage builds only web assets, we can use any platform
4+
FROM --platform=$BUILDPLATFORM node:18.20.5-alpine3.21 AS web
75

86
WORKDIR /app
97

108
COPY . .
119

1210
RUN apk add --no-cache make git
1311

14-
# because of this issue, we set network-timeout to 300000
15-
# https://github.com/pipe-cd/pipecd/issues/5422
16-
RUN yarn config set network-timeout 300000
17-
1812
RUN make update/web-deps
1913
RUN make build/web
2014

0 commit comments

Comments
 (0)