From 8081170b043022b02dc5b200b15308d6acd7f1eb Mon Sep 17 00:00:00 2001 From: Rael Garcia Arnes Date: Tue, 17 Dec 2024 16:51:20 +0100 Subject: [PATCH 1/8] feat: add PolicyGenerator binary to kubectl plugin Signed-off-by: Rael Garcia Arnes --- Dockerfile | 14 ++++++++++++++ Dockerfile-ci | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Dockerfile b/Dockerfile index 735d395..4087368 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,15 @@ RUN GO111MODULE=on go install -v -x -a github.com/raviqqe/liche@latest FROM gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.45.0 as git-init +FROM alpine:3.20 as PolicyGenerator + +ENV VERSION="v1.16.0" +ENV REGISTRY="open-cluster-management-io/policy-generator-plugin" +ENV BINARY="/bin/PolicyGenerator" + +RUN if [ $(uname -m) == "aarch64" ]; then ARCH="arm64"; else ARCH="amd64"; fi; \ + wget -q "https://github.com/${REGISTRY}/releases/download/${VERSION}/linux-${ARCH}-PolicyGenerator" -O ${BINARY} + FROM alpine:3.20 as gh ENV GITHUB_CLI_VERSION=2.0.0 @@ -79,6 +88,11 @@ COPY --from=gh /bin/gh /usr/local/bin COPY --from=yq /bin/yq /usr/local/bin +ENV KUSTOMIZE_PLUGIN_HOME /opt/kustomize/plugin + +COPY --from=PolicyGenerator --chmod=775 /bin/PolicyGenerator \ + /opt/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator + # ENV GO_BIN /go/bin # ENV PATH "$GO_BIN:$PATH" diff --git a/Dockerfile-ci b/Dockerfile-ci index 20e66e4..49e258e 100644 --- a/Dockerfile-ci +++ b/Dockerfile-ci @@ -10,6 +10,15 @@ RUN GO111MODULE=on go install github.com/raviqqe/liche@latest FROM gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.45.0 as git-init +FROM alpine:3.20 as PolicyGenerator + +ENV VERSION="v1.16.0" +ENV REGISTRY="open-cluster-management-io/policy-generator-plugin" +ENV BINARY="/bin/PolicyGenerator" + +RUN if [ $(uname -m) == "aarch64" ]; then ARCH="arm64"; else ARCH="amd64"; fi; \ + wget -q "https://github.com/${REGISTRY}/releases/download/${VERSION}/linux-${ARCH}-PolicyGenerator" -O ${BINARY} + FROM alpine:3.20 as gh ENV GITHUB_CLI_VERSION=2.0.0 @@ -45,6 +54,11 @@ COPY --from=gh /bin/gh /usr/local/bin COPY --from=yq /bin/yq /usr/local/bin +ENV KUSTOMIZE_PLUGIN_HOME /opt/kustomize/plugin + +COPY --from=PolicyGenerator --chmod=775 /bin/PolicyGenerator \ + /opt/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator + ENV GO_BIN /go/bin ENV PATH "$GO_BIN:$PATH" From a902b6f2fd1d6c144da1f965da44c40904d2c212 Mon Sep 17 00:00:00 2001 From: Rael Garcia Arnes Date: Tue, 17 Dec 2024 16:56:24 +0100 Subject: [PATCH 2/8] feat: add kubectl binary Signed-off-by: Rael Garcia Arnes --- Dockerfile | 10 ++++++++++ Dockerfile-ci | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/Dockerfile b/Dockerfile index 4087368..d1ee73a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,14 @@ RUN GO111MODULE=on go install -v -x -a github.com/raviqqe/liche@latest FROM gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.45.0 as git-init +FROM alpine:3.20 as kubectl + +ENV VERSION="v1.32.0" +ENV BINARY="/bin/kubectl" + +RUN if [ $(uname -m) == "aarch64" ]; then ARCH="arm64"; else ARCH="amd64"; fi; \ + wget -q "https://dl.k8s.io/release/${VERSION}/bin/linux/${ARCH}/kubectl" -O ${BINARY} + FROM alpine:3.20 as PolicyGenerator ENV VERSION="v1.16.0" @@ -88,6 +96,8 @@ COPY --from=gh /bin/gh /usr/local/bin COPY --from=yq /bin/yq /usr/local/bin +COPY --from=kubectl --chmod=775 /bin/kubectl /usr/local/bin + ENV KUSTOMIZE_PLUGIN_HOME /opt/kustomize/plugin COPY --from=PolicyGenerator --chmod=775 /bin/PolicyGenerator \ diff --git a/Dockerfile-ci b/Dockerfile-ci index 49e258e..e1000d6 100644 --- a/Dockerfile-ci +++ b/Dockerfile-ci @@ -10,6 +10,14 @@ RUN GO111MODULE=on go install github.com/raviqqe/liche@latest FROM gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.45.0 as git-init +FROM alpine:3.20 as kubectl + +ENV VERSION="v1.32.0" +ENV BINARY="/bin/kubectl" + +RUN if [ $(uname -m) == "aarch64" ]; then ARCH="arm64"; else ARCH="amd64"; fi; \ + wget -q "https://dl.k8s.io/release/${VERSION}/bin/linux/${ARCH}/kubectl" -O ${BINARY} + FROM alpine:3.20 as PolicyGenerator ENV VERSION="v1.16.0" @@ -54,6 +62,8 @@ COPY --from=gh /bin/gh /usr/local/bin COPY --from=yq /bin/yq /usr/local/bin +COPY --from=kubectl --chmod=775 /bin/kubectl /usr/local/bin + ENV KUSTOMIZE_PLUGIN_HOME /opt/kustomize/plugin COPY --from=PolicyGenerator --chmod=775 /bin/PolicyGenerator \ From e91070286115aa73557b75935e3c1de09bb9978a Mon Sep 17 00:00:00 2001 From: Rael Garcia Arnes Date: Tue, 17 Dec 2024 16:51:39 +0100 Subject: [PATCH 3/8] release: bump version to 4.5.4 Signed-off-by: Rael Garcia Arnes --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 589c016..806b03e 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY: help -TAG ?= 4.5.3 +TAG ?= 4.5.4 CI_TAG ?= ci HUB ?= quay.io/3scale IMAGE ?= quay.io/3scale/soyuz From 57f5b92145fcf3b280b3df3f6403fa3d194a59f2 Mon Sep 17 00:00:00 2001 From: Rael Garcia Arnes Date: Tue, 17 Dec 2024 17:06:07 +0100 Subject: [PATCH 4/8] fix: typo in Build action Signed-off-by: Rael Garcia Arnes --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 80e77dc..54dfd20 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -20,7 +20,7 @@ jobs: with: file: Dockerfile platforms: linux/amd64,linux/arm64 - push: flalse + push: false tags: quay.io/3scale/soyuz:test - name: Build CI Image From f0b8dc61c1ce171ca4a4ca5cbf6b75d00ef106a1 Mon Sep 17 00:00:00 2001 From: Rael Garcia Arnes Date: Tue, 17 Dec 2024 17:23:49 +0100 Subject: [PATCH 5/8] docs: rename docker test job Signed-off-by: Rael Garcia Arnes --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 54dfd20..5fbbe3c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -6,7 +6,7 @@ on: - main jobs: - docker: + image-build-test: runs-on: ubuntu-latest steps: - name: Set up QEMU From 4db1dff13a212e768bc9027998d0b5bf63386efa Mon Sep 17 00:00:00 2001 From: Rael Garcia Arnes Date: Tue, 17 Dec 2024 17:34:16 +0100 Subject: [PATCH 6/8] fix: update Dockerfile syntax Signed-off-by: Rael Garcia Arnes --- Dockerfile | 45 ++++++++++++++++++++------------------------- Dockerfile-ci | 28 ++++++++++++++-------------- 2 files changed, 34 insertions(+), 39 deletions(-) diff --git a/Dockerfile b/Dockerfile index d1ee73a..55d6694 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,16 @@ -FROM hashicorp/terraform:1.3.5 as terraform +FROM hashicorp/terraform:1.3.5 AS terraform -FROM amazon/aws-cli:2.8.13 as aws +FROM amazon/aws-cli:2.8.13 AS aws -FROM regclient/regctl:edge-alpine as regctl +FROM regclient/regctl:edge-alpine AS regctl -FROM golang:1.19.3-bullseye as go +FROM golang:1.19.3-bullseye AS go RUN GO111MODULE=on go install -v -x -a github.com/raviqqe/liche@latest -FROM gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.45.0 as git-init +FROM gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.45.0 AS git-init -FROM alpine:3.20 as kubectl +FROM alpine:3.20 AS kubectl ENV VERSION="v1.32.0" ENV BINARY="/bin/kubectl" @@ -18,7 +18,7 @@ ENV BINARY="/bin/kubectl" RUN if [ $(uname -m) == "aarch64" ]; then ARCH="arm64"; else ARCH="amd64"; fi; \ wget -q "https://dl.k8s.io/release/${VERSION}/bin/linux/${ARCH}/kubectl" -O ${BINARY} -FROM alpine:3.20 as PolicyGenerator +FROM alpine:3.20 AS policygenerator ENV VERSION="v1.16.0" ENV REGISTRY="open-cluster-management-io/policy-generator-plugin" @@ -27,7 +27,7 @@ ENV BINARY="/bin/PolicyGenerator" RUN if [ $(uname -m) == "aarch64" ]; then ARCH="arm64"; else ARCH="amd64"; fi; \ wget -q "https://github.com/${REGISTRY}/releases/download/${VERSION}/linux-${ARCH}-PolicyGenerator" -O ${BINARY} -FROM alpine:3.20 as gh +FROM alpine:3.20 AS gh ENV GITHUB_CLI_VERSION=2.0.0 RUN if [ $(uname -m) == "aarch64" ]; then ARCH=arm64; else ARCH=amd64; fi; \ @@ -35,7 +35,7 @@ RUN if [ $(uname -m) == "aarch64" ]; then ARCH=arm64; else ARCH=amd64; fi; \ tar --strip-components=2 --extract --file /tmp/gh.tgz \ gh_${GITHUB_CLI_VERSION}_linux_${ARCH}/bin/gh && mv -v gh /bin/gh -FROM alpine:3.20 as yq +FROM alpine:3.20 AS yq ENV VERSION=v4.30.5 RUN if [ $(uname -m) == "aarch64" ]; then ARCH=arm64; else ARCH=amd64; fi; \ @@ -43,7 +43,7 @@ RUN if [ $(uname -m) == "aarch64" ]; then ARCH=arm64; else ARCH=amd64; fi; \ tar --extract --file /tmp/yq.tgz \ ./yq_linux_${ARCH} && mv -v yq_linux_${ARCH} /bin/yq -FROM alpine:3.20 as mysql +FROM alpine:3.20 AS mysql RUN if [ $(uname -m) == "aarch64" ]; then ARCH=aarch64; else ARCH=x86_64; fi; \ wget -O /tmp/mysql.tgz https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.39-linux-glibc2.28-${ARCH}.tar.xz && \ @@ -54,7 +54,7 @@ RUN if [ $(uname -m) == "aarch64" ]; then ARCH=aarch64; else ARCH=x86_64; fi; \ FROM debian:12.4-slim -ENV DEBIAN_FRONTEND noninteractive +ENV DEBIAN_FRONTEND="noninteractive" RUN apt-get update -yq && \ DEBIAN_FRONTEND=noninteractive \ @@ -71,9 +71,9 @@ RUN \ echo "LANG=en_US.UTF-8" >/etc/locale.conf && \ locale-gen en_US.UTF-8 -ENV LANG "en_US.UTF-8" -ENV LANGUAGE "en_US.UTF-8" -ENV LC_ALL "en_US.UTF-8" +ENV LANG="en_US.UTF-8" +ENV LANGUAGE="en_US.UTF-8" +ENV LC_ALL="en_US.UTF-8" COPY --from=mysql /bin/mysql /usr/local/bin COPY --from=mysql /bin/mysqldump /usr/local/bin @@ -83,8 +83,8 @@ RUN gem install \ COPY --from=aws /usr/local/aws-cli /usr/local/aws-cli -ENV AWS_BIN /usr/local/aws-cli/v2/current/bin -ENV PATH "$AWS_BIN:$PATH" +ENV AWS_BIN="/usr/local/aws-cli/v2/current/bin" +ENV PATH="$AWS_BIN:$PATH" COPY --from=git-init /ko-app/git-init /usr/local/bin @@ -98,18 +98,13 @@ COPY --from=yq /bin/yq /usr/local/bin COPY --from=kubectl --chmod=775 /bin/kubectl /usr/local/bin -ENV KUSTOMIZE_PLUGIN_HOME /opt/kustomize/plugin +ENV KUSTOMIZE_PLUGIN_HOME="/opt/kustomize/plugin" -COPY --from=PolicyGenerator --chmod=775 /bin/PolicyGenerator \ +COPY --from=policygenerator --chmod=775 /bin/PolicyGenerator \ /opt/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator -# ENV GO_BIN /go/bin -# ENV PATH "$GO_BIN:$PATH" - -# COPY --from=go /go/bin $GO_BIN - -ENV BIN_3SCALE /opt/3scale/bin -ENV PATH "$BIN_3SCALE:$PATH" +ENV BIN_3SCALE="/opt/3scale/bin" +ENV PATH="$BIN_3SCALE:$PATH" ADD bin/ $BIN_3SCALE RUN chmod -R 0755 $BIN_3SCALE diff --git a/Dockerfile-ci b/Dockerfile-ci index e1000d6..a7afef5 100644 --- a/Dockerfile-ci +++ b/Dockerfile-ci @@ -1,16 +1,16 @@ -FROM hashicorp/terraform:1.3.5 as terraform +FROM hashicorp/terraform:1.3.5 AS terraform -FROM regclient/regctl:edge-alpine as regctl +FROM regclient/regctl:edge-alpine AS regctl -FROM golang:1.19.3-alpine as go +FROM golang:1.19.3-alpine AS go RUN apk add --update git RUN GO111MODULE=on go install github.com/raviqqe/liche@latest -FROM gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.45.0 as git-init +FROM gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.45.0 AS git-init -FROM alpine:3.20 as kubectl +FROM alpine:3.20 AS kubectl ENV VERSION="v1.32.0" ENV BINARY="/bin/kubectl" @@ -18,7 +18,7 @@ ENV BINARY="/bin/kubectl" RUN if [ $(uname -m) == "aarch64" ]; then ARCH="arm64"; else ARCH="amd64"; fi; \ wget -q "https://dl.k8s.io/release/${VERSION}/bin/linux/${ARCH}/kubectl" -O ${BINARY} -FROM alpine:3.20 as PolicyGenerator +FROM alpine:3.20 AS policygenerator ENV VERSION="v1.16.0" ENV REGISTRY="open-cluster-management-io/policy-generator-plugin" @@ -27,7 +27,7 @@ ENV BINARY="/bin/PolicyGenerator" RUN if [ $(uname -m) == "aarch64" ]; then ARCH="arm64"; else ARCH="amd64"; fi; \ wget -q "https://github.com/${REGISTRY}/releases/download/${VERSION}/linux-${ARCH}-PolicyGenerator" -O ${BINARY} -FROM alpine:3.20 as gh +FROM alpine:3.20 AS gh ENV GITHUB_CLI_VERSION=2.0.0 RUN if [ $(uname -m) == "aarch64" ]; then ARCH=arm64; else ARCH=amd64; fi; \ @@ -35,7 +35,7 @@ RUN if [ $(uname -m) == "aarch64" ]; then ARCH=arm64; else ARCH=amd64; fi; \ tar --strip-components=2 --extract --file /tmp/gh.tgz \ gh_${GITHUB_CLI_VERSION}_linux_${ARCH}/bin/gh && mv -v gh /bin/gh -FROM alpine:3.20 as yq +FROM alpine:3.20 AS yq ENV VERSION=v4.30.5 RUN if [ $(uname -m) == "aarch64" ]; then ARCH=arm64; else ARCH=amd64; fi; \ @@ -64,18 +64,18 @@ COPY --from=yq /bin/yq /usr/local/bin COPY --from=kubectl --chmod=775 /bin/kubectl /usr/local/bin -ENV KUSTOMIZE_PLUGIN_HOME /opt/kustomize/plugin +ENV KUSTOMIZE_PLUGIN_HOME="/opt/kustomize/plugin" -COPY --from=PolicyGenerator --chmod=775 /bin/PolicyGenerator \ +COPY --from=policygenerator --chmod=775 /bin/PolicyGenerator \ /opt/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator -ENV GO_BIN /go/bin -ENV PATH "$GO_BIN:$PATH" +ENV GO_BIN="/go/bin" +ENV PATH="$GO_BIN:$PATH" COPY --from=go /go/bin $GO_BIN -ENV BIN_3SCALE /opt/3scale/bin -ENV PATH "$BIN_3SCALE:$PATH" +ENV BIN_3SCALE="/opt/3scale/bin" +ENV PATH="$BIN_3SCALE:$PATH" ADD bin/ $BIN_3SCALE RUN chmod -R 0755 $BIN_3SCALE From a32401781315d1e43afbe6a140abe382041f2833 Mon Sep 17 00:00:00 2001 From: Rael Garcia Arnes Date: Tue, 17 Dec 2024 17:35:47 +0100 Subject: [PATCH 7/8] fix: pin gh jobs to ubuntu-24.04 Signed-off-by: Rael Garcia Arnes --- .github/workflows/release.yaml | 4 ++-- .github/workflows/test.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 18e312e..c237a86 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -7,7 +7,7 @@ on: jobs: release: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - id: meta name: Docker meta @@ -51,7 +51,7 @@ jobs: images: | quay.io/3scale/soyuz tags: | - type=raw,value={{tag}}-ci + type=raw,value={{tag}}-ci - name: Set up QEMU uses: docker/setup-qemu-action@v3 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5fbbe3c..10988d3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -7,7 +7,7 @@ on: jobs: image-build-test: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Set up QEMU uses: docker/setup-qemu-action@v3 From 654d0ec90c0a7e0f2bde195a53914011f05f0e53 Mon Sep 17 00:00:00 2001 From: Rael Garcia Arnes Date: Tue, 17 Dec 2024 17:39:50 +0100 Subject: [PATCH 8/8] feat: run build tests in paralell Signed-off-by: Rael Garcia Arnes --- .github/workflows/test.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 10988d3..537016e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -23,6 +23,15 @@ jobs: push: false tags: quay.io/3scale/soyuz:test + ci-image-build-test: + runs-on: ubuntu-24.04 + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build CI Image uses: docker/build-push-action@v6 with: