about summary refs log tree commit diff
path: root/tools/govanity/Makefile
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2021-08-12 13:53:33 -0700
committerFranck Cuny <franck@fcuny.net>2021-08-12 15:46:24 -0700
commitaa80df2b26c7455007d3db96f01bfde66c6779df (patch)
tree00cc4724a8362d0edad8de1f13be408f1df17ba6 /tools/govanity/Makefile
parentconfig: replace homelab with tools (diff)
downloadworld-aa80df2b26c7455007d3db96f01bfde66c6779df.tar.gz
build: deploy to fly
Don't deploy to Google App anymore, but use fly.io instead.

Add steps to the Makefile to build a docker image, and to deploy the
application to fly.io.
Diffstat (limited to '')
-rw-r--r--tools/govanity/Makefile31
1 files changed, 25 insertions, 6 deletions
diff --git a/tools/govanity/Makefile b/tools/govanity/Makefile
index e9ffe64..a826abe 100644
--- a/tools/govanity/Makefile
+++ b/tools/govanity/Makefile
@@ -1,9 +1,28 @@
-.PHONY: deploy
+DOCKER := docker
+DOCKER_BUILD_ARGS :=
+DOCKER_IMAGE := fcuny/golang.fcuny.net
+DOCKER_IMAGE_REF := $(shell git rev-parse HEAD)
+DOCKERFILE := Dockerfile
+PROJECT_DIR := $(realpath $(CURDIR))
+
+.PHONY: deploy docker-build docker-run
+
+server:
+	@echo "Running server ..."
+	go run .
+
 deploy:
-	gcloud -q app deploy --project=fcuny-govanity
+	@echo "Deploying to fly ..."
+	flyctl deploy --build-arg IMAGE_REF=$(DOCKER_IMAGE_REF)
 
-.PHONY: console
-	gcloud -q app open-console --project=fcuny-govanity
+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)"
 
-.PHONY: all
-all: deploy
+docker-run: docker-build
+	@echo "Running Docker image ..."
+	$(DOCKER) run -ti --rm -p 8080:8080 $(DOCKER_IMAGE):$(DOCKER_IMAGE_REF)