Skip to content

Commit

Permalink
Simplify images Makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
rikatz committed Jan 12, 2024
1 parent 2f0cbae commit 388fc74
Show file tree
Hide file tree
Showing 36 changed files with 114 additions and 523 deletions.
25 changes: 13 additions & 12 deletions .github/workflows/images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ on:
- 'images/**'

permissions:
contents: read
contents: write
packages: write

env:
PLATFORMS: linux/amd64
Expand All @@ -29,7 +30,7 @@ jobs:
custom-error-pages: ${{ steps.filter.outputs.custom-error-pages }}
cfssl: ${{ steps.filter.outputs.cfssl }}
fastcgi-helloserver: ${{ steps.filter.outputs.fastcgi-helloserver }}
echo: ${{ steps.filter.outputs.echo }}
e2e-test-echo: ${{ steps.filter.outputs.e2e-test-echo }}
go-grpc-greeter-server: ${{ steps.filter.outputs.go-grpc-greeter-server }}
httpbun: ${{ steps.filter.outputs.httpbun }}
kube-webhook-certgen: ${{ steps.filter.outputs.kube-webhook-certgen }}
Expand All @@ -50,8 +51,8 @@ jobs:
- 'images/cfssl/**'
fastcgi-helloserver:
- 'images/fastcgi-helloserver/**'
echo:
- 'images/echo/**'
e2e-test-echo:
- 'images/e2e-test-echo/**'
go-grpc-greeter-server:
- 'images/go-grpc-greeter-server/**'
httpbun:
Expand Down Expand Up @@ -80,13 +81,13 @@ jobs:
with:
name: custom-error-pages

echo:
e2e-test-echo:
needs: changes
if: |
(needs.changes.outputs.echo == 'true')
(needs.changes.outputs.e2e-test-echo == 'true')
uses: ./.github/workflows/zz-tmpl-images.yaml
with:
name: echo
name: e2e-test-echo

ext-auth-example-authsvc:
needs: changes
Expand All @@ -96,13 +97,13 @@ jobs:
with:
name: ext-auth-example-authsvc

fastcfgi-helloserver:
fastcgi-helloserver:
needs: changes
if: |
(needs.changes.outputs.fastcfgi-helloserver == 'true')
(needs.changes.outputs.fastcgi-helloserver == 'true')
uses: ./.github/workflows/zz-tmpl-images.yaml
with:
name: fastcfgi-helloserver
name: fastcgi-helloserver

go-grpc-greeter-server:
needs: changes
Expand Down Expand Up @@ -139,14 +140,14 @@ jobs:
check-latest: true
- name: image build
run: |
cd images/kube-webhook-certgen && make build
cd images/ && make NAME=kube-webhook-certgen build
- name: Create Kubernetes cluster
id: kind
run: |
kind create cluster --image=kindest/node:${{ matrix.k8s }}
- name: image test
run: |
cd images/kube-webhook-certgen && make test test-e2e
cd images/ && make NAME=kube-webhook-certgen test test-e2e
nginx:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/junit-reports.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ jobs:
name: JEST Tests $1 # Name of the check run which will be created
path: 'report*.xml' # Path to test results (inside artifact .zip)
reporter: jest-junit # Format of test results
fail-on-empty: 'true'
52 changes: 49 additions & 3 deletions .github/workflows/zz-tmpl-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,65 @@ env:
PLATFORMS: ${{ inputs.platforms-test }}

permissions:
contents: read
contents: write
packages: write

jobs:
changestag:
permissions:
contents: read # for dorny/paths-filter to fetch a list of changed files
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.filter.outputs.tag }}

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
id: filter
with:
token: ${{ secrets.GITHUB_TOKEN }}
filters: |
tag:
- 'images/**/TAG'
image-build:
name: Build ${{ inputs.name }}
name: Build
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Build
run: |
cd images/${{ inputs.name }} && make build
cd images/ && make NAME=${{ inputs.name }} build
image-push:
name: Push
needs: changestag
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'kubernetes/ingress-nginx' && needs.changestag.outputs.tag == 'true')
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
env:
PLATFORMS: ${{ inputs.platforms-publish }}
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Login to GitHub Container Registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push
run: |
cd images/ && make REGISTRY=ghcr.io/kubernetes/ingress-nginx NAME=${{ inputs.name }} push
2 changes: 1 addition & 1 deletion go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,4 @@ golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
46 changes: 31 additions & 15 deletions images/kube-webhook-certgen/Makefile → images/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 The Kubernetes Authors. All rights reserved.
# Copyright 2024 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,17 +14,23 @@

