Files
meal-prep-vibecoded/Makefile
2025-10-25 22:30:16 +02:00

131 lines
3.2 KiB
Makefile

.PHONY: all run build clean test deps install docker-build docker-up docker-down docker-logs docker-restart docker-clean help
# Default target: build and start with Docker
all: docker-up
# Run the application locally
run:
go run main.go
# Build the binary locally
build:
go build -o mealprep main.go
# Install dependencies
deps:
go mod tidy
go mod download
# Clean build artifacts and database
clean:
rm -f mealprep mealprep.db
# Clean only database (for fresh start)
clean-db:
rm -f mealprep.db
# Run with auto-reload (requires air: go install github.com/cosmtrek/air@latest)
dev:
air
# Test the application
test:
go test ./...
# Install the binary to GOPATH
install:
go install
# Docker: Build the Docker image
docker-build:
docker build -t mealprep:latest .
# Docker: Build and start containers
docker-up:
docker compose up -d
# Docker: Build and start with logs
docker-up-logs:
docker compose up --build
# Docker: Stop and remove containers
docker-down:
docker compose down
# Docker: View logs
docker-logs:
docker compose logs -f
# Docker: Restart containers
docker-restart:
docker compose restart
# Docker: Stop containers
docker-stop:
docker compose stop
# Docker: Start containers
docker-start:
docker compose start
# Docker: Clean everything (containers, volumes, images)
docker-clean:
docker compose down -v
docker rmi mealprep:latest 2>/dev/null || true
# Docker: Rebuild and restart
docker-rebuild:
docker compose down
docker compose build --no-cache
docker compose up -d
# Docker: Shell into container
docker-shell:
docker exec -it mealprep-app /bin/sh
# Docker: Show container status
docker-status:
docker compose ps
# Deploy: Build and deploy to production
deploy: docker-build
@echo "Building and deploying to Docker server..."
docker compose up -d --build
@echo "Deployment complete!"
# Show help
help:
@echo "Available targets:"
@echo ""
@echo "Default:"
@echo " make / all - Build and start with Docker (default)"
@echo ""
@echo "Local Development:"
@echo " run - Run the application locally"
@echo " build - Build the binary locally"
@echo " deps - Install dependencies"
@echo " clean - Remove binary and database"
@echo " clean-db - Remove only database"
@echo " dev - Run with auto-reload (requires air)"
@echo " test - Run tests"
@echo " install - Install binary to GOPATH"
@echo ""
@echo "Docker Commands:"
@echo " docker-build - Build the Docker image"
@echo " docker-up - Build and start containers in background"
@echo " docker-up-logs - Build and start with logs attached"
@echo " docker-down - Stop and remove containers"
@echo " docker-logs - View container logs"
@echo " docker-restart - Restart containers"
@echo " docker-stop - Stop containers"
@echo " docker-start - Start stopped containers"
@echo " docker-clean - Remove everything (containers, volumes, images)"
@echo " docker-rebuild - Rebuild from scratch and start"
@echo " docker-shell - Open shell in container"
@echo " docker-status - Show container status"
@echo ""
@echo "Deployment:"
@echo " deploy - Build and deploy to production"
@echo ""
@echo " help - Show this help message"