Skip to content

Commit

Permalink
[openshift-knative/hack] Add image generators
Browse files Browse the repository at this point in the history
  • Loading branch information
dsimansk committed Sep 12, 2024
1 parent 9360342 commit fb4ab67
Show file tree
Hide file tree
Showing 16 changed files with 284 additions and 64 deletions.
46 changes: 46 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
ARG GO_BUILDER=registry.ci.openshift.org/openshift/release:rhel-8-release-golang-1.22-openshift-4.17
ARG GO_RUNTIME=registry.access.redhat.com/ubi8/ubi-minimal

FROM $GO_BUILDER as builder

WORKDIR /opt/app-root/src/go/src/github.com/knative/client

COPY . .

ENV CGO_ENABLED=1
ENV GOEXPERIMENT=strictfipsruntime
ENV GOFLAGS="-tags=strictfipsruntime"

RUN pwd

RUN make build-cross

RUN microdnf install -y zip tar gzip && \
bash package_cliartifacts.sh


ARG VERSION=knative-v1.15
FROM $GO_RUNTIME

RUN mkdir -p /usr/share/kn/{linux_amd64,linux_arm64,linux_ppc64le,linux_s390x,macos_amd64,macos_arm64,windows}

COPY --from=builder /opt/app-root/src/go/src/github.com/knative/client/kn-linux-amd64.tar.gz /usr/share/kn/linux_amd64/
COPY --from=builder /opt/app-root/src/go/src/github.com/knative/client/kn-linux-arm64.tar.gz /usr/share/kn/linux_arm64/
COPY --from=builder /opt/app-root/src/go/src/github.com/knative/client/kn-linux-ppc64le.tar.gz /usr/share/kn/linux_ppc64le/
COPY --from=builder /opt/app-root/src/go/src/github.com/knative/client/kn-linux-s390x.tar.gz /usr/share/kn/linux_s390x/
COPY --from=builder /opt/app-root/src/go/src/github.com/knative/client/kn-macos-amd64.tar.gz /usr/share/kn/macos_amd64/
COPY --from=builder /opt/app-root/src/go/src/github.com/knative/client/kn-macos-arm64.tar.gz /usr/share/kn/macos_arm64/
COPY --from=builder /opt/app-root/src/go/src/github.com/knative/client/kn-windows-amd64.zip /usr/share/kn/windows/
COPY --from=builder /opt/app-root/src/go/src/github.com/knative/client/LICENSE /usr/share/kn/LICENSE

USER 65532

LABEL \
com.redhat.component="openshift-serverless-1-kn-cli-artifacts-rhel8-container" \
name="openshift-serverless-1/kn-cli-artifacts-rhel8" \
version=$VERSION \
summary="Red Hat OpenShift Serverless 1 kn CLI artifacts" \
maintainer="[email protected]" \
description="Red Hat OpenShift Serverless 1 kn CLI artifacts" \
io.k8s.display-name="Red Hat OpenShift Serverless 1 kn CLI artifacts"

34 changes: 13 additions & 21 deletions openshift/ci-operator/build-image/Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
# Copyright 2019 The OpenShift Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# DO NOT EDIT! Generated Dockerfile.

FROM registry.ci.openshift.org/ocp/4.17:cli-artifacts as tools

# Dockerfile to bootstrap build and test in openshift-ci
FROM registry.ci.openshift.org/openshift/release:rhel-8-release-golang-1.22-openshift-4.17 as builder

# Add kubernetes repository
ADD openshift/ci-operator/build-image/kubernetes.repo /etc/yum.repos.d/
ARG TARGETARCH

COPY --from=tools /usr/share/openshift/linux_$TARGETARCH/oc.rhel8 /usr/bin/oc

RUN ln -s /usr/bin/oc /usr/bin/kubectl

RUN yum install -y kubectl httpd-tools
RUN yum install -y httpd-tools

# Serverless-Operator `make generated-files` needs helm
RUN curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
RUN wget https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 && \
chmod 700 ./get-helm-3

RUN ./get-helm-3 --version v3.11.3 --no-sudo && helm version

RUN GOFLAGS='' go install github.com/mikefarah/yq/v3@latest

# go install creates $GOPATH/.cache with root permissions, we delete it here
# to avoid permission issues with the runtime users
RUN rm -rf $GOPATH/.cache

# Allow runtime users to add entries to /etc/passwd
RUN chmod g+rw /etc/passwd
6 changes: 0 additions & 6 deletions openshift/ci-operator/build-image/kubernetes.repo

This file was deleted.

