Skip to content

Commit

Permalink
chore: Improve Makefile for building and releasing the Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
ericof committed Jan 7, 2022
1 parent b5ce06c commit e79360e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ SHELL:=bash
.DELETE_ON_ERROR:
MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules
IMAGE_NAME=plone/blocks-conversion-tool:latest

define GetFromPkg
$(shell node -p "require('./package.json').$(1)")
endef

IMAGE_TAG:=$(call GetFromPkg,version)
IMAGE_NAME=plone/blocks-conversion-tool

# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
Expand Down Expand Up @@ -52,12 +58,17 @@ test-all: check-prettier check-lint test ## Check lint and test code

.PHONY: build-image
build-image: ## Build Docker Image
@docker build . -t $(IMAGE_NAME) -f Dockerfile
@echo "Building $(IMAGE_NAME):$(IMAGE_TAG)"
@docker build . -t $(IMAGE_NAME):$(IMAGE_TAG) -f Dockerfile

.PHONY: push-image
push-image: ## Publish Docker Image
@docker push $(IMAGE_NAME)
@echo "Pushing $(IMAGE_NAME):$(IMAGE_TAG)"
@docker push $(IMAGE_NAME):$(IMAGE_TAG)
@docker tag $(IMAGE_NAME):$(IMAGE_TAG) $(IMAGE_NAME):latest
@echo "Pushing $(IMAGE_NAME):latest"
@docker push $(IMAGE_NAME):latest

.PHONY: release-image
release-image: build-image push-image ## Build and push the image to docker hub
@echo "Releasing $(IMAGE_NAME)"
@echo "Released $(IMAGE_NAME)"

0 comments on commit e79360e

Please sign in to comment.