.DEFAULT_GOAL:=build

# set default shell
SHELL=/bin/bash -o pipefail -o errexit

DIR:=$(strip $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))))
INIT_BUILDX=$(DIR)/../../hack/init-buildx.sh
INIT_BUILDX=$(DIR)/../hack/init-buildx.sh

SHORT_SHA ?=$(shell git rev-parse --short HEAD)
TAG ?=v$(shell date +%Y%m%d)-$(SHORT_SHA)

BASE_IMAGE = $(shell cat $(DIR)/../NGINX_BASE)

REGISTRY ?= local
NAME ?=

IMAGE = $(REGISTRY)/$(NAME)
TAG ?= $(shell cat $(NAME)/TAG)

EXTRAARGS ?= $(shell cat $(NAME)/EXTRAARGS)

IMAGE = $(REGISTRY)/kube-webhook-certgen

# required to enable buildx
export DOCKER_CLI_EXPERIMENTAL=enabled
Expand All @@ -34,17 +40,33 @@ PLATFORMS?=linux/amd64,linux/arm,linux/arm64,linux/s390x
OUTPUT=
PROGRESS=plain

build: ensure-buildx

precheck:
ifndef NAME
$(error NAME variable is required)
endif

build: precheck ensure-buildx
docker buildx build \
--label=org.opencontainers.image.source=https://github.com/kubernetes/ingress-nginx \
--label=org.opencontainers.image.licenses=Apache-2.0 \
--label=org.opencontainers.image.description="Ingress NGINX $(NAME) image" \
--build-arg BASE_IMAGE=$(BASE_IMAGE) \
--platform=${PLATFORMS} $(OUTPUT) \
--progress=$(PROGRESS) \
--pull \
-t $(IMAGE):$(TAG) rootfs
--pull $(EXTRAARGS) \
-t $(IMAGE):$(TAG) $(NAME)/rootfs

# push the cross built image
push: OUTPUT=--push
push: build

test: precheck
cd $(NAME)/rootfs && go test ./...

test-e2e: precheck
cd $(NAME) && ./hack/e2e.sh

# enable buildx
ensure-buildx:
# this is required for cloudbuild
Expand All @@ -55,10 +77,4 @@ else
endif
@echo "done"

test:
cd rootfs && go test ./...

test-e2e:
./hack/e2e.sh

.PHONY: build push ensure-buildx test test-e2e
.PHONY: build push ensure-buildx test test-e2e precheck
57 changes: 0 additions & 57 deletions images/cfssl/Makefile

This file was deleted.

1 change: 1 addition & 0 deletions images/cfssl/TAG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.0.1
2 changes: 1 addition & 1 deletion images/cfssl/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ steps:
- -c
- |
gcloud auth configure-docker \
&& cd images/cfssl && make push
&& cd images && make NAME=cfssl push
1 change: 0 additions & 1 deletion images/cfssl/rootfs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

FROM alpine:3.19.0
# BLA

RUN echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN apk update \
Expand Down
59 changes: 0 additions & 59 deletions images/custom-error-pages/Makefile

This file was deleted.

1 change: 1 addition & 0 deletions images/custom-error-pages/TAG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.0.1
2 changes: 1 addition & 1 deletion images/custom-error-pages/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ steps:
- -c
- |
gcloud auth configure-docker \
&& cd images/custom-error-pages && make push
&& cd images/ && make NAME=custom-error-pages push
1 change: 1 addition & 0 deletions images/e2e-test-echo/EXTRAARGS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--build-arg LUAROCKS_VERSION=3.8.0 --build-arg LUAROCKS_SHA=ab6612ca9ab87c6984871d2712d05525775e8b50172701a0a1cabddf76de2be7
1 change: 1 addition & 0 deletions images/e2e-test-echo/TAG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.0.1
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 388fc74

Please sign in to comment.