42 changes: 42 additions & 0 deletions openshift/ci-operator/knative-images/cli-artifacts/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This is not generated Dockerfile, yet!
ARG GO_BUILDER=registry.ci.openshift.org/openshift/release:rhel-8-release-golang-1.22-openshift-4.17
ARG GO_RUNTIME=registry.access.redhat.com/ubi8/ubi-minimal

FROM $GO_BUILDER as builder

WORKDIR /go/src/github.com/knative/client
COPY . .

ENV CGO_ENABLED=1
ENV GOEXPERIMENT=strictfipsruntime
# Pass to cross compile target
ENV GOFLAGS="-tags=strictfipsruntime"

RUN make build-cross && \
bash package_cliartifacts.sh

ARG VERSION=knative-v1.15
FROM $GO_RUNTIME

RUN mkdir -p /usr/share/kn/{linux_amd64,linux_arm64,linux_ppc64le,linux_s390x,macos_amd64,macos_arm64,windows}

COPY --from=builder /go/src/github.com/knative/client/kn-linux-amd64.tar.gz /usr/share/kn/linux_amd64/
COPY --from=builder /go/src/github.com/knative/client/kn-linux-arm64.tar.gz /usr/share/kn/linux_arm64/
COPY --from=builder /go/src/github.com/knative/client/kn-linux-ppc64le.tar.gz /usr/share/kn/linux_ppc64le/
COPY --from=builder /go/src/github.com/knative/client/kn-linux-s390x.tar.gz /usr/share/kn/linux_s390x/
COPY --from=builder /go/src/github.com/knative/client/kn-macos-amd64.tar.gz /usr/share/kn/macos_amd64/
COPY --from=builder /go/src/github.com/knative/client/kn-macos-arm64.tar.gz /usr/share/kn/macos_arm64/
COPY --from=builder /go/src/github.com/knative/client/kn-windows-amd64.zip /usr/share/kn/windows/
COPY --from=builder /go/src/github.com/knative/client/LICENSE /usr/share/kn/LICENSE

USER 65532

LABEL \
com.redhat.component="openshift-serverless-1-kn-cli-artifacts-rhel8-container" \
name="openshift-serverless-1/kn-cli-artifacts-rhel8" \
version=$VERSION \
summary="Red Hat OpenShift Serverless 1 kn CLI artifacts" \
maintainer="[email protected]" \
description="Red Hat OpenShift Serverless 1 kn CLI artifacts" \
io.k8s.display-name="Red Hat OpenShift Serverless 1 kn CLI artifacts"

5 changes: 0 additions & 5 deletions openshift/ci-operator/knative-images/client/Dockerfile

This file was deleted.

This file was deleted.

31 changes: 31 additions & 0 deletions openshift/ci-operator/knative-images/kn/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# DO NOT EDIT! Generated Dockerfile for cmd/kn.
ARG GO_BUILDER=registry.ci.openshift.org/openshift/release:rhel-8-release-golang-1.22-openshift-4.17
ARG GO_RUNTIME=registry.access.redhat.com/ubi8/ubi-minimal

FROM $GO_BUILDER as builder

COPY . .

ENV CGO_ENABLED=1
ENV GOEXPERIMENT=strictfipsruntime

RUN go build -tags strictfipsruntime -o /usr/bin/main ./cmd/kn

FROM $GO_RUNTIME

ARG VERSION=knative-v1.15

COPY --from=builder /usr/bin/main /ko-app/kn

USER 65532

LABEL \
com.redhat.component="openshift-serverless-1-eventing-kn-rhel8-container" \
name="openshift-serverless-1/eventing-kn-rhel8" \
version=$VERSION \
summary="Red Hat OpenShift Serverless 1 Eventing Kn" \
maintainer="[email protected]" \
description="Red Hat OpenShift Serverless 1 Eventing Kn" \
io.k8s.display-name="Red Hat OpenShift Serverless 1 Eventing Kn"

ENTRYPOINT ["/ko-app/kn"]
31 changes: 28 additions & 3 deletions openshift/ci-operator/knative-test-images/grpc-ping/Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
FROM openshift/origin-base
# DO NOT EDIT! Generated Dockerfile for vendor/knative.dev/serving/test/test_images/grpc-ping.
ARG GO_BUILDER=registry.ci.openshift.org/openshift/release:rhel-8-release-golang-1.22-openshift-4.17
ARG GO_RUNTIME=registry.access.redhat.com/ubi8/ubi-minimal

FROM $GO_BUILDER as builder

COPY . .

ENV CGO_ENABLED=1
ENV GOEXPERIMENT=strictfipsruntime

RUN go build -tags strictfipsruntime -o /usr/bin/main ./vendor/knative.dev/serving/test/test_images/grpc-ping

