77 lines
2.2 KiB
Makefile

# Makefile for ImapNotification
ROOT_DIR := $(shell pwd)
include $(ROOT_DIR)/project.env
export
PORT ?= 8080
.PHONY: all build run stop shell help
all: build
build:
@sudo docker build \
-t $(NAME):local \
.
update:
@sudo docker run \
--rm \
-it \
--name $(NAME) \
-v "$(ROOT_DIR)/src:/usr/src/app" \
$(NAME):local \
npm update
.
run:
@sudo docker run \
--rm \
-it \
--name $(NAME) \
--env-file $(ROOT_DIR)/.env \
-v "$(ROOT_DIR)/src:/usr/src/app" \
$(NAME):local
stop:
@sudo docker stop $(NAME)
shell:
docker run --rm -it \
--name $(CONTAINER)-shell \
-v "$(shell pwd):$(WORKDIR)" \
-w $(WORKDIR) \
$(IMAGE) /bin/sh
help:
@printf "Usage:\n make build Build local docker image ($(IMAGE))\n make run Run image mounting project into $(WORKDIR) (port $(PORT))\n make stop Stop running container\n make shell Start a shell in a container with project mounted\n\nOverride variables: IMAGE, CONTAINER, WORKDIR, PORT, DOCKER_BUILD_ARGS, DOCKER_RUN_ARGS\n"
git_info:
$(eval GIT_HASH = $(shell git rev-parse HEAD))
$(eval GIT_BRANCH = $(shell git rev-parse --abbrev-ref HEAD))
publish: git_info
$(eval VERSION = $(shell git describe --tags 2>/dev/null | grep -e '^[0-9]\.[0-9]*\.[0-9]'))
@if [ -z "${VERSION}" ]; \
then \
echo "Error: Nincs verzió szám"; \
exit 1; \
fi
#@sudo docker login $(DOCKER_REGISTRY)
@sudo docker build \
--no-cache \
--label version=$(VERSION) \
--label org.opencontainers.image.created=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label org.opencontainers.image.authors="Krisztián Szabolcsi" \
--label org.opencontainers.image.version=$(VERSION) \
--label org.opencontainers.image.licences=MIT \
--label org.opencontainers.image.source=https://${DOCKER_REGISTRY}/${OWNER}/${NAME} \
--label org.opencontainers.image.revision=$(GIT_HASH) \
--label org.opencontainers.image.vendor="Krisztián Szabolcsi" \
--label org.opencontainers.image.description="IMAP email notification service using ntfy.sh" \
--label org.opencontainers.image.source.branch=$(GIT_BRANCH) \
--label org.opencontainers.image.source.hash=$(GIT_HASH) \
-t $(DOCKER_REGISTRY)/${OWNER}/$(NAME):$(VERSION) \
.
@sudo docker push $(DOCKER_REGISTRY)/$(NAME):$(VERSION)