Add target for deploy docker images to s3

This commit is contained in:
Alexey Golubev 2019-10-21 15:18:04 +03:00
parent d7833f454b
commit 03a96d3765

@ -12,22 +12,26 @@ REPO_URL := "deb [trusted=yes] http://repo-doc-onlyoffice-com.s3.amazonaws.com/u
UPDATE_LATEST := false UPDATE_LATEST := false
ifneq (,$(findstring develop,$(GIT_BRANCH))) ifneq (,$(findstring develop,$(GIT_BRANCH)))
DOCKER_TAGS += $(subst -,.,$(PACKAGE_VERSION)) DOCKER_TAG += $(subst -,.,$(PACKAGE_VERSION))
DOCKER_TAGS += latest DOCKER_TAGS += latest
else ifneq (,$(findstring release,$(GIT_BRANCH))) else ifneq (,$(findstring release,$(GIT_BRANCH)))
DOCKER_TAGS += $(subst -,.,$(PACKAGE_VERSION)) DOCKER_TAG += $(subst -,.,$(PACKAGE_VERSION))
else ifneq (,$(findstring hotfix,$(GIT_BRANCH))) else ifneq (,$(findstring hotfix,$(GIT_BRANCH)))
DOCKER_TAGS += $(subst -,.,$(PACKAGE_VERSION)) DOCKER_TAG += $(subst -,.,$(PACKAGE_VERSION))
else else
DOCKER_TAGS += $(subst -,.,$(PACKAGE_VERSION))-$(subst /,-,$(GIT_BRANCH)) DOCKER_TAG += $(subst -,.,$(PACKAGE_VERSION))-$(subst /,-,$(GIT_BRANCH))
endif endif
DOCKER_TAGS += $(DOCKER_TAG)
DOCKER_REPO = $(COMPANY_NAME)/4testing-$(PRODUCT_NAME) DOCKER_REPO = $(COMPANY_NAME)/4testing-$(PRODUCT_NAME)
COLON := __colon__ COLON := __colon__
DOCKER_TARGETS := $(foreach TAG,$(DOCKER_TAGS),$(DOCKER_REPO)$(COLON)$(TAG)) DOCKER_TARGETS := $(foreach TAG,$(DOCKER_TAGS),$(DOCKER_REPO)$(COLON)$(TAG))
.PHONY: all clean clean-docker deploy docker DOCKER_ARCH := $(COMPANY_NAME)-$(PRODUCT_NAME)_$(PACKAGE_VERSION).tar.gz
.PHONY: all clean clean-docker deploy docker publish
$(DOCKER_TARGETS): $(DEB_REPO_DATA) $(DOCKER_TARGETS): $(DEB_REPO_DATA)
@ -40,13 +44,23 @@ $(DOCKER_TARGETS): $(DEB_REPO_DATA)
mkdir -p $$(dirname $@) &&\ mkdir -p $$(dirname $@) &&\
echo "Done" > $@ echo "Done" > $@
$(DOCKER_ARCH): $(DOCKER_TARGETS)
docker save $(DOCKER_REPO):$(DOCKER_TAG) | \
gzip > $@
all: $(DOCKER_TARGETS) all: $(DOCKER_TARGETS)
clean: clean:
rm -rfv $(DOCKER_TARGETS) rm -rfv $(DOCKER_TARGETS) $(DOCKER_ARCH)
clean-docker: clean-docker:
docker rmi -f $$(docker images -q $(COMPANY_NAME)/*) || exit 0 docker rmi -f $$(docker images -q $(COMPANY_NAME)/*) || exit 0
deploy: $(DOCKER_TARGETS) deploy: $(DOCKER_TARGETS)
$(foreach TARGET,$(DOCKER_TARGETS),docker push $(subst $(COLON),:,$(TARGET));) $(foreach TARGET,$(DOCKER_TARGETS),docker push $(subst $(COLON),:,$(TARGET));)
publish: $(DOCKER_ARCH)
aws s3 cp \
$(DOCKER_ARCH) \
s3://repo-doc-onlyoffice-com.s3.amazonaws.com/docker/amd64/ \
--acl public-read