Skip to content

Commit f1a5a3d

Browse files
build kn inside artifact container (#851)
build kn inside artifact container for cross platform cc @dsimansk --------- Co-authored-by: David Simansky <[email protected]>
1 parent b1239d6 commit f1a5a3d

File tree

6 files changed

+78
-12
lines changed

6 files changed

+78
-12
lines changed

.tekton/kn-client-cli-artifacts-117-pull-request.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ spec:
4242
- linux/x86_64
4343
- name: revision
4444
value: '{{revision}}'
45+
- name: prefetch-input
46+
value: '[{"type":"rpm"}]'
47+
- name: prefetch-input-dev-package-managers
48+
value: 'true'
4549
taskRunSpecs:
4650
- pipelineTaskName: sast-shell-check
4751
stepSpecs:

.tekton/kn-client-cli-artifacts-117-push.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ spec:
4141
- $(context.pipelineRun.uid)-{{revision}}
4242
- 1.37.0
4343
- latest
44+
- name: prefetch-input
45+
value: '[{"type":"rpm"}]'
46+
- name: prefetch-input-dev-package-managers
47+
value: 'true'
4448
taskRunSpecs:
4549
- pipelineTaskName: sast-shell-check
4650
stepSpecs:

hack/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ go_build_with_goos_goarch() {
167167
echo "🚧 Compile for GOOS=${GOOS} GOARCH=${GOARCH}"
168168

169169
# Env var exported by hack/build-flags.sh
170-
GOOS="${GOOS}" GOARCH="${GOARCH}" go build -ldflags "${KN_BUILD_LD_FLAGS:-}" -o kn ./cmd/...
170+
GOOS="${GOOS}" GOARCH="${GOARCH}" go build -ldflags "${KN_BUILD_LD_FLAGS:-}" -o "kn-${GOOS}-${GOARCH}" ./cmd/...
171171

172-
if $(file kn | grep -q -i "Windows"); then
173-
mv kn kn.exe
172+
if $(file "kn-${GOOS}-${GOARCH}" | grep -q -i "Windows"); then
173+
mv "kn-${GOOS}-${GOARCH}" "kn-${GOOS}-${GOARCH}.exe"
174174
fi
175175
}
176176

openshift/ci-operator/generate-ci-config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ base_images:
3030
base:
3131
name: ubi-minimal
3232
namespace: ocp
33-
tag: "8"
33+
tag: "9"
3434
binary_build_commands: |
3535
TAG=${tag} make install
3636
TAG=${tag} make build-cross

openshift/ci-operator/knative-images/cli-artifacts/Dockerfile

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,51 @@
1-
# This is not generated Dockerfile, yet!
1+
# Not generated yet!
2+
ARG GO_BUILDER=registry.ci.openshift.org/openshift/release:rhel-9-release-golang-1.23-openshift-4.19
23
ARG GO_RUNTIME=registry.access.redhat.com/ubi9/ubi-minimal
3-
ARG CLI_ARTIFACTS=registry.redhat.io/openshift-serverless-1/kn-client-cli-artifacts-rhel8:1.36.0
44

5-
FROM $CLI_ARTIFACTS as builder
5+
# ---------- BUILD STAGE ----------
6+
FROM $GO_BUILDER AS builder
7+
WORKDIR /workspace
8+
# Allow copying from higher directory when context is limited
9+
COPY . .
10+
ENV GO_COMPLIANCE_DEBUG=1
11+
ENV KN_PLUGIN_FUNC_UTIL_IMAGE=registry.redhat.io/openshift-serverless-1/kn-plugin-func-func-util-rhel9@sha256:a181b639a19b3c36367eec41e5ac0e030bcfcb247b96e6843ff60a9561ead85dn
12+
ENV KN_PLUGIN_EVENT_SENDER_IMAGE=registry.redhat.io/openshift-serverless-1/kn-plugin-event-sender-rhel9@sha256:d28cd64bfc1d0978d6f95e8b70d5bf7c36d6b92c0d60460f7ac6fa2b2ba0a15b
13+
# Build binaries
14+
# RUN make build-cross-package
15+
RUN ./hack/build.sh -p linux amd64
16+
RUN ./hack/build.sh -p linux ppc64le
17+
RUN ./hack/build.sh -p linux s390x
18+
RUN ./hack/build.sh -p linux arm64
19+
RUN ./hack/build.sh -p darwin amd64
20+
RUN ./hack/build.sh -p darwin arm64
21+
RUN ./hack/build.sh -p windows amd64
622

7-
FROM $GO_RUNTIME
23+
RUN chmod +x kn-linux-amd64 kn-linux-ppc64le kn-linux-s390x kn-windows-amd64.exe kn-darwin-amd64 kn-linux-arm64 kn-darwin-arm64
24+
25+
## ---------- PACKAGING STAGE ----------
26+
RUN dnf install -y tar zip
827

9-
ARG VERSION=knative-v1.17
28+
RUN tar --transform='flags=r;s|kn-linux-amd64|kn|' -zcf kn-linux-amd64.tar.gz kn-linux-amd64 LICENSE \
29+
&& tar --transform='flags=r;s|kn-linux-ppc64le|kn|' -zcf kn-linux-ppc64le.tar.gz kn-linux-ppc64le LICENSE \
30+
&& tar --transform='flags=r;s|kn-linux-s390x|kn|' -zcf kn-linux-s390x.tar.gz kn-linux-s390x LICENSE \
31+
&& tar --transform='flags=r;s|kn-darwin-amd64|kn|' -zcf kn-macos-amd64.tar.gz kn-darwin-amd64 LICENSE \
32+
&& tar --transform='flags=r;s|kn-linux-arm64|kn|' -zcf kn-linux-arm64.tar.gz kn-linux-arm64 LICENSE \
33+
&& tar --transform='flags=r;s|kn-darwin-arm64|kn|' -zcf kn-macos-arm64.tar.gz kn-darwin-arm64 LICENSE
1034

11-
RUN mkdir -p /usr/share/kn
35+
RUN mkdir "windows" && mv kn-windows-amd64.exe ./windows/kn.exe && cp LICENSE ./windows/ && zip --quiet --junk-path - windows/* > kn-windows-amd64.zip
36+
37+
# ---------- FINAL RUNTIME IMAGE ----------
38+
FROM $GO_RUNTIME
39+
RUN mkdir -p /usr/share/kn/{linux_amd64,linux_arm64,linux_ppc64le,linux_s390x,macos_amd64,macos_arm64,windows}
1240

13-
COPY --from=builder /usr/share/kn /usr/share/kn
14-
COPY LICENSE /licenses/
41+
COPY --from=builder /workspace/kn-linux-amd64.tar.gz /usr/share/kn/linux_amd64/
42+
COPY --from=builder /workspace/kn-linux-ppc64le.tar.gz /usr/share/kn/linux_ppc64le/
43+
COPY --from=builder /workspace/kn-linux-s390x.tar.gz /usr/share/kn/linux_s390x/
44+
COPY --from=builder /workspace/kn-macos-amd64.tar.gz /usr/share/kn/macos_amd64/
45+
COPY --from=builder /workspace/kn-windows-amd64.zip /usr/share/kn/windows/
46+
COPY --from=builder /workspace/kn-linux-arm64.tar.gz /usr/share/kn/linux_arm64/
47+
COPY --from=builder /workspace/kn-linux-arm64.tar.gz /usr/share/kn/macos_arm64/
48+
COPY --from=builder /workspace/LICENSE /licenses/
1549

1650
USER 65532
1751

rpms.in.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
contentOrigin:
2+
# Define at least one source of packages, but you can have as many as you want.
3+
repofiles:
4+
# Either local path or url pointing to .repo file
5+
- 'https://raw.githubusercontent.com/konflux-ci/bazel-builder/refs/heads/bazel8-ubi9/ubi9.repo'
6+
packages:
7+
# list of rpm names to resolve
8+
- tar
9+
- zip
10+
11+
arches:
12+
# The list of architectures can be set in the config file. Any `--arch` option set
13+
# on the command line will override this list.
14+
- x86_64
15+
- aarch64
16+
- s390x
17+
- ppc64le
18+
19+
context:
20+
# Alternative to setting command line options. Usually you will only want
21+
# to include one of these options, with the exception of `flatpak` that
22+
# can be combined with `image` and `containerfile`
23+
# containerfile: ubi9.Containerfile
24+
image: registry.access.redhat.com/ubi9/ubi-minimal

0 commit comments

Comments
 (0)