From 72ec551e6cb422531e543e3fb431324aed5ac025 Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Sun, 13 Aug 2023 18:40:49 +0200 Subject: feat: Add better tooling for running the project * Add watch option for hot reload(ish). * Read from `.env` file. This make local development a bit easier since now can easily run the application with custom configuration. --- Makefile | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index c1deac1..743c0fd 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,19 @@ GO_TEST=go test -v -timeout 100ms -shuffle on -parallel `nproc` GO_BUILD=go build -v -ldflags '-w -s' GO_RUN=go run -v +# Development setup +DB_TYPE?=sqlite +DB_CON?=main.db +LOG_LEVEL?=error +SCHEDULER_COUNT?=`nproc` +CACHE_PATH?=$(HOME)/cache +AES_KEY?=`openssl rand -rand /dev/urandom 32 | base64` + +ifneq (,$(wildcard ./.env)) + include .env + export +endif + all: build build: sass tmpl @@ -19,9 +32,12 @@ compress_into_oblivion: build run: sass $(GO_RUN) $(SERVER) \ - --log-level error \ - --aes-key=6368616e676520746869732070617373 \ - --cache-path=${HOME}/.thumb + --db-type=$(DB_TYPE) \ + --db-con="$(DB_CON)" \ + --log-level=$(LOG_LEVEL) \ + --scheduler-count=$(SCHEDULER_COUNT) \ + --cache-path="$(CACHE_PATH)" \ + --aes-key="$(AES_KEY)" sass: @mkdir -p static @@ -75,3 +91,7 @@ gci: alignment: betteralign -apply ./... + +watch: + find . \( ! -name "*.qtpl.go" -a \( -name "*.go" -o -name "*.qtpl" -o -name "main.scss" \) \) | \ + entr -sr 'make run' -- cgit v1.2.3