From a805fd7cddec4f9ce6b6cdfa7e30e0c6d839f3f3 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Wed, 25 Nov 2020 23:24:20 +0900
Subject: [PATCH] Fix build script and docker file for new controller
---
Dockerfile | 8 +++++++-
Makefile | 13 +++++++++++--
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 151940d..54f0a33 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -6,13 +6,19 @@ ENV CGO_ENABLED="0" \
WORKDIR /go/src/github.com/h3poteto/fluentd-sidecar-injector
+RUN set -ex && \
+ apk add --no-cache \
+ make \
+ git \
+ bash
+
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN set -ex && \
- go build -o fluentd-sidecar-injector
+ make build
FROM alpine:latest
COPY --from=builder /go/src/github.com/h3poteto/fluentd-sidecar-injector/fluentd-sidecar-injector /fluentd-sidecar-injector
diff --git a/Makefile b/Makefile
index 067135b..b7910a7 100644
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,10 @@ GOBIN=$(shell go env GOBIN)
endif
CRD_OPTIONS ?= "crd:trivialVersions=true"
+CODE_GENERATOR=${GOPATH}/src/k8s.io/code-generator
+
+build: codegen manifests
+ go build
run: codegen manifests
go run ./main.go controller sidecar-injector
@@ -25,14 +29,19 @@ clean:
rm ./*.crt
rm ./*.key
-codegen:
- ${GOPATH}/src/k8s.io/code-generator/generate-groups.sh "deepcopy,client,informer,lister" \
+codegen: code-generator
+ ${CODE_GENERATOR}/generate-groups.sh "deepcopy,client,informer,lister" \
github.com/h3poteto/fluentd-sidecar-injector/pkg/client github.com/h3poteto/fluentd-sidecar-injector/pkg/apis \
sidecarinjectorcontroller:v1alpha1
manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=sidecar-injector-manager-role paths=./... output:crd:artifacts:config=./config/crd/
+code-generator:
+ifeq (, $(wildcard ${CODE_GENERATOR}))
+ git clone https://github.com/kubernetes/code-generator.git ${CODE_GENERATOR}
+endif
+
controller-gen:
ifeq (, $(shell which controller-gen))
@{ \