added docker setup
This commit is contained in:
106
Makefile
106
Makefile
@@ -1,10 +1,13 @@
|
||||
.PHONY: run build clean test deps install
|
||||
.PHONY: all run build clean test deps install docker-build docker-up docker-down docker-logs docker-restart docker-clean help
|
||||
|
||||
# Run the application
|
||||
# Default target: build and start with Docker
|
||||
all: docker-up
|
||||
|
||||
# Run the application locally
|
||||
run:
|
||||
go run main.go
|
||||
|
||||
# Build the binary
|
||||
# Build the binary locally
|
||||
build:
|
||||
go build -o mealprep main.go
|
||||
|
||||
@@ -33,14 +36,95 @@ test:
|
||||
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 " run - Run the application"
|
||||
@echo " build - Build the binary"
|
||||
@echo " deps - Install dependencies"
|
||||
@echo " clean - Remove binary and database"
|
||||
@echo " clean-db - Remove only database"
|
||||
@echo " test - Run tests"
|
||||
@echo " install - Install binary to GOPATH"
|
||||
@echo " help - Show this help message"
|
||||
@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"
|
||||
|
||||
Reference in New Issue
Block a user