Skip to content

Commit 18ed7a1

Browse files
Merge branch 'fastapi:master' into refactor-status-code
2 parents 343b64f + 110a59c commit 18ed7a1

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

docker-compose.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ services:
22
db:
33
image: postgres:12
44
restart: always
5+
healthcheck:
6+
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
7+
interval: 10s
8+
retries: 5
9+
start_period: 30s
10+
timeout: 10s
511
volumes:
612
- app-db-data:/var/lib/postgresql/data/pgdata
713
env_file:
@@ -42,7 +48,9 @@ services:
4248
- traefik-public
4349
- default
4450
depends_on:
45-
- db
51+
db:
52+
condition: service_healthy
53+
restart: true
4654
env_file:
4755
- .env
4856
environment:
@@ -73,30 +81,23 @@ services:
7381
context: ./backend
7482
args:
7583
INSTALL_DEV: ${INSTALL_DEV-false}
76-
platform: linux/amd64 # Patch for M1 Mac
7784
labels:
7885
- traefik.enable=true
7986
- traefik.docker.network=traefik-public
8087
- traefik.constraint-label=traefik-public
8188

8289
- traefik.http.services.${STACK_NAME?Variable not set}-backend.loadbalancer.server.port=80
8390

84-
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.rule=(Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`)) && (PathPrefix(`/api`) || PathPrefix(`/docs`) || PathPrefix(`/redoc`))
91+
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.rule=Host(`${DOMAIN?Variable not set}`) && (PathPrefix(`/api`) || PathPrefix(`/docs`) || PathPrefix(`/redoc`))
8592
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.entrypoints=http
8693

87-
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.rule=(Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`)) && (PathPrefix(`/api`) || PathPrefix(`/docs`) || PathPrefix(`/redoc`))
94+
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.rule=Host(`${DOMAIN?Variable not set}`) && (PathPrefix(`/api`) || PathPrefix(`/docs`) || PathPrefix(`/redoc`))
8895
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.entrypoints=https
8996
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.tls=true
9097
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.tls.certresolver=le
9198

92-
# Define Traefik Middleware to handle domain with and without "www" to redirect to only one
93-
- traefik.http.middlewares.${STACK_NAME?Variable not set}-www-redirect.redirectregex.regex=^http(s)?://www.(${DOMAIN?Variable not set})/(.*)
94-
# Redirect a domain with www to non-www
95-
- traefik.http.middlewares.${STACK_NAME?Variable not set}-www-redirect.redirectregex.replacement=http$${1}://${DOMAIN?Variable not set}/$${3}
96-
97-
# Enable www redirection for HTTP and HTTPS
98-
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.middlewares=https-redirect,${STACK_NAME?Variable not set}-www-redirect
99-
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.middlewares=${STACK_NAME?Variable not set}-www-redirect
99+
# Enable redirection for HTTP and HTTPS
100+
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.middlewares=https-redirect
100101

101102
frontend:
102103
image: '${DOCKER_IMAGE_FRONTEND?Variable not set}:${TAG-latest}'
@@ -116,17 +117,16 @@ services:
116117

117118
- traefik.http.services.${STACK_NAME?Variable not set}-frontend.loadbalancer.server.port=80
118119

119-
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`)
120+
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.rule=Host(`${DOMAIN?Variable not set}`)
120121
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.entrypoints=http
121122

122-
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`)
123+
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.rule=Host(`${DOMAIN?Variable not set}`)
123124
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.entrypoints=https
124125
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.tls=true
125126
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.tls.certresolver=le
126127

127-
# Enable www redirection for HTTP and HTTPS
128-
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.middlewares=${STACK_NAME?Variable not set}-www-redirect
129-
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.middlewares=https-redirect,${STACK_NAME?Variable not set}-www-redirect
128+
# Enable redirection for HTTP and HTTPS
129+
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.middlewares=https-redirect
130130
volumes:
131131
app-db-data:
132132

release-notes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@
44

55
* 👷 Do not sync labels as it overrides manually added labels. PR [#1307](https://github.com/fastapi/full-stack-fastapi-template/pull/1307) by [@tiangolo](https://github.com/tiangolo).
66

7+
### Features
8+
9+
* 🩺 Add DB healthcheck. PR [#1342](https://github.com/fastapi/full-stack-fastapi-template/pull/1342) by [@tiangolo](https://github.com/tiangolo).
10+
711
### Refactors
812

13+
* 🔥 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).
14+
* 🔥 Enable support for Arm Docker images in Mac, remove old patch. PR [#1341](https://github.com/fastapi/full-stack-fastapi-template/pull/1341) by [@tiangolo](https://github.com/tiangolo).
915
* ♻️ Remove duplicate information in the ItemCreate model. PR [#1287](https://github.com/fastapi/full-stack-fastapi-template/pull/1287) by [@jjaakko](https://github.com/jjaakko).
1016

1117
### Docs

0 commit comments

Comments
 (0)