Skip to content

Commit 9703ef4

Browse files
committed
Add make task docker-multi-arch-push-manifest
To update references of a multi-arch image on docker registry.
1 parent 532d64c commit 9703ef4

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ endif
1616
BINDATA := modules/{options,public,templates}/bindata.go
1717
STYLESHEETS := $(wildcard public/less/index.less public/less/_*.less)
1818
JAVASCRIPTS :=
19-
DOCKER_TAG := gitea/gitea:latest
19+
DOCKER_IMAGE ?= gitea/gitea
20+
DOCKER_TAG ?= latest
21+
DOCKER_REF := $(DOCKER_IMAGE):$(DOCKER_TAG)
2022
GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*" -not -path "*/bindata.go")
2123
GOFMT ?= gofmt -s
2224

@@ -193,8 +195,18 @@ $(EXECUTABLE): $(SOURCES)
193195
.PHONY: docker
194196
docker:
195197
docker run -ti --rm -v $(CURDIR):/srv/app/src/code.gitea.io/gitea -w /srv/app/src/code.gitea.io/gitea -e TAGS="bindata $(TAGS)" webhippie/golang:edge make clean generate build
196-
docker build -t $(DOCKER_TAG) .
198+
docker build -t $(DOCKER_REF) .
197199

200+
.PHONY: docker-multi-arch-push-manifest
201+
docker-multi-arch-push-manifest: DOCKER_MANIFEST ?= docker/manifest/base.yml #Manifest to update
202+
docker-multi-arch-push-manifest:
203+
@hash manifest-tool > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
204+
go get -u github.com/estesp/manifest-tool; \
205+
fi
206+
sed -i "s;gitea/gitea;$(DOCKER_IMAGE);g" $(DOCKER_MANIFEST) #Replace if using custom image name
207+
@manifest-tool --docker-cfg $HOME/.docker/ push from-spec $(DOCKER_MANIFEST) #Up new references
208+
sed -i "s;$(DOCKER_IMAGE);gitea/gitea;g" $(DOCKER_MANIFEST) #Revert back config
209+
198210
.PHONY: release
199211
release: release-dirs release-windows release-linux release-darwin release-copy release-check
200212

0 commit comments

Comments
 (0)