From 96cf0f396e470011df2c8c102d37f925ee75b83a Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Thu, 5 Aug 2021 11:42:21 -0700 Subject: build: add a Makefile Add a Makefile to take care of most common operations (build, deploy, etc). --- users/fcuny/notes/Makefile | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 users/fcuny/notes/Makefile diff --git a/users/fcuny/notes/Makefile b/users/fcuny/notes/Makefile new file mode 100644 index 0000000..0276958 --- /dev/null +++ b/users/fcuny/notes/Makefile @@ -0,0 +1,29 @@ +DOCKER := DOCKER_BUILDKIT=1 docker +DOCKER_BUILD_ARGS := +DOCKER_IMAGE := fcuny/fcuny.net +DOCKER_IMAGE_REF := $(shell git rev-parse HEAD) +DOCKERFILE := Dockerfile +PROJECT_DIR := $(realpath $(CURDIR)) + +.PHONY: server deploy docker-build docker-run + +server: + @echo "Running hugo server ..." + hugo server + +deploy: + @echo "Deploying to fly ..." + flyctl deploy \ + --build-arg IMAGE_REF=$(DOCKER_IMAGE_REF) + +docker-build: + @echo "Building Docker image ..." + $(DOCKER) build $(DOCKER_BUILD_ARGS) \ + --tag "${DOCKER_IMAGE}:${DOCKER_IMAGE_REF}" \ + --build-arg IMAGE_REF=$(DOCKER_IMAGE_REF) \ + --file "$(DOCKERFILE)" \ + "$(PROJECT_DIR)" + +docker-run: docker-build + @echo "Running Docker image ..." + $(DOCKER) run -ti --rm -p 8080:8080 $(DOCKER_IMAGE) -- cgit 1.4.1