Skip to content

Commit 509564c

Browse files
committed
reorg and working
1 parent 7cb41a4 commit 509564c

File tree

9 files changed

+29
-23
lines changed

9 files changed

+29
-23
lines changed

samples/fastapi-postgres/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ This sample project demonstrates how to deploy FastAPI with Defang.
1313

1414
---
1515

16-
Title: FastAPI&PostgreSQL
16+
Title: FastAPI & PostgreSQL
1717

18-
Short Description: A sample project demonstrating how to deploy FastAPI with Neon as the with Defang
18+
Short Description: A sample project with FastAPI and PostgreSQL
1919

20-
Tags: FastAPI,PostgreSQL
20+
Tags: FastAPI,PostgreSQL, Python, SQL
2121

22-
Languages: Python, FastAPI
22+
Languages: Python, SQL
Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
version: '3.9'
2+
name: fastapi-postgres
3+
24
services:
3-
service1:
4-
restart: always
5-
build:
6-
context: .
7-
dockerfile: Dockerfile
5+
fastapi:
6+
extends:
7+
file: compose.yaml
8+
service: fastapi
9+
restart: unless-stopped
810
ports:
9-
- mode: ingress
10-
target: 8000
11+
- "8000:8000"
12+
environment:
13+
- DATABASE_URL=postgres://postgres:postgres@db:5432/postgres
14+
volumes:
15+
- ./fastapi:/app
1116
depends_on:
12-
- db
17+
- db
18+
command: fastapi dev main.py --host 0.0.0.0
19+
1320
db:
1421
image: postgres:15
15-
init: true
16-
restart: always
22+
restart: unless-stopped
1723
environment:
18-
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres
24+
- POSTGRES_USER=postgres
25+
- POSTGRES_PASSWORD=postgres
26+
- POSTGRES_DB=postgres
1927

2028

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
version: '3.9'
2+
name: fastapi-postgres
23
services:
3-
service1:
4-
restart: always
4+
fastapi:
55
build:
6-
context: .
6+
context: ./fastapi
77
dockerfile: Dockerfile
88
ports:
99
- mode: ingress
1010
target: 8000
1111
environment:
12-
- DATABASE_URL
13-
# To use your production database connection string, use `defang config set DATABASE_URL`
12+
- DATABASE_URL
File renamed without changes.
File renamed without changes.

samples/fastapi-postgres/Dockerfile renamed to samples/fastapi-postgres/fastapi/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@ EXPOSE 8000
2424

2525
# Run main when the container launches
2626
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
27-
USER nobody
File renamed without changes.
File renamed without changes.

samples/fastapi-postgres/templates/index.html renamed to samples/fastapi-postgres/fastapi/templates/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>FastAPI To-Do List</title>
6+
<title>FastAPI &amp; Defang To-Do List</title>
77
</head>
88
<body>
9-
<h1>To-Do List</h1>
9+
<h1>FastAPI &amp; Defang To-Do List</h1>
1010
<form action="/add" method="post">
1111
<input type="text" name="task" placeholder="New task" required>
1212
<button type="submit">Add Task</button>

0 commit comments

Comments
 (0)