Skip to content

Commit

Permalink
Building frontend only once (netobserv#718)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierCazade committed Feb 10, 2025
1 parent 3468c48 commit f0931f3
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 18 deletions.
53 changes: 53 additions & 0 deletions .tekton/pipeline-ref.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ spec:
path-context
name: dockerfile
type: string
- default: "Dockerfile.front.downstream"
description: Path to the frontend Dockerfile inside the context specified by parameter
path-context
name: front-dockerfile
type: string
- default: "false"
description: Force rebuild image
name: rebuild
Expand Down Expand Up @@ -173,6 +178,52 @@ spec:
workspace: git-auth
- name: netrc
workspace: netrc
- name: build-front-container
params:
- name: IMAGE
value: "$(params.output-image)-front"
- name: DOCKERFILE
value: $(params.front-dockerfile)
- name: CONTEXT
value: $(params.path-context)
- name: HERMETIC
value: $(params.hermetic)
- name: PREFETCH_INPUT
value: $(params.prefetch-input)
- name: IMAGE_EXPIRES_AFTER
value: $(params.image-expires-after)
- name: COMMIT_SHA
value: $(tasks.clone-repository.results.commit)
- name: BUILD_ARGS
value:
- $(params.build-args[*])
- "COMMIT=$(tasks.clone-repository.results.commit)"
- "BUILDVERSION=$(params.build-version)"
- "DATE=$(tasks.clone-repository.results.commit-timestamp)"
- name: BUILD_ARGS_FILE
value: $(params.build-args-file)
- name: SOURCE_ARTIFACT
value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
- name: CACHI2_ARTIFACT
value: $(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT)
- name: PLATFORM
value: "linux/x86_64"
runAfter:
- prefetch-dependencies
taskRef:
params:
- name: name
value: buildah-remote-oci-ta
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-buildah-remote-oci-ta:0.3@sha256:3070ee1a75e9a5a0a082008e1f9b3d2df7a9508ca107678b2613dc201eb2e279
- name: kind
value: task
resolver: bundles
when:
- input: $(tasks.init.results.build)
operator: in
values:
- "true"
- name: build-container
matrix:
params:
Expand Down Expand Up @@ -200,6 +251,7 @@ spec:
- "COMMIT=$(tasks.clone-repository.results.commit)"
- "BUILDVERSION=$(params.build-version)"
- "DATE=$(tasks.clone-repository.results.commit-timestamp)"
- "FRONTBUILD=$(params.output-image)-front"
- name: BUILD_ARGS_FILE
value: $(params.build-args-file)
- name: SOURCE_ARTIFACT
Expand All @@ -210,6 +262,7 @@ spec:
value: "true"
runAfter:
- prefetch-dependencies
- build-front-container
taskRef:
params:
- name: name
Expand Down
20 changes: 2 additions & 18 deletions Dockerfile.downstream
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
ARG COMMIT
ARG FRONTBUILD

FROM registry.access.redhat.com/ubi9/nodejs-18:1-108.1716477799 as web-builder

ARG BUILDSCRIPT
WORKDIR /opt/app-root

COPY --chown=default web/package.json web/package.json
COPY --chown=default web/package-lock.json web/package-lock.json
WORKDIR /opt/app-root/web

RUN CYPRESS_INSTALL_BINARY=0 node --max-old-space-size=6000 $(which npm) --legacy-peer-deps ci

WORKDIR /opt/app-root
COPY --chown=default web web
COPY --chown=default mocks mocks

WORKDIR /opt/app-root/web
RUN npm run format-all
RUN npm run build$BUILDSCRIPT
FROM $FRONTBUILD as web-builder

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

Expand Down
22 changes: 22 additions & 0 deletions Dockerfile.front.downstream
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM registry.access.redhat.com/ubi9/nodejs-18:1-108.1716477799 as web-builder

ARG BUILDSCRIPT
WORKDIR /opt/app-root

COPY --chown=default web/package.json web/package.json
COPY --chown=default web/package-lock.json web/package-lock.json
WORKDIR /opt/app-root/web

RUN CYPRESS_INSTALL_BINARY=0 node --max-old-space-size=6000 $(which npm) --legacy-peer-deps ci

WORKDIR /opt/app-root
COPY --chown=default web web
COPY --chown=default mocks mocks

WORKDIR /opt/app-root/web
RUN npm run format-all
RUN npm run build$BUILDSCRIPT

FROM scratch

COPY --from=web-builder /opt/app-root/web/dist /opt/app-root/web/dist

0 comments on commit f0931f3

Please sign in to comment.