|
| 1 | +# AngelaMos | 2026 |
| 2 | +# Justfile |
| 3 | + |
| 4 | +set dotenv-load := true |
| 5 | + |
| 6 | +# Default recipe |
| 7 | +default: |
| 8 | + @just --list |
| 9 | + |
| 10 | +# Development |
| 11 | +# ----------- |
| 12 | + |
| 13 | +# Run the API server with hot reload (requires air) |
| 14 | +dev: |
| 15 | + air -c .air.toml |
| 16 | + |
| 17 | +# Run the API server without hot reload |
| 18 | +run: |
| 19 | + go run ./cmd/api |
| 20 | + |
| 21 | +# Build the binary |
| 22 | +build: |
| 23 | + CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o bin/api ./cmd/api |
| 24 | + |
| 25 | +# Run tests |
| 26 | +test: |
| 27 | + go test -v -race -coverprofile=coverage.out ./... |
| 28 | + |
| 29 | +# Run tests with coverage report |
| 30 | +test-coverage: test |
| 31 | + go tool cover -html=coverage.out -o coverage.html |
| 32 | + |
| 33 | +# Run linter |
| 34 | +lint: |
| 35 | + golangci-lint run --timeout=5m |
| 36 | + |
| 37 | +# Format code |
| 38 | +fmt: |
| 39 | + gofumpt -w . |
| 40 | + goimports -w . |
| 41 | + |
| 42 | +# Tidy dependencies |
| 43 | +tidy: |
| 44 | + go mod tidy |
| 45 | + |
| 46 | +# Database |
| 47 | +# -------- |
| 48 | + |
| 49 | +# Run database migrations |
| 50 | +migrate-up: |
| 51 | + goose -dir migrations postgres "${DATABASE_URL}" up |
| 52 | + |
| 53 | +# Rollback last migration |
| 54 | +migrate-down: |
| 55 | + goose -dir migrations postgres "${DATABASE_URL}" down |
| 56 | + |
| 57 | +# Check migration status |
| 58 | +migrate-status: |
| 59 | + goose -dir migrations postgres "${DATABASE_URL}" status |
| 60 | + |
| 61 | +# Create new migration |
| 62 | +migrate-create name: |
| 63 | + goose -dir migrations create {{name}} sql |
| 64 | + |
| 65 | +# Docker |
| 66 | +# ------ |
| 67 | + |
| 68 | +# Start development containers |
| 69 | +up: |
| 70 | + docker compose -f dev.compose.yml up -d |
| 71 | + |
| 72 | +# Stop development containers |
| 73 | +down: |
| 74 | + docker compose -f dev.compose.yml down |
| 75 | + |
| 76 | +# View container logs |
| 77 | +logs: |
| 78 | + docker compose -f dev.compose.yml logs -f |
| 79 | + |
| 80 | +# Rebuild and restart containers |
| 81 | +rebuild: |
| 82 | + docker compose -f dev.compose.yml up -d --build |
| 83 | + |
| 84 | +# Build production image |
| 85 | +docker-build: |
| 86 | + docker build -t go-backend:latest . |
| 87 | + |
| 88 | +# Keys |
| 89 | +# ---- |
| 90 | + |
| 91 | +# Generate ES256 keypair for JWT signing |
| 92 | +generate-keys: |
| 93 | + #!/usr/bin/env bash |
| 94 | + set -euo pipefail |
| 95 | + mkdir -p keys |
| 96 | + openssl ecparam -genkey -name prime256v1 -noout -out keys/private.pem |
| 97 | + openssl ec -in keys/private.pem -pubout -out keys/public.pem |
| 98 | + chmod 600 keys/private.pem |
| 99 | + echo "ES256 keypair generated in keys/" |
| 100 | + |
| 101 | +# Clean |
| 102 | +# ----- |
| 103 | + |
| 104 | +# Remove build artifacts |
| 105 | +clean: |
| 106 | + rm -rf bin/ coverage.out coverage.html tmp/ |
| 107 | + |
| 108 | +# Full clean including containers |
| 109 | +clean-all: clean |
| 110 | + docker compose -f dev.compose.yml down -v |
0 commit comments