refactor: adopt portigo infrastructure patterns

Add config package with build-tag-switched dev/prod environments,
structured logging via zerolog, Taskfile for dev workflow, golangci-lint
config, testutil package, and improved DB setup with proper SQLite
pragmas and cleanup. Rename sqlc output package from gen to repository.

Switch to allowlist .gitignore, Alpine+UPX+scratch Dockerfile, and
CI pipeline with test/lint gates before deploy.
This commit is contained in:
Ryan Hamamura
2026-03-02 11:48:47 -10:00
parent 6d4f3eb821
commit 2df20c2840
27 changed files with 694 additions and 143 deletions

63
Taskfile.yml Normal file
View File

@@ -0,0 +1,63 @@
version: "3"
tasks:
build:styles:
desc: Build TailwindCSS styles
cmds:
- go tool gotailwind -i assets/css/input.css -o assets/css/output.css --minify
sources:
- "assets/css/input.css"
- "**/*.go"
generates:
- "assets/css/output.css"
build:
desc: Production build to bin/c4
cmds:
- go build -o bin/c4 .
deps:
- build:styles
live:styles:
desc: Watch and rebuild TailwindCSS styles
cmds:
- go tool gotailwind -i assets/css/input.css -o assets/css/output.css -w
live:server:
desc: Run server with hot-reload via air
cmds:
- |
go tool air \
-build.cmd "go build -tags=dev -o tmp/bin/c4 ." \
-build.bin "tmp/bin/c4" \
-build.exclude_dir "data,bin,tmp,deploy" \
-build.include_ext "go" \
-misc.clean_on_exit "true"
live:
desc: Dev mode with hot-reload
deps:
- live:styles
- live:server
test:
desc: Run the test suite
cmds:
- go test ./...
lint:
desc: Run golangci-lint
cmds:
- golangci-lint run
run:
desc: Build and run the server
cmds:
- ./bin/c4
deps:
- build
default:
desc: Run the default task (live)
cmds:
- task: live