diff --git a/Makefile b/Makefile index a436cf461..c0eb69456 100644 --- a/Makefile +++ b/Makefile @@ -27,11 +27,11 @@ logs: ## Show logs of timetracker_ui. .PHONY: stop stop: ## Stop container timetracker_ui. - docker-compose stop + docker-compose stop .PHONY: restart restart: ## Restart container timetracker_ui. - docker-compose stop + docker-compose stop docker-compose up -d .PHONY: remove @@ -44,9 +44,9 @@ test: ## Run all tests on docker container timetracker_ui. docker exec -it timetracker_ui bash -c "npm run test" .PHONY: publish -publish: ## Publish the container image timetracker_ui. - docker tag timetracker_ui:latest $(registry_url)/timetracker_ui:latest - docker push $(registry_url)/timetracker_ui:latest +publish: require-acr-arg require-image_tag-arg ## Upload a docker image to the stage azure container registry acr= image_tag= + docker tag timetracker_ui:latest $(acr).azurecr.io/timetracker_ui:$(image_tag) + docker push $(acr).azurecr.io/timetracker_ui:$(image_tag) .PHONY: build_prod build_prod: ## Create docker image with dependencies needed for production. @@ -54,7 +54,7 @@ build_prod: ## Create docker image with dependencies needed for production. .PHONY: run_prod run_prod: ## Execute timetracker_ui_prod docker container. - docker run -d -p 4200:4200 --name timetracker_ui_prod timetracker_ui_prod + docker run -d -p 4200:4200 --name timetracker_ui_prod timetracker_ui_prod .PHONY: stop_prod stop_prod: ## Stop container timetracker_ui_prod. @@ -66,10 +66,27 @@ remove_prod: ## Delete container timetracker_ui_prod. docker rm timetracker_ui_prod .PHONY: publish_prod -publish_prod: ## Publish the container image timetracker_ui_prod. - docker tag timetracker_ui_prod:latest $(registry_url)/timetracker_ui_prod:latest - docker push $(registry_url)/timetracker_ui_prod:latest +publish_prod: require-acr-arg require-image_tag-arg ## Upload a docker image to the prod azure container registry acr= image_tag= + docker tag timetracker_ui_prod:latest $(acr).azurecr.io/timetracker_ui:$(image_tag) + docker push $(acr).azurecr.io/timetracker_ui:$(image_tag) .PHONY: login login: ## Login in respository of docker images. az acr login --name $(container_registry) + +.PHONY: release +release: require-VERSION-arg require-COMMENT-arg ## Creates an pushes a new tag. + git tag -a ${VERSION} -m "${COMMENT}" + git push origin ${VERSION} + +require-%-arg: + @if [ -z ${${*}} ]; then \ + echo "ERROR: [$*] argument is required, e.g. $*="; \ + exit 1; \ + fi + +require-%-tool: + @if [ "$(shell command -v ${*} 2> /dev/null)" = "" ]; then \ + echo "ERROR: [$*] not found"; \ + exit 1; \ + fi