- Dockerfile cross-compiles Go for the target platform (amd64/arm64 without emulation), uses templ pinned in go.mod, runs as uid 1000 on alpine and lets FRONTEND_IMAGE pin the frontend version - justfile: tools via go tool, `test` (unit) and `test-integration` (uses the active docker context), no hardcoded paths, no tailwind or frontend recipes - Removed app.yaml, init.sh, tailwind.config.js and the tracked .idea folder
66 lines
1.5 KiB
Makefile
66 lines
1.5 KiB
Makefile
set dotenv-load
|
|
|
|
# Build and run the unit tests
|
|
all: build test
|
|
|
|
# Generate templ components (version pinned in go.mod)
|
|
templ-build:
|
|
@echo "Building templ..."
|
|
@go tool templ generate
|
|
|
|
sqlc-generate:
|
|
@echo "Generating sqlc code..."
|
|
@sqlc generate
|
|
|
|
migrate-create name:
|
|
@migrate create -ext sql -dir internal/db/migrations -seq {{name}}
|
|
|
|
# Generate OpenAPI docs (version pinned in go.mod)
|
|
swag-generate:
|
|
@echo "Generating OpenAPI docs..."
|
|
@go tool swag init -g internal/server/routes.go -o cmd/docs --parseInternal
|
|
|
|
build: sqlc-generate templ-build swag-generate
|
|
@echo "Building..."
|
|
@go build -o main cmd/main.go
|
|
|
|
run: templ-build
|
|
@go run cmd/main.go
|
|
|
|
build-run: build
|
|
@./main
|
|
|
|
# Unit tests: no database or Docker needed
|
|
test:
|
|
@go test -race ./...
|
|
|
|
# Integration tests against PostgreSQL in Docker (testcontainers), using the active docker context.
|
|
# Pass a pattern to run a subset, e.g. `just test-integration TestSQLDumps`
|
|
test-integration pattern=".":
|
|
@DOCKER_HOST="${DOCKER_HOST:-$(docker context inspect --format '{{{{.Endpoints.docker.Host}}')}" \
|
|
go test -tags integration -race -timeout 15m -run '{{pattern}}' ./...
|
|
|
|
clean:
|
|
@echo "Cleaning..."
|
|
@rm -f main
|
|
|
|
docker-build:
|
|
@docker build -t music-server .
|
|
|
|
docker-run:
|
|
@docker compose up --build
|
|
|
|
docker-down:
|
|
@docker compose down
|
|
|
|
watch-templ:
|
|
@go tool templ generate --watch --proxy="http://localhost:8080" --cmd="go run ./cmd"
|
|
|
|
# Live reload
|
|
watch:
|
|
@if ! command -v air > /dev/null; then \
|
|
echo "air is not installed. Install it with: go install github.com/air-verse/air@latest"; \
|
|
exit 1; \
|
|
fi
|
|
@air
|