2023-12-23 11:27:37 +00:00
|
|
|
SHELL := bash
|
|
|
|
.ONESHELL:
|
|
|
|
.SHELLFLAGS := -eu -o pipefail -c
|
|
|
|
.DELETE_ON_ERROR:
|
|
|
|
MAKEFLAGS += --warn-undefined-variables
|
|
|
|
MAKEFLAGS += --no-builtin-rules
|
|
|
|
OS:=$(shell uname -s)
|
|
|
|
|
|
|
|
ifeq ($(origin .RECIPEPREFIX), undefined)
|
|
|
|
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
|
|
|
|
endif
|
|
|
|
.RECIPEPREFIX = >
|
|
|
|
|
2023-07-09 03:01:12 +00:00
|
|
|
IMAGE_NAME:=homepage
|
|
|
|
# REMOTE_REPO:=harbor.fizz.buzz/private
|
2023-12-23 11:27:37 +00:00
|
|
|
TARGET :=
|
2023-07-09 03:01:12 +00:00
|
|
|
|
2023-12-23 11:27:37 +00:00
|
|
|
.PHONY: help
|
|
|
|
help:
|
|
|
|
> @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -E 's/^([^:]*): *## */\1: /'
|
2023-07-09 03:01:12 +00:00
|
|
|
|
|
|
|
.PHONY: build
|
2023-12-23 11:27:37 +00:00
|
|
|
build: ## Build the docker image.
|
2024-10-20 21:28:12 +00:00
|
|
|
> docker build --ssh default --tag $(IMAGE_NAME) --target=$(TARGET) --file Dockerfile ../../
|
2023-07-09 03:01:12 +00:00
|
|
|
|
|
|
|
.PHONY: push
|
2023-12-23 11:27:37 +00:00
|
|
|
push: ## Push the docker image to a remote repository.
|
2023-07-09 03:01:12 +00:00
|
|
|
ifdef REMOTE_REPO
|
2023-12-23 11:27:37 +00:00
|
|
|
> docker tag $(IMAGE_NAME) $(REMOTE_REPO)/$(IMAGE_NAME)
|
|
|
|
> docker push $(REMOTE_REPO)/$(IMAGE_NAME)
|
2023-07-09 03:01:12 +00:00
|
|
|
else
|
2023-12-23 11:27:37 +00:00
|
|
|
> @echo "REMOTE_REPO not defined, not pushing to a remote repo."
|
2023-07-09 03:01:12 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2023-12-23 11:27:37 +00:00
|
|
|
> docker rmi $(IMAGE_NAME)
|
2023-07-09 03:01:12 +00:00
|
|
|
ifdef REMOTE_REPO
|
2023-12-23 11:27:37 +00:00
|
|
|
> docker rmi $(REMOTE_REPO)/$(IMAGE_NAME)
|
2023-07-09 03:01:12 +00:00
|
|
|
else
|
2023-12-23 11:27:37 +00:00
|
|
|
> @echo "REMOTE_REPO not defined, not removing from remote repo."
|
2023-07-09 03:01:12 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
.PHONY: run
|
2023-12-23 22:22:37 +00:00
|
|
|
run: build
|
2023-12-23 11:27:37 +00:00
|
|
|
run: ## Launch the docker image
|
|
|
|
> docker run --rm -i -t -p "8080:8080" $(IMAGE_NAME)
|
2023-07-09 03:01:12 +00:00
|
|
|
|
|
|
|
.PHONY: shell
|
2023-12-23 11:27:37 +00:00
|
|
|
shell: ## Launch an interactive shell inside the docker image.
|
|
|
|
shell: build
|
|
|
|
> docker run --rm -i -t -p "8080:8080" --entrypoint /bin/bash --mount type=tmpfs,destination=/tmp $(IMAGE_NAME)
|