FROM $GO_RUNTIME

ARG VERSION=knative-v1.15

COPY --from=builder /usr/bin/main /ko-app/grpc-ping

USER 65532

ADD grpc-ping /ko-app/grpc-ping
LABEL \
com.redhat.component="openshift-serverless-1-eventing-vendor-knative.dev-serving-test-test-images-grpc-ping-rhel8-container" \
name="openshift-serverless-1/eventing-vendor-knative.dev-serving-test-test-images-grpc-ping-rhel8" \
version=$VERSION \
summary="Red Hat OpenShift Serverless 1 Eventing Vendor Knative.Dev Serving Test Test Images Grpc Ping" \
maintainer="[email protected]" \
description="Red Hat OpenShift Serverless 1 Eventing Vendor Knative.Dev Serving Test Test Images Grpc Ping" \
io.k8s.display-name="Red Hat OpenShift Serverless 1 Eventing Vendor Knative.Dev Serving Test Test Images Grpc Ping"

ENTRYPOINT ["/ko-app/grpc-ping"]
ENTRYPOINT ["/ko-app/grpc-ping"]
31 changes: 28 additions & 3 deletions openshift/ci-operator/knative-test-images/helloworld/Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
FROM openshift/origin-base
# DO NOT EDIT! Generated Dockerfile for test/test_images/helloworld.
ARG GO_BUILDER=registry.ci.openshift.org/openshift/release:rhel-8-release-golang-1.22-openshift-4.17
ARG GO_RUNTIME=registry.access.redhat.com/ubi8/ubi-minimal

FROM $GO_BUILDER as builder

COPY . .

ENV CGO_ENABLED=1
ENV GOEXPERIMENT=strictfipsruntime

RUN go build -tags strictfipsruntime -o /usr/bin/main ./test/test_images/helloworld

FROM $GO_RUNTIME

ARG VERSION=knative-v1.15

COPY --from=builder /usr/bin/main /ko-app/helloworld

USER 65532

ADD helloworld /ko-app/helloworld
LABEL \
com.redhat.component="openshift-serverless-1-eventing-test-test-images-helloworld-rhel8-container" \
name="openshift-serverless-1/eventing-test-test-images-helloworld-rhel8" \
version=$VERSION \
summary="Red Hat OpenShift Serverless 1 Eventing Test Test Images Helloworld" \
maintainer="[email protected]" \
description="Red Hat OpenShift Serverless 1 Eventing Test Test Images Helloworld" \
io.k8s.display-name="Red Hat OpenShift Serverless 1 Eventing Test Test Images Helloworld"

ENTRYPOINT ["/ko-app/helloworld"]
ENTRYPOINT ["/ko-app/helloworld"]
31 changes: 28 additions & 3 deletions openshift/ci-operator/knative-test-images/servingcontainer/Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
# Do not edit! This file was generated via Makefile
FROM openshift/origin-base
# DO NOT EDIT! Generated Dockerfile for vendor/knative.dev/serving/test/test_images/multicontainer/servingcontainer.
ARG GO_BUILDER=registry.ci.openshift.org/openshift/release:rhel-8-release-golang-1.22-openshift-4.17
ARG GO_RUNTIME=registry.access.redhat.com/ubi8/ubi-minimal

FROM $GO_BUILDER as builder

COPY . .

ENV CGO_ENABLED=1
ENV GOEXPERIMENT=strictfipsruntime

RUN go build -tags strictfipsruntime -o /usr/bin/main ./vendor/knative.dev/serving/test/test_images/multicontainer/servingcontainer

FROM $GO_RUNTIME

ARG VERSION=knative-v1.15

COPY --from=builder /usr/bin/main /ko-app/servingcontainer

USER 65532

ADD servingcontainer /ko-app/servingcontainer
LABEL \
com.redhat.component="openshift-serverless-1-eventing-vendor-knative.dev-serving-test-test-images-multicontainer-servingcontainer-rhel8-container" \
name="openshift-serverless-1/eventing-vendor-knative.dev-serving-test-test-images-multicontainer-servingcontainer-rhel8" \
version=$VERSION \
summary="Red Hat OpenShift Serverless 1 Eventing Vendor Knative.Dev Serving Test Test Images Multicontainer Servingcontainer" \
maintainer="[email protected]" \
description="Red Hat OpenShift Serverless 1 Eventing Vendor Knative.Dev Serving Test Test Images Multicontainer Servingcontainer" \
io.k8s.display-name="Red Hat OpenShift Serverless 1 Eventing Vendor Knative.Dev Serving Test Test Images Multicontainer Servingcontainer"

