Add cloudbuild configuration for fastcgi test image
This commit is contained in:
parent
a24ce45b89
commit
9107a042de
5 changed files with 70 additions and 26 deletions
|
@ -14,34 +14,44 @@
|
||||||
|
|
||||||
# Docker image for e2e testing.
|
# Docker image for e2e testing.
|
||||||
|
|
||||||
# Use the 0.0 tag for testing, it shouldn't clobber any release builds
|
# set default shell
|
||||||
TAG ?= 0.0
|
SHELL=/bin/bash -o pipefail -o errexit
|
||||||
|
|
||||||
HOSTARCH := $(shell uname -m | sed -e s/x86_64/amd64/ \
|
DIR:=$(strip $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))))
|
||||||
-e s/s390x/s390x/ \
|
INIT_BUILDX=$(DIR)/../../hack/init-buildx.sh
|
||||||
-e s/armv7l/arm/ \
|
|
||||||
-e s/aarch64.*/arm64/)
|
|
||||||
|
|
||||||
ifndef ARCH
|
TAG ?=v$(shell date +%m%d%Y)-$(shell git rev-parse --short HEAD)
|
||||||
ARCH := $(HOSTARCH)
|
REGISTRY ?= local
|
||||||
endif
|
|
||||||
ifeq ($(ARCH),)
|
|
||||||
$(error mandatory variable ARCH is empty)
|
|
||||||
endif
|
|
||||||
|
|
||||||
REGISTRY ?= ingress-controller
|
IMAGE = $(REGISTRY)/e2e-test-fastcgi-helloserver
|
||||||
|
|
||||||
IMAGE = $(REGISTRY)/fastcgi-helloserver
|
# required to enable buildx
|
||||||
|
export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||||
|
|
||||||
PKG=k8s.io/ingress-nginx/images/fastcgi-helloserver
|
# build with buildx
|
||||||
|
PLATFORMS?=linux/amd64
|
||||||
|
OUTPUT=
|
||||||
|
PROGRESS=plain
|
||||||
|
|
||||||
.PHONY: image
|
build: ensure-buildx
|
||||||
image: build
|
docker buildx build \
|
||||||
docker build \
|
--platform=${PLATFORMS} $(OUTPUT) \
|
||||||
|
--progress=$(PROGRESS) \
|
||||||
|
--pull \
|
||||||
-t $(IMAGE):$(TAG) rootfs
|
-t $(IMAGE):$(TAG) rootfs
|
||||||
|
|
||||||
.PHONY: build
|
# push the cross built image
|
||||||
build:
|
push: OUTPUT=--push
|
||||||
GOARCH=$(ARCH) CGO_ENABLED=0 go build -a -installsuffix cgo \
|
push: build
|
||||||
-ldflags "-s -w" \
|
|
||||||
-o rootfs/fastcgi-helloserver ${PKG}/...
|
# enable buildx
|
||||||
|
ensure-buildx:
|
||||||
|
# this is required for cloudbuild
|
||||||
|
ifeq ("$(wildcard $(INIT_BUILDX))","")
|
||||||
|
@curl -sSL https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/hack/init-buildx.sh | bash
|
||||||
|
else
|
||||||
|
@exec $(INIT_BUILDX)
|
||||||
|
endif
|
||||||
|
@echo "done"
|
||||||
|
|
||||||
|
.PHONY: build push ensure-buildx
|
||||||
|
|
22
images/fastcgi-helloserver/cloudbuild.yaml
Normal file
22
images/fastcgi-helloserver/cloudbuild.yaml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
timeout: 600s
|
||||||
|
options:
|
||||||
|
substitution_option: ALLOW_LOOSE
|
||||||
|
steps:
|
||||||
|
- name: gcr.io/k8s-testimages/gcb-docker-gcloud:v20200619-68869a4
|
||||||
|
entrypoint: bash
|
||||||
|
env:
|
||||||
|
- DOCKER_CLI_EXPERIMENTAL=enabled
|
||||||
|
- TAG=$_GIT_TAG
|
||||||
|
- BASE_REF=$_PULL_BASE_REF
|
||||||
|
- REGISTRY=gcr.io/k8s-staging-ingress-nginx
|
||||||
|
# default cloudbuild has HOME=/builder/home and docker buildx is in /root/.docker/cli-plugins/docker-buildx
|
||||||
|
# set the home to /root explicitly to if using docker buildx
|
||||||
|
- HOME=/root
|
||||||
|
args:
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
gcloud auth configure-docker \
|
||||||
|
&& make push
|
||||||
|
substitutions:
|
||||||
|
_GIT_TAG: "12345"
|
||||||
|
_PULL_BASE_REF: "master"
|
1
images/fastcgi-helloserver/rootfs/.gitignore
vendored
1
images/fastcgi-helloserver/rootfs/.gitignore
vendored
|
@ -1 +0,0 @@
|
||||||
fastcgi-helloserver
|
|
|
@ -12,8 +12,21 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
FROM scratch
|
FROM golang:1.14-alpine as builder
|
||||||
|
|
||||||
COPY . /
|
WORKDIR /go/src/k8s.io/ingress-nginx/images/fastcgi
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN CGO_ENABLED=0 go build -a -installsuffix cgo \
|
||||||
|
-ldflags "-s -w" \
|
||||||
|
-o fastcgi-helloserver main.go
|
||||||
|
|
||||||
|
# Use distroless as minimal base image to package the binary
|
||||||
|
# Refer to https://github.com/GoogleContainerTools/distroless for more details
|
||||||
|
FROM gcr.io/distroless/static:nonroot
|
||||||
|
|
||||||
|
COPY --from=builder /go/src/k8s.io/ingress-nginx/images/fastcgi/fastcgi-helloserver /
|
||||||
|
USER nonroot:nonroot
|
||||||
|
|
||||||
CMD ["/fastcgi-helloserver"]
|
CMD ["/fastcgi-helloserver"]
|
||||||
|
|
Loading…
Reference in a new issue