Repository navigation
Expand file tree
/
Copy pathdev.compose.yaml
More file actions
116 lines (110 loc) · 3.7 KB
/
Copy pathdev.compose.yaml
File metadata and controls
116 lines (110 loc) · 3.7 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
# Local development: the production setup from compose.yaml, but built from the local source (instead of
# the published image), with code reload and a stylesheet rebuild.
#
# docker compose -f dev.compose.yaml watch
#
# Needs APP_SECRET_KEY in .env (any value will do here), see .env.example.
# It runs as its own project (own volumes, own container names), so it does not touch the production
# data and can run on the same host. Stop it with `docker compose -f dev.compose.yaml down`.
name: lextracker-dev
x-environment: &environment
APP_ENVIRONMENT: development
# Plain HTTP on localhost, so no Secure cookies.
APP_SECURE_COOKIES: "false"
APP_LOG_LEVEL: debug
# uvicorn --reload runs a single process.
UVICORN_WORKERS: 1
# The files that end up in the container, as in the Dockerfile: the app folder without what is
# generated there (the stylesheet is built in the container, not taken from the host).
x-app-sync: &app-sync
path: ./app
target: /srv/app
ignore:
- "**/__pycache__/"
- "**/*.py[cod]"
- .django_tailwind_cli/
- static/css/tailwind.css
# compose.yaml pulls the published image; here both services build it from the Dockerfile.
x-build: &build
context: .
dockerfile: docker/Dockerfile
services:
app:
extends:
file: compose.yaml
service: app
container_name: lextracker-dev
image: lextracker:dev
build: *build
environment: *environment
# Bound to localhost only, because the dev server runs with DEBUG on.
ports: !override
- "127.0.0.1:8000:8000"
# `watch` copies changed files into the container, which needs a writable file system.
read_only: false
# Same as the image's CMD, plus --reload. It restarts when a synced .py file changes.
command:
- uvicorn
- config.asgi:application
- --host=0.0.0.0
- --port=8000
- --proxy-headers
- --lifespan=off
- --no-server-header
- --reload
- --reload-dir=/srv/app
volumes:
# Keeps the Tailwind CLI (downloaded on the first stylesheet build) across container rebuilds.
- lextracker-tailwind:/srv/app/.django_tailwind_cli
develop:
watch:
# Templates and scripts can use new Tailwind classes: copy, then rebuild the stylesheet.
# Runs as root because the image's app folder belongs to root. The next page load picks up
# the new file (ServeStatic checks for changes in development).
- <<: *app-sync
action: sync+exec
include:
- "**/*.html"
- "**/*.js"
- assets/tailwind.css
exec:
command: python manage.py tailwind build
user: root
# Everything else is only copied. uvicorn picks up Python changes by itself.
- <<: *app-sync
action: sync
# New dependencies or a changed Dockerfile need a new image.
- path: ./pyproject.toml
action: rebuild
- path: ./uv.lock
action: rebuild
- path: ./docker/Dockerfile
action: rebuild
scheduler:
extends:
file: compose.yaml
service: scheduler
container_name: lextracker-dev-scheduler
image: lextracker:dev
build: *build
environment: *environment
read_only: false
# `extends` does not take over depends_on.
depends_on:
app:
condition: service_healthy
develop:
watch:
# No reload here: restart the scheduler when the code changes.
- <<: *app-sync
action: sync+restart
- path: ./pyproject.toml
action: rebuild
- path: ./uv.lock
action: rebuild
- path: ./docker/Dockerfile
action: rebuild
volumes:
lextracker-data:
lextracker-backups:
lextracker-tailwind: