Skip to content

Commit f8d4713

Browse files
committed
Avoid redundant frontend builds
The goal is to avoid redundant frontend builds for each architecture, since the frontend artifacts are just plain text files / noarch. For now it's only for upstream builds, but the goal would be to have the same with konflux
1 parent a6504fe commit f8d4713

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

Dockerfile

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
1-
ARG TARGETARCH
2-
FROM docker.io/library/node:18-alpine as web-builder
3-
4-
USER node
5-
6-
ARG BUILDSCRIPT
7-
WORKDIR /opt/app-root
8-
9-
COPY --chown=node web/package.json web/package.json
10-
COPY --chown=node web/package-lock.json web/package-lock.json
11-
WORKDIR /opt/app-root/web
12-
RUN CYPRESS_INSTALL_BINARY=0 npm --legacy-peer-deps ci
13-
14-
WORKDIR /opt/app-root
15-
COPY --chown=node web web
16-
COPY mocks mocks
17-
18-
WORKDIR /opt/app-root/web
19-
RUN npm run format-all
20-
RUN npm run build$BUILDSCRIPT
1+
FROM localhost/local-front-build:latest as web-builder
212

3+
ARG TARGETARCH
224
FROM docker.io/library/golang:1.23 as go-builder
235

246
ARG TARGETARCH=amd64

Dockerfile.front

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM docker.io/library/node:18-alpine as web-builder
2+
3+
USER node
4+
5+
ARG BUILDSCRIPT
6+
WORKDIR /opt/app-root
7+
8+
COPY --chown=node web/package-lock.json web/package-lock.json
9+
COPY --chown=node web/package.json web/package.json
10+
WORKDIR /opt/app-root/web
11+
RUN CYPRESS_INSTALL_BINARY=0 npm --legacy-peer-deps ci
12+
13+
WORKDIR /opt/app-root
14+
COPY --chown=node web web
15+
COPY mocks mocks
16+
17+
WORKDIR /opt/app-root/web
18+
RUN npm run format-all
19+
RUN npm run build$BUILDSCRIPT
20+
21+
FROM scratch
22+
23+
COPY --from=web-builder /opt/app-root/web/dist /opt/app-root/web/dist

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ CMDLINE_ARGS ?= --loglevel trace --config config/config.yaml
5050
# build a single arch target provided as argument
5151
define build_target
5252
echo 'building image for arch $(1)'; \
53-
DOCKER_BUILDKIT=1 $(OCI_BIN) buildx build --ulimit nofile=20480:20480 --load --build-arg LDFLAGS="${LDFLAGS}" --build-arg BUILDSCRIPT=${BUILDSCRIPT} --build-arg TARGETARCH=$(1) ${OCI_BUILD_OPTS} -t ${IMAGE}-$(1) -f Dockerfile .;
53+
DOCKER_BUILDKIT=1 $(OCI_BIN) buildx build --load --build-arg LDFLAGS="${LDFLAGS}" --build-arg TARGETARCH=$(1) ${OCI_BUILD_OPTS} -t ${IMAGE}-$(1) -f Dockerfile .;
5454
endef
5555

5656
# push a single arch target image
@@ -196,6 +196,7 @@ serve-mock: YQ ## Run backend using mocks
196196
# note: to build and push custom image tag use: IMAGE_ORG=myuser VERSION=dev make images
197197
.PHONY: image-build
198198
image-build: ## Build MULTIARCH_TARGETS images
199+
$(OCI_BIN) build --ulimit nofile=20480:20480 --build-arg BUILDSCRIPT=${BUILDSCRIPT} ${OCI_BUILD_OPTS} -t localhost/local-front-build:latest -f Dockerfile.front .
199200
trap 'exit' INT; \
200201
$(foreach target,$(MULTIARCH_TARGETS),$(call build_target,$(target)))
201202

0 commit comments

Comments
 (0)