Skip to content

Commit b5aa6f8

Browse files
committed
Simplify docker compose and add reload based on .env file to CMD command in the dockerfile
1 parent b5ebc8e commit b5aa6f8

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

scripts/local_with_uvicorn/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ USER app
4040
WORKDIR /code
4141

4242
# -------- replace with comment to run with gunicorn --------
43-
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
43+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload", "--reload-include", ".env"]
4444
# CMD ["gunicorn", "app.main:app", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "-b", "0.0.0.0:8000"]

scripts/local_with_uvicorn/docker-compose.yml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
services:
22
web:
3-
build:
3+
build:
44
context: .
55
dockerfile: Dockerfile
6-
# -------- Both of the following commands should be commented to run with nginx --------
7-
8-
# -------- replace with comment to run with gunicorn --------
9-
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
10-
# command: gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000
11-
env_file:
12-
- ./src/.env
13-
# -------- replace with expose if you are using nginx --------
6+
environment:
7+
# Enable polling for file changes on macOS/Windows Docker Desktop
8+
- WATCHFILES_FORCE_POLLING=true
149
ports:
1510
- "8000:8000"
16-
# expose:
17-
# - "8000"
1811
depends_on:
1912
- db
2013
- redis
@@ -23,7 +16,7 @@ services:
2316
- ./src/.env:/code/.env
2417

2518
worker:
26-
build:
19+
build:
2720
context: .
2821
dockerfile: Dockerfile
2922
command: arq app.core.worker.settings.WorkerSettings
@@ -64,7 +57,7 @@ services:
6457

6558
#-------- uncomment to create first superuser --------
6659
create_superuser:
67-
build:
60+
build:
6861
context: .
6962
dockerfile: Dockerfile
7063
env_file:
@@ -78,9 +71,9 @@ services:
7871

7972
#-------- uncomment to run tests --------
8073
pytest:
81-
build:
74+
build:
8275
context: .
83-
dockerfile: Dockerfile
76+
dockerfile: Dockerfile
8477
env_file:
8578
- ./src/.env
8679
depends_on:
@@ -93,7 +86,7 @@ services:
9386

9487
#-------- uncomment to create first tier --------
9588
# create_tier:
96-
# build:
89+
# build:
9790
# context: .
9891
# dockerfile: Dockerfile
9992
# env_file:
@@ -109,4 +102,3 @@ services:
109102
volumes:
110103
postgres-data:
111104
redis-data:
112-

0 commit comments

Comments
 (0)