Skip to content

Commit 12c484e

Browse files
committed
Update basic template
1 parent 047cb10 commit 12c484e

28 files changed

+75
-21
lines changed

create_fastapi_project/templates/__init__.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ def install_template(root: str, template: ITemplate, app_name: str):
3939

4040
poetry_path = ""
4141
if template == ITemplate.full or template == ITemplate.langchain_basic:
42-
# TODO: CHECK PATHS IN MACOS AND WINDOWS | (os.path.join)
43-
poetry_path = os.path.join(root, "backend", "app")
42+
# TODO: CHECK PATHS IN MACOS AND WINDOWS | (os.path.join)
4443
poetry_frontend_path = os.path.join(root, "frontend", "app")
4544

4645
else:
47-
poetry_path = os.path.join(root, "app")
46+
poetry_path = os.path.join(root, "backend", "app")
4847

4948
has_pyproject = add_configuration_to_pyproject(poetry_path)
5049

Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
PROJECT_NAME=app
2-
BACKEND_CORS_ORIGINS=["*"]
2+
BACKEND_CORS_ORIGINS=["*"]
3+
4+
#############################################
5+
# Caddy variables
6+
#############################################
7+
EXT_ENDPOINT1=127.0.0.1
8+
LOCAL_1=localhost
9+
LOCAL_2=127.0.0.1

create_fastapi_project/templates/basic/Makefile

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ help:
3030
@echo " Lint code with ruff and try to fix."
3131

3232
install:
33-
cd app && poetry install && cd ..
33+
cd backend/app && poetry install && cd ..
3434

3535
run-app:
36-
cd app && poetry run uvicorn app.main:app --host 0.0.0.0 --port 8000 && cd ..
36+
cd backend/app && poetry run uvicorn app.main:app --host 0.0.0.0 --port 8000 && cd ..
3737

3838

3939
run-dev-build:
@@ -52,21 +52,21 @@ stop-prod:
5252
docker compose down
5353

5454
formatter:
55-
cd app && \
55+
cd backend/app && \
5656
poetry run black app
5757

5858
mypy:
59-
cd app && \
59+
cd backend/app && \
6060
poetry run mypy .
6161

6262
lint:
63-
cd app && \
63+
cd backend/app && \
6464
poetry run ruff app && poetry run black --check app
6565

6666
lint-watch:
67-
cd app && \
67+
cd backend/app && \
6868
poetry run ruff app --watch
6969

7070
lint-fix:
71-
cd app && \
71+
cd backend/app && \
7272
poetry run ruff app --fix

create_fastapi_project/templates/basic/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ make run-dev
2121
make run-prod
2222
```
2323

24+
Open [http://fastapi.localhost/docs](http://fastapi.localhost/docs) with your browser to see the result.
25+
26+
2427
- Run the server without docker:
2528

2629
First, make sure you have all packages installed:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
3+
}
4+
5+
fastapi.{$EXT_ENDPOINT1}:80, fastapi.{$LOCAL_1}:80, fastapi.{$LOCAL_2}:80 {
6+
reverse_proxy fastapi_server:8000
7+
}
8+

create_fastapi_project/templates/basic/docker-compose-dev.yml

+23-5
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,32 @@ version: '3.8'
33
services:
44
fastapi_server:
55
container_name: ${PROJECT_NAME}_fastapi_server
6-
build: .
6+
build: ./backend
77
restart: always
88
command: "sh -c 'uvicorn app.main:app --reload --workers 3 --host 0.0.0.0 --port 8000'"
99
volumes:
10-
- ./app:/code
10+
- ./backend/app:/code
1111
expose:
12-
- 8000
13-
ports:
14-
- 8000:8000
12+
- 8000
1513
env_file: ".env"
1614

15+
caddy_reverse_proxy:
16+
container_name: ${PROJECT_NAME}_caddy_reverse_proxy
17+
image: caddy:alpine
18+
restart: always
19+
ports:
20+
- 80:80
21+
- 443:443
22+
environment:
23+
- EXT_ENDPOINT1=${EXT_ENDPOINT1}
24+
- LOCAL_1=${LOCAL_1}
25+
- LOCAL_2=${LOCAL_2}
26+
volumes:
27+
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
28+
- caddy_data:/data
29+
- caddy_config:/config
30+
31+
volumes:
32+
caddy_data:
33+
caddy_config:
34+

create_fastapi_project/templates/basic/docker-compose.yml

+21-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,31 @@ version: '3.8'
33
services:
44
fastapi_server:
55
container_name: ${PROJECT_NAME}_fastapi_server
6-
build: .
6+
build: ./backend
77
restart: always
88
command: "sh -c 'gunicorn -w 3 -k uvicorn.workers.UvicornWorker app.main:app --bind 0.0.0.0:8000 --preload --log-level=debug --timeout 120'"
99
volumes:
10-
- ./app:/code
10+
- ./backend/app:/code
1111
expose:
1212
- 8000
13-
ports:
14-
- 8000:8000
1513
env_file: ".env"
1614

15+
caddy_reverse_proxy:
16+
container_name: ${PROJECT_NAME}_caddy_reverse_proxy
17+
image: caddy:alpine
18+
restart: always
19+
ports:
20+
- 80:80
21+
- 443:443
22+
environment:
23+
- EXT_ENDPOINT1=${EXT_ENDPOINT1}
24+
- LOCAL_1=${LOCAL_1}
25+
- LOCAL_2=${LOCAL_2}
26+
volumes:
27+
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
28+
- caddy_data:/data
29+
- caddy_config:/config
30+
31+
volumes:
32+
caddy_data:
33+
caddy_config:

create_fastapi_project/templates/langchain_basic/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ make run-dev
4848
make run-prod
4949
```
5050

51+
Open [http://fastapi.localhost/docs](http://fastapi.localhost/docs) with your browser to see the result.
52+
5153
- Run the server without docker:
5254

5355
First, make sure you have all packages installed:
@@ -60,7 +62,7 @@ make install
6062
make run-app
6163
```
6264

63-
Open [http://fastapi.localhost/docs](http://fastapi.localhost/docs) with your browser to see the result.
65+
Open [http://localhost:8000/docs](http://localhost:8000/docs) with your browser to see the result.
6466

6567
You can start editing the server by modifying `app/main.py`.
6668

0 commit comments

Comments
 (0)