inquisitor/Makefile
2025-07-09 16:01:51 +02:00

81 lines
2.7 KiB
Makefile

NAME := inquisitor
COMPOSE_FILE := docker-compose.yml
NETWORK := inquisitor-network
IMAGES := ftp-server ftp-client $(NAME)
.PHONY: up down ps clean help logs attach
# Build images and run containers
up:
@echo "Building and starting $(NAME) project..."
docker-compose -f $(COMPOSE_FILE) up --build -d
@echo "Project started successfully!"
# Stop containers and remove images
down:
@echo "Stopping and removing containers..."
docker-compose -f $(COMPOSE_FILE) down
@echo "Removing images..."
@for image in $(IMAGES); do \
if docker images -q $$image > /dev/null 2>&1; then \
docker rmi $$image; \
fi; \
done
@echo "Containers stopped and images removed!"
# Show detailed information about containers, networks, and images
ps:
@echo "=== CONTAINERS ==="
docker ps -a --filter "name=$(NAME)" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}\t{{.Image}}"
@echo "\n=== NETWORKS ==="
docker network ls --filter "name=$(NETWORK)" --format "table {{.Name}}\t{{.Driver}}\t{{.Scope}}"
@if docker network ls --filter "name=$(NETWORK)" -q | grep -q .; then \
echo "\nNetwork details:"; \
docker network inspect $(NETWORK) --format "{{range .Containers}}{{.Name}}: {{.IPv4Address}}{{println}}{{end}}"; \
fi
@echo "\n=== IMAGES ==="
@for image in $(IMAGES); do \
if docker images -q $$image > /dev/null 2>&1; then \
docker images $$image --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.Size}}"; \
fi; \
done
# Clean up everything: containers, images, networks, volumes
clean:
@echo "Cleaning up $(NAME) project..."
@echo "Stopping and removing containers..."
docker-compose -f $(COMPOSE_FILE) down --remove-orphans
@echo "Removing images..."
@for image in $(IMAGES); do \
if docker images -q $$image > /dev/null 2>&1; then \
docker rmi $$image; \
fi; \
done
@echo "Removing network..."
@if docker network ls -q --filter "name=$(NETWORK)" | grep -q .; then \
docker network rm $(NETWORK); \
fi
@echo "Cleaning up dangling images..."
@docker image prune -f
@echo "Clean up completed!"
# Show help
help:
@echo "Available targets:"
@echo " up - Build images and start containers"
@echo " down - Stop containers and remove images"
@echo " ps - Show detailed information about containers, networks, and images"
@echo " clean - Remove all project resources (containers, images, networks, volumes)"
@echo " logs - Show logs from all containers (or specific container with CONTAINER=name)"
@echo " help - Show this help message"
# Show logs from containers
logs:
@if [ -z "$(CONTAINER)" ]; then \
echo "Showing logs from all containers..."; \
docker-compose -f $(COMPOSE_FILE) logs -f; \
else \
echo "Showing logs from $(CONTAINER) container..."; \
docker-compose -f $(COMPOSE_FILE) logs -f $(CONTAINER); \
fi