From b92d66c728a7c4e9aad8e2d904d7e762cb81982e Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Wed, 1 Mar 2017 10:03:21 +0100 Subject: [PATCH] Add target to create a release build of Docker image Release builds for Docker Hub are special snow flakes. A release build has to be tagged with a version number. We also want to start with the latest base image and refresh all layers to get security fixes. Signed-off-by: Christian Heimes --- Makefile | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 213520d..4870266 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,8 @@ SERVER_SOCKET = $(CURDIR)/server_socket DOCKER_CMD = docker DOCKER_IMAGE = latchset/custodia +DOCKER_RELEASE_ARGS = --no-cache=true --pull=true + CONTAINER_NAME = custodia_container CONTAINER_VOL = $(CURDIR)/vol CONTAINER_SOCKET = $(CONTAINER_VOL)/run/sock @@ -93,11 +95,13 @@ release: clean egg_info README run: egg_info $(PYTHON) -m custodia.server $(CONF) -.PHONY = dockerbuild dockerdemo dockerdemoinit dockershell +.PHONY: dockerbuild dockerdemo dockerdemoinit dockershell dockerreleasebuild dockerbuild: rm -f dist/custodia*.whl $(PYTHON) setup.py bdist_wheel - $(DOCKER_CMD) build -f contrib/docker/Dockerfile -t $(DOCKER_IMAGE) . + $(DOCKER_CMD) build $(DOCKER_BUILD_ARGS) \ + -f contrib/docker/Dockerfile \ + -t $(DOCKER_IMAGE) . dockerdemo: dockerbuild @mkdir -p -m755 $(CONTAINER_VOL)/lib $(CONTAINER_VOL)/log $(CONTAINER_VOL)/run @@ -124,6 +128,10 @@ dockerdemoinit: dockershell: $(DOCKER_CMD) exec -ti $(CONTAINER_NAME) /bin/bash -.PHONY=dockerpush -dockerpush: dockerbuild - docker push $(DOCKER_IMAGE) +dockerrelasebuild: + VERSION=$$($(PYTHON) -c \ + "import pkg_resources; print(pkg_resources.get_distribution('custodia').version)") && \ + $(MAKE) dockerbuild \ + DOCKER_BUILD_ARGS="$(DOCKER_RELEASE_ARGS)" \ + DOCKER_IMAGE="$(DOCKER_IMAGE):$${VERSION}" && \ + echo -e "\n\nRun: $(DOCKER_CMD) push $(DOCKER_IMAGE):$${VERSION}"