-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (66 loc) · 2.3 KB
/
Copy pathMakefile
File metadata and controls
84 lines (66 loc) · 2.3 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
.PHONY: build run stop health test clean docker-build docker-run dev deploy deploy-full deploy-no-es compose-up compose-down compose-full-up
APP_NAME=resume-rag-service
PORT=8080
FRONTEND_PORT=5000
ES_PORT=9200
build:
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
run:
python main.py
dev:
APP_MODE=dev python main.py
stop:
docker rm -f rag-es rag-backend rag-frontend 2>/dev/null || true
health:
@echo -n "Backend: "; curl -sf http://localhost:$(PORT)/health && echo " OK" || echo " FAILED"
@echo -n "Frontend: "; curl -sf -o /dev/null -w "%{http_code}" http://localhost:$(FRONTEND_PORT) && echo "" || echo " FAILED"
docker-build:
@if [ -n "${HTTP_PROXY}" ]; then \
echo ">>> 使用代理: ${HTTP_PROXY}"; \
fi
docker build \
--build-arg PIP_INDEX=${PIP_INDEX:-https://pypi.tuna.tsinghua.edu.cn/simple} \
--build-arg PIP_TRUSTED_HOST=${PIP_TRUSTED_HOST:-pypi.tuna.tsinghua.edu.cn} \
--build-arg HTTP_PROXY=${HTTP_PROXY:-} \
--build-arg HTTPS_PROXY=${HTTPS_PROXY:-} \
-t $(APP_NAME)-backend:latest -f docker/Dockerfile .
docker build -t $(APP_NAME)-frontend:latest -f docker/Dockerfile.frontend .
docker-run:
docker rm -f $(APP_NAME) 2>/dev/null || true
docker run -d \
--name $(APP_NAME) \
-p $(PORT):8080 \
--restart=unless-stopped \
$(APP_NAME)-backend:latest
@sleep 5
@make health
# ========== 部署 ==========
# 全栈部署(ES + 后端 + 前端)
deploy:
chmod +x bin/deploy.sh 2>/dev/null || true
bash bin/deploy.sh
# 跳过 ES 部署(已有 ES 时使用)
deploy-no-es:
SKIP_ES=true ES_HOST=$(ES_HOST) bash bin/deploy.sh
# 全栈部署 + 自定义端口
deploy-full:
BACKEND_PORT=$(PORT) FRONTEND_PORT=$(FRONTEND_PORT) ES_PORT=$(ES_PORT) bash bin/deploy.sh
# ========== Docker Compose ==========
# 仅后端 + 前端(连外部 ES)→ 已有 ES 时用这个
compose-up:
docker-compose up -d --build backend frontend
@sleep 10
@make health
# 全栈(ES + 后端 + 前端)→ 没有 ES 时用这个
compose-full-up:
docker-compose --profile full up -d --build
@sleep 20
@make health
compose-down:
docker-compose --profile full down -v
test:
python -m pytest tests/ -v
clean:
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete 2>/dev/null || true
rm -rf .pytest_cache 2>/dev/null || true