-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathjustfile
More file actions
executable file
·142 lines (111 loc) · 3.71 KB
/
justfile
File metadata and controls
executable file
·142 lines (111 loc) · 3.71 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
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env just --justfile
set shell := ["bash", "-c"]
# Default recipe lists available commands
default:
@just --list
# Backend recipes
backend-setup:
cd backend && (test -f .env && echo ".env cloned previously" || cp .env.example .env)
@echo "Please fill in your API keys in backend/.env"
backend-venv:
cd backend && uv venv
backend-activate:
@echo "Run: source backend/.venv/bin/activate"
backend-install:
cd backend && \
uv venv && \
. .venv/bin/activate && \
uv pip install -r requirements.txt && \
python -c 'import groq'
backend-dev:
cd backend && \
test -f .env && source .env \
&& . .venv/bin/activate \
&& python fastapi_app.py
# Frontend recipes
frontend-install:
cd frontend && bun install
frontend-clean:
cd frontend && rm -rf node_modules
frontend-build-dev:
cd frontend && \
bun run build:dev
frontend-dev:
cd frontend && \
PORT=30000 bun start ./build-dev
frontend-build-staging:
cd frontend && \
bun install --no-optional --omit=optional && \
bun run build:staging
test -f ./frontend/build-staging/index.html
frontend-build-prod:
cd frontend && \
bun install --no-optional --omit=optional && \
bun run build:prod
test -f ./frontend/build-prod/index.html
frontend-build-cloudflare namespace:
mkdir -p ./deployment/cloudflare/dist
cd frontend && \
bun install --no-optional --omit=optional && \
bun run build:cloudflare-{{ namespace }}
test -f ./deployment/cloudflare/dist/frontend-{{ namespace }}/index.html
frontend-build-cloudflare-local:
just frontend-build-cloudflare local
frontend-build-cloudflare-prod:
just frontend-build-cloudflare prod
# Combined recipes
setup: backend-setup frontend-install
@echo "Setup complete! Don't forget to fill in backend/.env"
dev:
@echo "Starting backend and frontend in dev mode..."
@echo "Run these in separate terminals:"
@echo "1. just backend-dev"
@echo "2. just frontend-dev"
# Utility recipes
clean:
cd backend && find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
cd frontend && rm -rf node_modules build
lint-backend:
cd backend && uvx ruff check --fix .
format-backend:
cd backend && uvx ruff format .
# Docker packaging
build-image-staging extra_flags="":
test -d ./frontend/build-staging
docker build -t perplexed-staging \
--build-arg FRONTEND_BUILD_DIR=./frontend/build-staging \
--progress plain {{extra_flags}} .
build-image-prod extra_flags="":
docker build -t perplexed \
--build-arg FRONTEND_BUILD_DIR=./frontend/build-prod \
--progress plain {{extra_flags}} .
rebuild-image:
docker build -t perplexed --no-cache --progress plain .
run cmd="":
@if [ ! -d ./frontend/build-staging ]; then \
just frontend-build-staging; \
fi
@if ! docker image inspect perplexed-staging; then \
just build-image-staging; \
fi
@if [ ! -f ./backend/.env ]; then \
cp ./backend/.env.example ./backend/.env; \
echo "Required: must first fill out the secrets in ./backend/.env" >&2; \
cat ./backend/.env >&2; \
exit 1; \
fi
docker run \
--env-file <(sed s/'export '//g ./backend/.env | sed 's/"//g' | grep -v '^#') \
--env DOMAINS_ALLOW="http://localhost:30000" \
-p 30000:30000 \
-it perplexed-staging \
{{cmd}}
backend-log:
docker exec $(docker ps --filter "ancestor=perplexed" --format '{{{{.ID}}') \
tail -f /var/log/app/backend.log
live-sh:
docker exec -it $(docker ps --filter "ancestor=perplexed" --format '{{{{.ID}}') \
/bin/bash
sh:
# same as "run" but drop into shell for interactive debug
just run /bin/bash