about summary refs log tree commit diff
path: root/users/fcuny/notes/Makefile
blob: 4644ac381083bf65e1d441c6c2644580a6317d62 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
DOCKER := DOCKER_BUILDKIT=1 docker
DOCKER_BUILD_ARGS :=
DOCKER_IMAGE := fcuny/notes.fcuny.net
DOCKER_IMAGE_REF := $(shell git rev-parse HEAD)
DOCKERFILE := Dockerfile
PROJECT_DIR := $(realpath $(CURDIR))

.PHONY: server deploy docker-build docker-run worktree-clean

server:
	@echo "Running hugo server ..."
	hugo server

worktree-clean:
	git diff --exit-code
	git diff --staged --exit-code

deploy: worktree-clean docker-build
	@echo "Deploying to fly ..."
	flyctl deploy
	@git tag -a --message $$(flyctl info -j |jq -r '.App | "notes.fcuny.net/v\(.Version)"') $$(flyctl info -j |jq -r '.App | "notes.fcuny.net/v\(.Version)"')
	@git push origin --all
	@git push origin --tags

docker-build:
	@echo "Building Docker image ..."
	$(DOCKER) build $(DOCKER_BUILD_ARGS) \
		--tag "${DOCKER_IMAGE}:${DOCKER_IMAGE_REF}" \
		--file "$(DOCKERFILE)" \
		"$(PROJECT_DIR)"

docker-run: docker-build
	@echo "Running Docker image ..."
	$(DOCKER) run -ti --rm -p 8080:8080 "${DOCKER_IMAGE}:${DOCKER_IMAGE_REF}"