version: "3" env: COMPOSE_PROJECT_NAME: maplefile # Variables for Docker Compose command detection vars: DOCKER_COMPOSE_CMD: sh: | if command -v docker-compose >/dev/null 2>&1; then echo "docker-compose" elif docker compose version >/dev/null 2>&1; then echo "docker compose" else echo "docker-compose" fi tasks: # Development workflow (requires infrastructure) dev: desc: Start app in development mode (requires infrastructure running) deps: [dev:check-infra] cmds: - "{{.DOCKER_COMPOSE_CMD}} -f docker-compose.dev.yml up --build" - echo "Press Ctrl+C to stop" dev:down: desc: Stop development app cmds: - "{{.DOCKER_COMPOSE_CMD}} -f docker-compose.dev.yml down" dev:restart: desc: Quick restart (fast!) cmds: - "{{.DOCKER_COMPOSE_CMD}} -f docker-compose.dev.yml restart" - echo "✅ MapleFile backend restarted" dev:logs: desc: View app logs cmds: - "{{.DOCKER_COMPOSE_CMD}} -f docker-compose.dev.yml logs -f" dev:shell: desc: Open shell in running container cmds: - docker exec -it maplefile-backend-dev sh dev:check-infra: desc: Verify infrastructure is running silent: true cmds: - | if ! docker network inspect maple-dev >/dev/null 2>&1; then echo "❌ Infrastructure not running!" echo "" echo "Start it with:" echo " cd ../infrastructure/development && task dev:start" echo "" exit 1 fi if ! docker ps | grep -q maple-cassandra-1-dev; then echo "❌ Cassandra not running!" echo "" echo "Start it with:" echo " cd ../infrastructure/development && task dev:start" echo "" exit 1 fi echo "✅ Infrastructure is running" # Database operations migrate:up: desc: Run all migrations up cmds: - ./maplefile-backend migrate up migrate:down: desc: Run all migrations down cmds: - ./maplefile-backend migrate down migrate:create: desc: Create new migration (usage task migrate:create -- create_users) cmds: - ./maplefile-backend migrate create {{.CLI_ARGS}} db:clear: desc: Clear Cassandra database (drop and recreate keyspace) deps: [build] cmds: - echo "⚠️ Dropping keyspace 'maplefile'..." - docker exec maple-cassandra-1-dev cqlsh -e "DROP KEYSPACE IF EXISTS maplefile;" - echo "✅ Keyspace dropped" - echo "🔄 Running migrations to recreate schema..." - ./maplefile-backend migrate up - echo "✅ Database cleared and recreated" db:reset: desc: Reset database using migrations (down then up) deps: [build] cmds: - echo "🔄 Running migrations down..." - ./maplefile-backend migrate down - echo "🔄 Running migrations up..." - ./maplefile-backend migrate up - echo "✅ Database reset complete" # Build and test build: desc: Build the Go binary cmds: - go build -o maplefile-backend . test: desc: Run tests cmds: - go test ./... -v test:short: desc: Run short tests only cmds: - go test ./... -short lint: desc: Run linters cmds: - go vet ./... vulncheck: desc: Check for known vulnerabilities in dependencies cmds: - go run golang.org/x/vuln/cmd/govulncheck ./... nilaway: desc: Run nilaway static analysis for nil pointer dereferences cmds: - go run go.uber.org/nilaway/cmd/nilaway ./... format: desc: Format code cmds: - go fmt ./... tidy: desc: Tidy Go modules cmds: - go mod tidy wire: desc: Generate dependency injection code using Wire cmds: - wire ./app - echo "✅ Wire dependency injection code generated" clean: desc: Clean build artifacts cmds: - rm -f maplefile-backend deploy: desc: (DevOps only) Command will build the production container of this project and deploy to the private docker container registry. vars: GIT_COMMIT: sh: git rev-parse --short HEAD GIT_COMMIT_FULL: sh: git rev-parse HEAD BUILD_TIME: sh: date -u '+%Y-%m-%dT%H:%M:%SZ' cmds: - echo "Building version {{.GIT_COMMIT}} at {{.BUILD_TIME}}" - docker build -f Dockerfile --rm --build-arg GIT_COMMIT={{.GIT_COMMIT_FULL}} --build-arg BUILD_TIME={{.BUILD_TIME}} -t registry.digitalocean.com/ssp/maplefile-backend:prod -t registry.digitalocean.com/ssp/maplefile-backend:{{.GIT_COMMIT}} --platform linux/amd64 . - docker push registry.digitalocean.com/ssp/maplefile-backend:prod - docker push registry.digitalocean.com/ssp/maplefile-backend:{{.GIT_COMMIT}} - echo "Deployed version {{.GIT_COMMIT}} - use this to verify on production"