aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile45
1 files changed, 45 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..9eb6b2d
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,45 @@
+# Local development helpers. Requires Go and Docker.
+export DEV ?= 1
+export BASE_DOMAIN ?= blogspace.localhost
+export PUBLIC_PORT ?= 8080
+export ADDR ?= :8080
+export DATABASE_URL ?= postgres://blogspace:blogspace@localhost:5432/blogspace?sslmode=disable
+export TEST_DATABASE_URL ?= $(DATABASE_URL)
+
+.PHONY: dev run db-up db-down db-reset seed test build docker-build up down fmt
+
+dev: db-up run ## start postgres and run the app with live template reload
+
+run: ## run the app (assumes postgres is up)
+ go run ./cmd/blogspace serve
+
+db-up: ## start dev postgres and wait until it accepts connections
+ docker compose -f compose.dev.yml up -d --wait
+
+db-down:
+ docker compose -f compose.dev.yml down
+
+db-reset: ## drop all dev data and start fresh
+ docker compose -f compose.dev.yml down -v
+ $(MAKE) db-up
+
+seed: db-up ## insert demo superadmin (admin/admin) and blogger (alice/alicealice)
+ go run ./cmd/blogspace seed
+
+test:
+ go test ./...
+
+build:
+ CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o bin/blogspace ./cmd/blogspace
+
+fmt:
+ gofmt -w .
+
+docker-build:
+ docker build -t blogspace .
+
+up: ## production-style: app + db in docker (needs .env)
+ docker compose up --build -d
+
+down:
+ docker compose down