Skip to content

Commit 9f088a8

Browse files
committed
fast make workflow and runtime dependency sync
1 parent 7e934aa commit 9f088a8

3 files changed

Lines changed: 45 additions & 16 deletions

File tree

Makefile

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help init fireform build up down logs logs-app logs-ollama shell pull-model test clean super-clean
1+
.PHONY: help init fireform build up down logs logs-app logs-ollama shell pull-model test clean super-clean status ready-banner sync
22

33
COMPOSE = docker compose -f docker/dev/compose.yml --env-file docker/.env.dev
44
ENV_DEV = docker/.env.dev
@@ -22,6 +22,8 @@ help:
2222
@echo "make build - Build Docker images"
2323
@echo "make up - Start all containers (detached)"
2424
@echo "make down - Stop all containers"
25+
@echo "make sync - Fast-install new requirements.txt deps into running app (no rebuild)"
26+
@echo "make status - Show compact container health summary"
2527
@echo "make logs - Stream all container logs"
2628
@echo "make logs-app - Stream app container logs"
2729
@echo "make logs-ollama - Stream Ollama container logs"
@@ -43,30 +45,38 @@ init:
4345
*) echo "Run 'make fireform' when ready." ;; \
4446
esac
4547

46-
fireform: build up
47-
@printf "Waiting for Ollama to be ready..."
48-
@until $(COMPOSE) exec -T ollama ollama list > /dev/null 2>&1; do \
49-
printf '.'; sleep 2; \
50-
done
51-
@echo " ready."
48+
fireform:
49+
@$(COMPOSE) up -d --build
5250
@if $(COMPOSE) exec -T ollama ollama list 2>/dev/null | grep -q "^$(OLLAMA_MODEL)"; then \
5351
echo " Model $(OLLAMA_MODEL) already pulled."; \
5452
else \
5553
echo " Pulling $(OLLAMA_MODEL)..."; \
5654
$(COMPOSE) exec -T ollama ollama pull $(OLLAMA_MODEL); \
5755
fi
58-
@echo ""
59-
@echo "FireForm is ready!"
60-
@echo " API: http://localhost:8000"
61-
@echo " API Docs: http://localhost:8000/docs"
62-
@echo ""
63-
@echo "Run 'make logs' to view live logs, 'make down' to stop."
56+
@$(MAKE) --no-print-directory ready-banner
6457

6558
build:
6659
@$(COMPOSE) build
6760

6861
up:
6962
@$(COMPOSE) up -d
63+
@$(MAKE) --no-print-directory ready-banner
64+
65+
# Fast path for "I added a package": install the delta into the running container
66+
# (no image rebuild, no 1.6GB layer re-export). uv installs only what's missing in
67+
sync:
68+
@$(COMPOSE) exec -T app sh -c "UV_TORCH_BACKEND=cpu uv pip install --system -r requirements.txt"
69+
70+
status:
71+
@$(COMPOSE) ps --format 'table {{.Service}}\t{{.Status}}'
72+
73+
ready-banner:
74+
@echo ""
75+
@echo "FireForm is ready!"
76+
@echo " API: http://localhost:8000"
77+
@echo " API Docs: http://localhost:8000/docs"
78+
@echo ""
79+
@echo "Run 'make logs' to view live logs, 'make down' to stop."
7080

7181
down:
7282
@$(COMPOSE) down --remove-orphans

docker/entrypoint.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
#!/bin/sh
22
set -e
33

4-
# Ensure data directories exist (volumes may be empty on first run)
54
mkdir -p /data/uploads
65

7-
# Run DB migrations / init before starting the server
6+
# Reinstall deps only when the live requirements.txt differs from what the image
7+
# was built with. The image bakes the hash at /opt/req_hash; in dev the live file
8+
# comes from the bind mount. Matching hash => deps already baked in => skip (instant).
9+
BAKED_HASH=$(cat /opt/req_hash 2>/dev/null || echo "none")
10+
LIVE_HASH=$(sha256sum requirements.txt 2>/dev/null | cut -d' ' -f1 || echo "unknown")
11+
12+
if [ "$BAKED_HASH" = "$LIVE_HASH" ]; then
13+
echo "[entrypoint] dependencies up to date — skipping install"
14+
else
15+
echo "[entrypoint] requirements.txt changed since image build — syncing deps..."
16+
if command -v uv > /dev/null 2>&1; then
17+
UV_TORCH_BACKEND=cpu uv pip install --system -r requirements.txt
18+
else
19+
pip install -r requirements.txt
20+
fi
21+
fi
22+
823
python3 -m app.db.init_db
924

1025
exec "$@"

scripts/setup-dockers-env.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#!/bin/bash
22

33
source venv/bin/activate
4-
pip install -r requirements.txt
4+
if command -v uv > /dev/null 2>&1; then
5+
uv pip install -r requirements.txt
6+
else
7+
pip install -r requirements.txt
8+
fi

0 commit comments

Comments
 (0)