Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Konflux building frontend only once #718

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you specify the architecture, won't it reject it when trying to build the full image on a different architecture?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, looks like it worked 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the build-container task is run multiple times because of the architecture, this is done by using the matrix definition and running the task for each platform value:

The new build-front-container is only run once, the platform here is just to tell konflux which platform to use to build it once.

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