-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
131 lines (109 loc) · 3.78 KB
/
Copy pathMakefile
File metadata and controls
131 lines (109 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
.PHONY: help build run stop logs clean test docker-build docker-run docker-stop docker-logs docker-clean
# Variables
DOCKER_IMAGE := api-test-generator
DOCKER_TAG := latest
DOCKER_REGISTRY :=
DOCKER_COMPOSE_FILE := infrastructure/docker/docker-compose.yml
CONTAINER_NAME := api-test-generator
PORT := 8080
help:
@echo "API Test Generator - Makefile Commands"
@echo ""
@echo "Docker Commands:"
@echo " make docker-build Build Docker image"
@echo " make docker-run Run Docker container"
@echo " make docker-stop Stop Docker container"
@echo " make docker-logs View Docker logs"
@echo " make docker-clean Clean Docker resources"
@echo ""
@echo "Docker Compose Commands:"
@echo " make compose-up Start services with Docker Compose"
@echo " make compose-down Stop services with Docker Compose"
@echo " make compose-logs View Docker Compose logs"
@echo " make compose-build Build Docker Compose image"
@echo ""
@echo "Development Commands:"
@echo " make install Install dependencies"
@echo " make test Run tests"
@echo " make run Run Flask app locally"
@echo ""
@echo "Utility Commands:"
@echo " make health-check Check API health"
@echo " make clean Clean up local files"
@echo " make help Show this help message"
# Docker Commands
docker-build:
@echo "Building Docker image: $(DOCKER_IMAGE):$(DOCKER_TAG)"
docker build -f infrastructure/docker/Dockerfile \
-t $(DOCKER_IMAGE):$(DOCKER_TAG) .
@echo "✓ Docker image built successfully"
docker-run:
@echo "Running Docker container on port $(PORT)"
docker run -d -p $(PORT):8080 \
--name $(CONTAINER_NAME) \
$(DOCKER_IMAGE):$(DOCKER_TAG)
@echo "✓ Container started: http://localhost:$(PORT)"
docker-stop:
@echo "Stopping Docker container"
docker stop $(CONTAINER_NAME) || true
docker rm $(CONTAINER_NAME) || true
@echo "✓ Container stopped"
docker-logs:
@echo "Viewing Docker logs"
docker logs -f $(CONTAINER_NAME)
docker-clean:
@echo "Cleaning Docker resources"
docker stop $(CONTAINER_NAME) || true
docker rm $(CONTAINER_NAME) || true
docker rmi $(DOCKER_IMAGE):$(DOCKER_TAG) || true
@echo "✓ Docker resources cleaned"
# Docker Compose Commands
compose-up:
@echo "Starting services with Docker Compose"
docker-compose -f $(DOCKER_COMPOSE_FILE) up -d
@echo "✓ Services started"
compose-down:
@echo "Stopping services with Docker Compose"
docker-compose -f $(DOCKER_COMPOSE_FILE) down
@echo "✓ Services stopped"
compose-logs:
@echo "Viewing Docker Compose logs"
docker-compose -f $(DOCKER_COMPOSE_FILE) logs -f
compose-build:
@echo "Building Docker Compose image"
docker-compose -f $(DOCKER_COMPOSE_FILE) build --no-cache
@echo "✓ Image built"
# Development Commands
install:
@echo "Installing dependencies"
pip install -r requirements.txt
@echo "✓ Dependencies installed"
test:
@echo "Running tests"
pytest tests/ -v
@echo "✓ Tests completed"
run:
@echo "Running Flask app locally"
python src/main/app.py
# Utility Commands
health-check:
@echo "Checking API health"
curl -s http://localhost:$(PORT)/health | jq . || echo "API not responding"
clean:
@echo "Cleaning up local files"
find . -type d -name __pycache__ -exec rm -rf {} + || true
find . -type f -name "*.pyc" -delete || true
find . -type d -name ".pytest_cache" -exec rm -rf {} + || true
find . -type d -name ".coverage" -exec rm -rf {} + || true
@echo "✓ Cleanup completed"
# Combined Commands
build: docker-build
@echo "✓ Build completed"
run-docker: docker-stop docker-build docker-run
@echo "✓ Docker container is running on port $(PORT)"
stop: docker-stop
@echo "✓ Stopped"
logs: docker-logs
all: install test docker-build docker-run
@echo "✓ All tasks completed"
.DEFAULT_GOAL := help