Add code for local docker image build and testing
[mbt-docker.git] / Makefile
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..bbf6910
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,52 @@
+PROJECT_NAME?=sap-e-mobility
+NAME:=ci-build
+SUBMODULES_INIT?=false
+DOCKER_REGISTRY_USERNAME?=fraggle0
+DOCKER_REGISTRY_PASSWORD?=
+DOCKER_REGISTRY_NAME?=$(NAME)
+DOCKER_REGISTRY_TAG?=latest
+
+.PHONY: all
+
+default: all
+
+submodule-update:
+       git submodule update --init --recursive
+
+submodules-init=
+ifeq '$(SUBMODULES_INIT)' 'true'
+       submodules-init += submodule-update
+endif
+
+$(NAME): $(submodules-init)
+       docker-compose -p $(PROJECT_NAME) up -d
+
+$(NAME)-force: $(submodules-init)
+       docker-compose -p $(PROJECT_NAME) up -d --build --force-recreate
+
+all: $(NAME)
+
+clean-images:
+       -docker rmi $(PROJECT_NAME)-$(NAME)
+
+clean-containers:
+       -docker-compose -p $(PROJECT_NAME) down
+
+clean: clean-containers clean-images
+
+docker-tag-registry:
+       docker tag $(PROJECT_NAME)-$(NAME) $(DOCKER_REGISTRY_USERNAME)/$(DOCKER_REGISTRY_NAME):$(DOCKER_REGISTRY_TAG)
+
+docker-login-registry:
+       -docker login -u '$(DOCKER_REGISTRY_USERNAME)' -p '$(DOCKER_REGISTRY_PASSWORD)'
+
+docker-push-registry: $(NAME)-force docker-tag-registry
+       docker push $(DOCKER_REGISTRY_USERNAME)/$(DOCKER_REGISTRY_NAME):$(DOCKER_REGISTRY_TAG)
+
+dist-clean-images:
+       docker image prune -a -f
+
+dist-clean-volumes:
+       docker volume prune -f
+
+dist-clean: clean-containers dist-clean-volumes dist-clean-images