-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
134 lines (110 loc) · 3.51 KB
/
justfile
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
# ---
# --- INITIAL SETUP
# ---
# build step tailwindcss
tw :
npx tailwindcss -i ./src/static/css/input.css -o ./src/static/css/output.css --watch
# update requirements.txt in /src
req:
poetry export -f requirements.txt \
--without-hashes \
--output src/requirements.txt
# prep commit
ante:
pre-commit run --all-files
pytest
# quickstart post clone
start:
if [ -x "$(command -v op)" ]; then just dumpenv; else cp ./etc/env.example.0.dev-op .env; fi
@echo "\nInitialized .env file"
@read -p "Setup .venv with poetry?"
@if ! command -v poetry &> /dev/null; then echo -e "\nPoetry is not installed. You'll need to adjust pyproject.toml to work with your setup."; exit 1; fi
@poetry install
@poetry shell
@read -p "Install tailwind? Enter to continue"
@if ! command -v npm &> /dev/null; then echo -e "\nnpm is not installed. It's needed to install tailwindcss."; exit 1; fi
npm install -D tailwindcss \
@tailwindcss/typography \
@tailwindcss/forms \
@tailwindcss/aspect-ratio \
@tailwindcss/container-queries
npx tailwindcss -i ./src/static/css/input.css -o ./src/static/css/output.css
@read -p "Proceed with django setup? Enter to continue"
just req
just press
just db
pre-commit autoupdate
pytest
just run
# undo quickstart post clone
start_undo:
just ante
@read -p "Restart entire setup? Enter to continue"
rm -rf node_modules ./src/staticfiles ./src/mediafiles ./src/static/CACHE ./src/requirements.txt
rm -fv package-lock.json package.json poetry.lock compose.yml
rm -rf .venv **/.env
# ---
# --- DJANGO MANAGEMENT
# ---
# collect staticfiles for django-compressor
press:
rm -rf ./src/static/CACHE
cd src && python manage.py collectstatic --noinput
cd src && python manage.py compress --force
# set db
db:
test -d src/data || mkdir src/data
cd src && python manage.py makemigrations
cd src && python manage.py migrate
# check common runtime status
status:
cd src && python manage.py rich
# run_huey: django extensions, may require dumpenv
work:
cd src && python manage.py run_huey
# shell_plus
sh:
cd src && python manage.py shell_plus
# runserver_plus: django extensions, may require dumpenv
run:
open http://127.0.0.1:8000/ && cd src && python manage.py runserver_plus
# ---
# --- DOCKER COMPOSE
# ---
# 1password: inject secrets from 1password to root env file
dumpenv:
op inject -i ./etc/env.example.0.dev-op -o .env
# 1password: debug containers with compose.profiled.yml's --profile(sq / pg):
debug_up target:
just req
op inject -i ./deploy/env.common.tpl -o ./deploy/.env.debug
cp ./deploy/compose.debug.yml compose.yml
docker-compose --profile {{target}} up --build
# 1password: up containers via folder (sq / pg) copied compose.yml:
up folder:
just req
op inject -i ./deploy/env.common.tpl -o ./deploy/{{folder}}/.env
cp ./deploy/{{folder}}/compose.yml compose.yml
docker-compose up --build
# ---
# --- FLY DEPLOY
# ---
# deploy via config
deploy deployable config:
just req
fly deploy \
--app {{deployable}} \
--config ./deploy/{{config}}/fly.toml \
--dockerfile ./deploy/{{config}}/Dockerfile
# 1password: use env.fly.tpl to stage fly app secrets
set_secrets deployable:
op inject -i ./deploy/env.fly.tpl -o ./deploy/.env.fly
fly secrets --app {{deployable}} import < ./deploy/.env.fly --stage
rm ./deploy/.env.fly
# 1password: deploy via config with secrets
fly deployable config:
just set_secrets {{deployable}}
just deploy {{deployable}} {{config}}
# serve docs
docs:
mkdocs serve --config-file ./etc/mkdocs.yml