Makefile: handle a private registry
This commit is contained in:
parent
166094b5ad
commit
6301503095
@ -1,5 +1,5 @@
|
||||
ARG FROM=alpine
|
||||
FROM alpine AS cni
|
||||
FROM $FROM AS cni
|
||||
ARG GOARCH=amd64
|
||||
ARG CNI_PLUGINS_VERSION=v0.9.1
|
||||
RUN apk add --no-cache curl && \
|
||||
|
22
Makefile
22
Makefile
@ -17,6 +17,10 @@ PROJECT := kilo
|
||||
PKG := github.com/squat/$(PROJECT)
|
||||
REGISTRY ?= index.docker.io
|
||||
IMAGE ?= squat/$(PROJECT)
|
||||
ifneq ($(REGISTRY),index.docker.io)
|
||||
REGISTRY_PREFIX := $(REGISTRY)/
|
||||
endif
|
||||
FULLY_QUALIFIED_IMAGE := $(REGISTRY_PREFIX)$(IMAGE)
|
||||
|
||||
TAG := $(shell git describe --abbrev=0 --tags HEAD 2>/dev/null)
|
||||
COMMIT := $(shell git rev-parse HEAD)
|
||||
@ -243,7 +247,7 @@ container: .container-$(ARCH)-$(VERSION) container-name
|
||||
@docker images -q $(IMAGE):$(ARCH)-$(VERSION) > $@
|
||||
|
||||
container-latest: .container-$(ARCH)-$(VERSION)
|
||||
@docker tag $(IMAGE):$(ARCH)-$(VERSION) $(IMAGE):$(ARCH)-latest
|
||||
@docker tag $(IMAGE):$(ARCH)-$(VERSION) $(REGISTRY_PREFIX)$(IMAGE):$(ARCH)-latest
|
||||
@echo "container: $(IMAGE):$(ARCH)-latest"
|
||||
|
||||
container-name:
|
||||
@ -251,14 +255,15 @@ container-name:
|
||||
|
||||
manifest: .manifest-$(VERSION) manifest-name
|
||||
.manifest-$(VERSION): Dockerfile $(addprefix push-, $(ALL_ARCH))
|
||||
@docker manifest create --amend $(IMAGE):$(VERSION) $(addsuffix -$(VERSION), $(addprefix squat/$(PROJECT):, $(ALL_ARCH)))
|
||||
@docker manifest create --amend $(FULLY_QUALIFIED_IMAGE):$(VERSION) $(addsuffix -$(VERSION), $(addprefix $(FULLY_QUALIFIED_IMAGE):, $(ALL_ARCH)))
|
||||
@$(MAKE) --no-print-directory manifest-annotate-$(VERSION)
|
||||
@docker manifest push $(IMAGE):$(VERSION) > $@
|
||||
@docker manifest push $(FULLY_QUALIFIED_IMAGE):$(VERSION) > $@
|
||||
|
||||
manifest-latest: Dockerfile $(addprefix push-latest-, $(ALL_ARCH))
|
||||
@docker manifest create --amend $(IMAGE):latest $(addsuffix -latest, $(addprefix squat/$(PROJECT):, $(ALL_ARCH)))
|
||||
@docker manifest rm $(FULLY_QUALIFIED_IMAGE):latest || echo no old manifest
|
||||
@docker manifest create --amend $(FULLY_QUALIFIED_IMAGE):latest $(addsuffix -latest, $(addprefix $(FULLY_QUALIFIED_IMAGE):, $(ALL_ARCH)))
|
||||
@$(MAKE) --no-print-directory manifest-annotate-latest
|
||||
@docker manifest push $(IMAGE):latest
|
||||
@docker manifest push $(FULLY_QUALIFIED_IMAGE):latest
|
||||
@echo "manifest: $(IMAGE):latest"
|
||||
|
||||
manifest-annotate: manifest-annotate-$(VERSION)
|
||||
@ -269,7 +274,7 @@ manifest-annotate-%:
|
||||
annotate=; \
|
||||
j=0; for da in $(DOCKER_ARCH); do \
|
||||
if [ "$$j" -eq "$$i" ] && [ -n "$$da" ]; then \
|
||||
annotate="docker manifest annotate $(IMAGE):$* $(IMAGE):$$a-$* --os linux --arch"; \
|
||||
annotate="docker manifest annotate $(FULLY_QUALIFIED_IMAGE):$* $(FULLY_QUALIFIED_IMAGE):$$a-$* --os linux --arch"; \
|
||||
k=0; for ea in $$da; do \
|
||||
[ "$$k" = 0 ] && annotate="$$annotate $$ea"; \
|
||||
[ "$$k" != 0 ] && annotate="$$annotate --variant $$ea"; \
|
||||
@ -283,10 +288,13 @@ manifest-annotate-%:
|
||||
done
|
||||
|
||||
manifest-name:
|
||||
@echo "manifest: $(IMAGE_ROOT):$(VERSION)"
|
||||
@echo "manifest: $(IMAGE):$(VERSION)"
|
||||
|
||||
push: .push-$(ARCH)-$(VERSION) push-name
|
||||
.push-$(ARCH)-$(VERSION): .container-$(ARCH)-$(VERSION)
|
||||
ifneq ($(REGISTRY_PREFIX),)
|
||||
@docker tag $(IMAGE):$(ARCH)-$(VERSION) $(REGISTRY)/$(IMAGE):$(ARCH)-$(VERSION)
|
||||
endif
|
||||
@docker push $(REGISTRY)/$(IMAGE):$(ARCH)-$(VERSION)
|
||||
@docker images -q $(IMAGE):$(ARCH)-$(VERSION) > $@
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user