ENTRYPOINT ["/ko-app/servingcontainer"]
31 changes: 28 additions & 3 deletions openshift/ci-operator/knative-test-images/sidecarcontainer/Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
# Do not edit! This file was generated via Makefile
FROM openshift/origin-base
# DO NOT EDIT! Generated Dockerfile for vendor/knative.dev/serving/test/test_images/multicontainer/sidecarcontainer.
ARG GO_BUILDER=registry.ci.openshift.org/openshift/release:rhel-8-release-golang-1.22-openshift-4.17
ARG GO_RUNTIME=registry.access.redhat.com/ubi8/ubi-minimal

FROM $GO_BUILDER as builder

COPY . .

ENV CGO_ENABLED=1
ENV GOEXPERIMENT=strictfipsruntime

RUN go build -tags strictfipsruntime -o /usr/bin/main ./vendor/knative.dev/serving/test/test_images/multicontainer/sidecarcontainer

FROM $GO_RUNTIME

ARG VERSION=knative-v1.15

COPY --from=builder /usr/bin/main /ko-app/sidecarcontainer

USER 65532

ADD sidecarcontainer /ko-app/sidecarcontainer
LABEL \
com.redhat.component="openshift-serverless-1-eventing-vendor-knative.dev-serving-test-test-images-multicontainer-sidecarcontainer-rhel8-container" \
name="openshift-serverless-1/eventing-vendor-knative.dev-serving-test-test-images-multicontainer-sidecarcontainer-rhel8" \
version=$VERSION \
summary="Red Hat OpenShift Serverless 1 Eventing Vendor Knative.Dev Serving Test Test Images Multicontainer Sidecarcontainer" \
maintainer="[email protected]" \
description="Red Hat OpenShift Serverless 1 Eventing Vendor Knative.Dev Serving Test Test Images Multicontainer Sidecarcontainer" \
io.k8s.display-name="Red Hat OpenShift Serverless 1 Eventing Vendor Knative.Dev Serving Test Test Images Multicontainer Sidecarcontainer"

ENTRYPOINT ["/ko-app/sidecarcontainer"]
7 changes: 7 additions & 0 deletions openshift/ci-operator/source-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# DO NOT EDIT! Generated Dockerfile.

FROM src

RUN chmod +x vendor/k8s.io/code-generator/generate-groups.sh || true
RUN chmod +x vendor/knative.dev/pkg/hack/generate-knative.sh || true
RUN chmod +x vendor/k8s.io/code-generator/generate-internal-groups.sh || true
24 changes: 24 additions & 0 deletions openshift/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
#
# This script generates the productized Dockerfiles
#

set -o errexit
set -o nounset
set -o pipefail

function install_generate_hack_tool() {
go install github.com/openshift-knative/hack/cmd/generate@latest
return $?
}

repo_root_dir=$(dirname "$(realpath "${BASH_SOURCE[0]}")")/..

install_generate_hack_tool || exit 1

# --app-file-fmt is used to mimic ko build, it's assumed in --cmd flag tests
"$(go env GOPATH)"/bin/generate \
--root-dir "${repo_root_dir}" \
--generators dockerfile \
--app-file-fmt "/ko-app/%s" \
--dockerfile-image-builder-fmt "registry.ci.openshift.org/openshift/release:rhel-8-release-golang-%s-openshift-4.17"
5 changes: 5 additions & 0 deletions openshift/images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
knative.dev/client/cmd/kn: registry.ci.openshift.org/openshift/knative-eventing-kn:knative-v1.15
knative.dev/client/test/test_images/helloworld: registry.ci.openshift.org/openshift/knative-eventing-test-helloworld:knative-v1.15
knative.dev/serving/test/test_images/grpc-ping: registry.ci.openshift.org/openshift/knative-eventing-test-grpc-ping:knative-v1.15
knative.dev/serving/test/test_images/multicontainer/servingcontainer: registry.ci.openshift.org/openshift/knative-eventing-test-servingcontainer:knative-v1.15
knative.dev/serving/test/test_images/multicontainer/sidecarcontainer: registry.ci.openshift.org/openshift/knative-eventing-test-sidecarcontainer:knative-v1.15
3 changes: 3 additions & 0 deletions openshift/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
project:
tag: knative-v1.15
imagePrefix: knative-eventing
2 changes: 1 addition & 1 deletion package_cliartifacts.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This script is used to package kn cross platform cli artifacts
# for kn-cli-artifacts image
# for cli-artifacts image
# Copyright 2020 The OpenShift Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down

0 comments on commit fb4ab67

Please sign in to comment.