Skip to content

Commit 1c1a1be

Browse files
Merge branch 'fastapi:master' into refactor-status-code
2 parents 972f57c + 68a7fe0 commit 1c1a1be

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

backend/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ COPY ./prestart.sh /app/
2626
COPY ./tests-start.sh /app/
2727

2828
COPY ./app /app/app
29+
30+
CMD ["fastapi", "run", "--workers", "4", "app/main.py"]

docker-compose.override.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,19 @@ services:
5959
restart: "no"
6060
ports:
6161
- "8888:8888"
62-
- "8000:80"
62+
- "8000:8000"
6363
volumes:
6464
- ./backend/:/app
6565
build:
6666
context: ./backend
6767
args:
6868
INSTALL_DEV: ${INSTALL_DEV-true}
6969
# command: sleep infinity # Infinite loop to keep container alive doing nothing
70-
command: /start-reload.sh
70+
command:
71+
- fastapi
72+
- run
73+
- --reload
74+
- "app/main.py"
7175
environment:
7276
SMTP_HOST: "mailcatcher"
7377
SMTP_PORT: "1025"

docker-compose.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,41 @@ services:
4242
- traefik.http.routers.${STACK_NAME?Variable not set}-adminer-https.tls.certresolver=le
4343
- traefik.http.services.${STACK_NAME?Variable not set}-adminer.loadbalancer.server.port=8080
4444

45+
prestart:
46+
image: '${DOCKER_IMAGE_BACKEND?Variable not set}:${TAG-latest}'
47+
build:
48+
context: ./backend
49+
args:
50+
INSTALL_DEV: ${INSTALL_DEV-false}
51+
networks:
52+
- traefik-public
53+
- default
54+
depends_on:
55+
db:
56+
condition: service_healthy
57+
restart: true
58+
command: bash prestart.sh
59+
env_file:
60+
- .env
61+
environment:
62+
- DOMAIN=${DOMAIN}
63+
- FRONTEND_HOST=${FRONTEND_HOST?Variable not set}
64+
- ENVIRONMENT=${ENVIRONMENT}
65+
- BACKEND_CORS_ORIGINS=${BACKEND_CORS_ORIGINS}
66+
- SECRET_KEY=${SECRET_KEY?Variable not set}
67+
- FIRST_SUPERUSER=${FIRST_SUPERUSER?Variable not set}
68+
- FIRST_SUPERUSER_PASSWORD=${FIRST_SUPERUSER_PASSWORD?Variable not set}
69+
- SMTP_HOST=${SMTP_HOST}
70+
- SMTP_USER=${SMTP_USER}
71+
- SMTP_PASSWORD=${SMTP_PASSWORD}
72+
- EMAILS_FROM_EMAIL=${EMAILS_FROM_EMAIL}
73+
- POSTGRES_SERVER=db
74+
- POSTGRES_PORT=${POSTGRES_PORT}
75+
- POSTGRES_DB=${POSTGRES_DB}
76+
- POSTGRES_USER=${POSTGRES_USER?Variable not set}
77+
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD?Variable not set}
78+
- SENTRY_DSN=${SENTRY_DSN}
79+
4580
backend:
4681
image: '${DOCKER_IMAGE_BACKEND?Variable not set}:${TAG-latest}'
4782
restart: always
@@ -52,6 +87,8 @@ services:
5287
db:
5388
condition: service_healthy
5489
restart: true
90+
prestart:
91+
condition: service_completed_successfully
5592
env_file:
5693
- .env
5794
environment:
@@ -74,7 +111,7 @@ services:
74111
- SENTRY_DSN=${SENTRY_DSN}
75112

76113
healthcheck:
77-
test: ["CMD", "curl", "-f", "http://localhost/api/v1/utils/health-check/"]
114+
test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/utils/health-check/"]
78115
interval: 10s
79116
timeout: 5s
80117
retries: 5
@@ -88,7 +125,7 @@ services:
88125
- traefik.docker.network=traefik-public
89126
- traefik.constraint-label=traefik-public
90127

91-
- traefik.http.services.${STACK_NAME?Variable not set}-backend.loadbalancer.server.port=80
128+
- traefik.http.services.${STACK_NAME?Variable not set}-backend.loadbalancer.server.port=8000
92129

93130
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.rule=Host(`api.${DOMAIN?Variable not set}`)
94131
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.entrypoints=http

release-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Refactors
1212

13+
* ♻️ Refactor prestart (migrations), move that to its own container. PR [#1350](https://github.com/fastapi/full-stack-fastapi-template/pull/1350) by [@tiangolo](https://github.com/tiangolo).
1314
* ♻️ Include `FRONTEND_HOST` in CORS origins by default. PR [#1348](https://github.com/fastapi/full-stack-fastapi-template/pull/1348) by [@tiangolo](https://github.com/tiangolo).
1415
* ♻️ Simplify domains with `api.example.com` for API and `dashboard.example.com` for frontend, improve local development with `localhost`. PR [#1344](https://github.com/fastapi/full-stack-fastapi-template/pull/1344) by [@tiangolo](https://github.com/tiangolo).
1516
* 🔥 Simplify Traefik, remove www-redirects that add complexity. PR [#1343](https://github.com/fastapi/full-stack-fastapi-template/pull/1343) by [@tiangolo](https://github.com/tiangolo).

0 commit comments

Comments
 (0)