Skip to content

Commit f0931f3

Browse files
committed
Building frontend only once (#718)
1 parent 3468c48 commit f0931f3

File tree

3 files changed

+77
-18
lines changed

3 files changed

+77
-18
lines changed

.tekton/pipeline-ref.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ spec:
4242
path-context
4343
name: dockerfile
4444
type: string
45+
- default: "Dockerfile.front.downstream"
46+
description: Path to the frontend Dockerfile inside the context specified by parameter
47+
path-context
48+
name: front-dockerfile
49+
type: string
4550
- default: "false"
4651
description: Force rebuild image
4752
name: rebuild
@@ -173,6 +178,52 @@ spec:
173178
workspace: git-auth
174179
- name: netrc
175180
workspace: netrc
181+
- name: build-front-container
182+
params:
183+
- name: IMAGE
184+
value: "$(params.output-image)-front"
185+
- name: DOCKERFILE
186+
value: $(params.front-dockerfile)
187+
- name: CONTEXT
188+
value: $(params.path-context)
189+
- name: HERMETIC
190+
value: $(params.hermetic)
191+
- name: PREFETCH_INPUT
192+
value: $(params.prefetch-input)
193+
- name: IMAGE_EXPIRES_AFTER
194+
value: $(params.image-expires-after)
195+
- name: COMMIT_SHA
196+
value: $(tasks.clone-repository.results.commit)
197+
- name: BUILD_ARGS
198+
value:
199+
- $(params.build-args[*])
200+
- "COMMIT=$(tasks.clone-repository.results.commit)"
201+
- "BUILDVERSION=$(params.build-version)"
202+
- "DATE=$(tasks.clone-repository.results.commit-timestamp)"
203+
- name: BUILD_ARGS_FILE
204+
value: $(params.build-args-file)
205+
- name: SOURCE_ARTIFACT
206+
value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
207+
- name: CACHI2_ARTIFACT
208+
value: $(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT)
209+
- name: PLATFORM
210+
value: "linux/x86_64"
211+
runAfter:
212+
- prefetch-dependencies
213+
taskRef:
214+
params:
215+
- name: name
216+
value: buildah-remote-oci-ta
217+
- name: bundle
218+
value: quay.io/konflux-ci/tekton-catalog/task-buildah-remote-oci-ta:0.3@sha256:3070ee1a75e9a5a0a082008e1f9b3d2df7a9508ca107678b2613dc201eb2e279
219+
- name: kind
220+
value: task
221+
resolver: bundles
222+
when:
223+
- input: $(tasks.init.results.build)
224+
operator: in
225+
values:
226+
- "true"
176227
- name: build-container
177228
matrix:
178229
params:
@@ -200,6 +251,7 @@ spec:
200251
- "COMMIT=$(tasks.clone-repository.results.commit)"
201252
- "BUILDVERSION=$(params.build-version)"
202253
- "DATE=$(tasks.clone-repository.results.commit-timestamp)"
254+
- "FRONTBUILD=$(params.output-image)-front"
203255
- name: BUILD_ARGS_FILE
204256
value: $(params.build-args-file)
205257
- name: SOURCE_ARTIFACT
@@ -210,6 +262,7 @@ spec:
210262
value: "true"
211263
runAfter:
212264
- prefetch-dependencies
265+
- build-front-container
213266
taskRef:
214267
params:
215268
- name: name

Dockerfile.downstream

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
11
ARG COMMIT
2+
ARG FRONTBUILD
23

3-
FROM registry.access.redhat.com/ubi9/nodejs-18:1-108.1716477799 as web-builder
4-
5-
ARG BUILDSCRIPT
6-
WORKDIR /opt/app-root
7-
8-
COPY --chown=default web/package.json web/package.json
9-
COPY --chown=default web/package-lock.json web/package-lock.json
10-
WORKDIR /opt/app-root/web
11-
12-
RUN CYPRESS_INSTALL_BINARY=0 node --max-old-space-size=6000 $(which npm) --legacy-peer-deps ci
13-
14-
WORKDIR /opt/app-root
15-
COPY --chown=default web web
16-
COPY --chown=default mocks mocks
17-
18-
WORKDIR /opt/app-root/web
19-
RUN npm run format-all
20-
RUN npm run build$BUILDSCRIPT
4+
FROM $FRONTBUILD as web-builder
215

226
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:v1.23 as go-builder
237

Dockerfile.front.downstream

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM registry.access.redhat.com/ubi9/nodejs-18:1-108.1716477799 as web-builder
2+
3+
ARG BUILDSCRIPT
4+
WORKDIR /opt/app-root
5+
6+
COPY --chown=default web/package.json web/package.json
7+
COPY --chown=default web/package-lock.json web/package-lock.json
8+
WORKDIR /opt/app-root/web
9+
10+
RUN CYPRESS_INSTALL_BINARY=0 node --max-old-space-size=6000 $(which npm) --legacy-peer-deps ci
11+
12+
WORKDIR /opt/app-root
13+
COPY --chown=default web web
14+
COPY --chown=default mocks mocks
15+
16+
WORKDIR /opt/app-root/web
17+
RUN npm run format-all
18+
RUN npm run build$BUILDSCRIPT
19+
20+
FROM scratch
21+
22+
COPY --from=web-builder /opt/app-root/web/dist /opt/app-root/web/dist

0 commit comments

Comments
 (0)