about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2021-08-05 11:42:21 -0700
committerFranck Cuny <franck@fcuny.net>2021-08-05 11:42:21 -0700
commitc31a760273b705c0d7c5ba17e6c89e17cc6c097c (patch)
tree86c8958218dfcfedeec51a3c1461a6eafc0446ff
parentbuild: add Dockerfile (diff)
downloadfcuny.net-c31a760273b705c0d7c5ba17e6c89e17cc6c097c.tar.gz
build: add a Makefile
Add a Makefile to take care of most common operations (build, deploy,
etc).
-rw-r--r--Makefile29
1 files changed, 29 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..0276958
--- /dev/null
+++ b/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)