aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-08-13 18:40:49 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-08-13 18:40:49 +0200
commit72ec551e6cb422531e543e3fb431324aed5ac025 (patch)
tree5919c6a20f64868ce7bad68c5094d4612accdb27 /Makefile
parent5f660b309bc695277c67223520499fcc13f3c59f (diff)
downloadlens-72ec551e6cb422531e543e3fb431324aed5ac025.tar.gz
lens-72ec551e6cb422531e543e3fb431324aed5ac025.tar.bz2
lens-72ec551e6cb422531e543e3fb431324aed5ac025.zip
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.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile26
1 files changed, 23 insertions, 3 deletions
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'