Skip to content

Commit

Permalink
Fixes make docker-images target and imporve the Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
plkokanov committed Dec 11, 2023
1 parent 76fd1b7 commit 553682a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ COPY . .
ARG EFFECTIVE_VERSION
ARG TARGETARCH

RUN make install EFFECTIVE_VERSION=$EFFECTIVE_VERSION GOARCH=$TARGETARCH
RUN make install EFFECTIVE_VERSION=$EFFECTIVE_VERSION

############# base
FROM gcr.io/distroless/static-debian11:nonroot AS base
Expand Down
19 changes: 9 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
#
# SPDX-License-Identifier: Apache-2.0

EXTENSION_PREFIX := gardener-extension
NAME_ADMISSION := shoot-rsyslog-relp-admission
NAME := shoot-rsyslog-relp
REGISTRY := eu.gcr.io/gardener-project/gardener
IMAGE_PREFIX := $(REGISTRY)/extensions
NAME_ADMISSION := $(NAME)-admission
IMAGE := eu.gcr.io/gardener-project/gardener/extensions/shoot-rsyslog-relp
REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
HACK_DIR := $(REPO_ROOT)/hack
VERSION := $(shell cat "$(REPO_ROOT)/VERSION")
EFFECTIVE_VERSION := $(VERSION)-$(shell git rev-parse HEAD)
GOARCH ?= $(shell go env GOARCH)
IMAGE_TAG := $(EFFECTIVE_VERSION)
LD_FLAGS := "-w $(shell EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) $(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/get-build-ld-flags.sh k8s.io/component-base $(REPO_ROOT)/VERSION $(NAME))"
PARALLEL_E2E_TESTS := 2

ifndef ARTIFACTS
Expand All @@ -35,17 +34,17 @@ include $(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/tools.mk

.PHONY: install
install:
@LD_FLAGS="-w $(shell EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) $(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/get-build-ld-flags.sh k8s.io/component-base $(REPO_ROOT)/VERSION $(EXTENSION_PREFIX)-$(NAME))" \
$(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/install.sh ./...
@LD_FLAGS=$(LD_FLAGS) \
$(REPO_ROOT)/vendor/github.com/gardener/gardener/hack/install.sh ./cmd/...

.PHONY: docker-login
docker-login:
@gcloud auth activate-service-account --key-file .kube-secrets/gcr/gcr-readwrite.json

.PHONY: docker-images
docker-images:
@docker build --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) --build-arg TARGETARCH=$(GOARCH) -t $(IMAGE_PREFIX)/$(NAME):$(EFFECTIVE_VERSION) -t $(IMAGE_PREFIX)/$(NAME):latest -f Dockerfile -m 6g --target $(EXTENSION_PREFIX)-$(NAME) .
@docker build --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) --build-arg TARGETARCH=$(GOARCH) -t $(IMAGE_PREFIX)/$(NAME_ADMISSION):$(EFFECTIVE_VERSION) -t $(IMAGE_PREFIX)/$(NAME_ADMISSION):latest -f Dockerfile -m 6g --target $(EXTENSION_PREFIX)-$(NAME_ADMISSION) .
@docker build --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) -t $(IMAGE):$(IMAGE_TAG) -f Dockerfile -m 6g --target $(NAME) .
@docker build --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) -t $(IMAGE)-admission:$(IMAGE_TAG) -f Dockerfile -m 6g --target $(NAME_ADMISSION) .

#####################################################################
# Rules for verification, formatting, linting, testing and cleaning #
Expand Down Expand Up @@ -123,7 +122,7 @@ ci-e2e-kind: $(KIND) $(YQ)
extension-up extension-down: export SKAFFOLD_LABEL = skaffold.dev/run-id=extension-local

extension-up: $(SKAFFOLD) $(HELM) $(KUBECTL)
$(SKAFFOLD) run
@LD_FLAGS=$(LD_FLAGS) $(SKAFFOLD) run

extension-dev: $(SKAFFOLD) $(HELM) $(KUBECTL)
$(SKAFFOLD) dev --cleanup=false --trigger=manual
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
kind: Secret
metadata:
name: rsyslog-relp-tls
namepace: {{ .Release.Namespace }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: rsyslog-relp-echo-server
app.kubernetes.io/instance: {{ .Release.Name }}
Expand Down
4 changes: 4 additions & 0 deletions skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ build:
- pkg/utils
- vendor
- VERSION
ldflags:
- '{{.LD_FLAGS}}'
main: ./cmd/gardener-extension-shoot-rsyslog-relp
resourceSelector:
allow:
Expand Down Expand Up @@ -78,6 +80,8 @@ build:
- pkg/utils
- vendor
- VERSION
ldflags:
- '{{.LD_FLAGS}}'
main: ./cmd/gardener-extension-shoot-rsyslog-relp-admission
deploy:
helm:
Expand Down

0 comments on commit 553682a

Please sign in to comment.