Skip to content
This repository was archived by the owner on Sep 28, 2023. It is now read-only.

Commit 9898e72

Browse files
committed
added 2 more docker-compose files and updated dependencies/tests/.env file
1 parent 7a99ffd commit 9898e72

15 files changed

Lines changed: 755 additions & 388 deletions

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"python.pythonPath": ".venv\\Scripts\\python.exe",
32
"python.formatting.provider": "black",
43
"python.analysis.extraPaths": ["./fastapi_plan/template/{{cookiecutter.project_name}}"]
54
}

fastapi_plan/template/hooks/post_gen_project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def remove_file(filepath):
1010
if __name__ == "__main__":
1111

1212
if "{{ cookiecutter.preffered_requirements_tool }}" == "poetry":
13-
remove_file("requirements.txt")
13+
pass
1414
else:
1515
remove_file("pyproject.toml")
1616
remove_file("poetry.lock")

fastapi_plan/template/{{cookiecutter.project_name}}/.dockerignore

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,24 @@ README.md
22
.gitignore
33
data
44
.vscode
5-
venv
5+
venv
6+
.venv
7+
letsencrypt
8+
poetry.lock
9+
pyproject.toml
10+
requirements.txt
11+
.git/
12+
13+
build
14+
dist
15+
*.egg-info
16+
*.egg/
17+
*.pyc
18+
*.swp
19+
20+
.tox
21+
.coverage
22+
.pytest_cache
23+
24+
html/*
25+
__pycache__
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
DEBUG=true
22
SECRET_KEY="{{ random_ascii_string(50) }}"
3-
ACCESS_TOKEN_EXPIRE_MINUTES= 11520
3+
ACCESS_TOKEN_EXPIRE_MINUTES=11520
44

55
PROJECT_NAME="{{ cookiecutter.project_name }}"
6-
API_STR=""
7-
BACKEND_CORS_ORIGINS="http://localhost:3000,http://localhost:8001"
6+
API_STR=
7+
BACKEND_CORS_ORIGINS=http://localhost:3000,http://localhost:8001
88

9-
POSTGRES_USER="postgres"
9+
POSTGRES_USER=postgres
1010
POSTGRES_PASSWORD="{{ random_ascii_string(50) }}"
11-
POSTGRES_SERVER="db"
12-
POSTGRES_DB="db"
13-
POSTGRES_PORT="5432"
11+
# change POSTGRES_SERVER to: "db" (literally <db>) in debug/production
12+
POSTGRES_SERVER=localhost
13+
POSTGRES_DB=db
14+
POSTGRES_PORT=5432
1415

15-
FIRST_SUPERUSER_EMAIL="example@example.com"
16-
FIRST_SUPERUSER_PASSWORD="{{ random_ascii_string(20) }}"
16+
FIRST_SUPERUSER_EMAIL=example@example.com
17+
FIRST_SUPERUSER_PASSWORD="{{ random_ascii_string(20) }}"
18+
19+
# letsencrypt ssl certificate contact email
20+
DEFAULT_FROM_EMAIL=my_personal_email@example.com
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
version: "3.3"
2+
3+
# For testing if project is alive on http (port 80) only!!! (without traefic)
4+
#
5+
# docker-compose -f docker-compose.debug.yml up -d
6+
#
7+
# It should be available on HOST_NAME adress, for example
8+
# 1. http://localhost
9+
# 2. http://example.com
10+
# Depend on using it with your machine or VM
11+
12+
services:
13+
db:
14+
restart: always
15+
image: postgres
16+
volumes:
17+
- ./data/db:/var/lib/postgresql/data
18+
environment:
19+
- POSTGRES_DB=${POSTGRES_DB}
20+
- POSTGRES_USER=${POSTGRES_USER}
21+
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
22+
env_file:
23+
- .env
24+
ports:
25+
- ${POSTGRES_PORT}:5432
26+
healthcheck:
27+
test: ["CMD-SHELL", "pg_isready -U postgres"]
28+
interval: 5s
29+
timeout: 5s
30+
retries: 5
31+
web:
32+
restart: always
33+
build:
34+
context: ./
35+
dockerfile: Dockerfile
36+
ports:
37+
- "80:80"
38+
depends_on:
39+
- db
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
version: "3.3"
2+
3+
# For running project with own domain (IT IS REQUIRED) with https (traefic as proxy)
4+
#
5+
# docker-compose -f docker-compose.prod.yml up -d
6+
#
7+
# It should be available on HOST_NAME adress, for example
8+
# 1. https://example.com
9+
# 2. http://example.com -> redirected to https://example.com
10+
# QUICK NOTES
11+
# a) By default log_level = DEBUG in traefic and it uses test certificates
12+
# b) provide your domain name in MAIN_DOMAIN and email DEFAULT_FROM_EMAIL in .env file
13+
14+
services:
15+
db:
16+
restart: always
17+
image: postgres
18+
volumes:
19+
- ./data/db:/var/lib/postgresql/data
20+
environment:
21+
- POSTGRES_DB=${POSTGRES_DB}
22+
- POSTGRES_USER=${POSTGRES_USER}
23+
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
24+
env_file:
25+
- .env
26+
ports:
27+
- ${POSTGRES_PORT}:5432
28+
healthcheck:
29+
test: ["CMD-SHELL", "pg_isready -U postgres"]
30+
interval: 5s
31+
timeout: 5s
32+
retries: 5
33+
34+
web:
35+
depends_on:
36+
- db
37+
restart: always
38+
build:
39+
context: ./
40+
dockerfile: Dockerfile
41+
labels:
42+
- "traefik.enable=true"
43+
- "traefik.http.routers.web.rule=Host(`${MAIN_DOMAIN}`)"
44+
- "traefik.http.routers.web.entrypoints=websecure"
45+
- "traefik.http.routers.web.tls.certresolver=myresolver"
46+
- "traefik.http.services.web.loadbalancer.server.port=80"
47+
env_file:
48+
- .env
49+
50+
traefik:
51+
image: "traefik:v2.4"
52+
container_name: "traefik"
53+
command:
54+
#
55+
# comment line below after debugging!
56+
- "--log.level=DEBUG"
57+
- "--api.dashboard=false"
58+
- "--providers.docker=true"
59+
- "--providers.docker.exposedbydefault=false"
60+
- "--entrypoints.web.address=:80"
61+
- "--entrypoints.websecure.address=:443"
62+
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
63+
- "--entrypoints.web.http.redirections.entryPoint.scheme=https"
64+
- "--certificatesresolvers.myresolver.acme.httpchallenge=true"
65+
- "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web"
66+
#
67+
# test certificates, comment line below to use real certificates
68+
- "--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
69+
- "--certificatesresolvers.myresolver.acme.email=${DEFAULT_FROM_EMAIL}"
70+
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
71+
ports:
72+
- "80:80"
73+
- "443:443"
74+
volumes:
75+
- "./letsencrypt:/letsencrypt"
76+
- "/var/run/docker.sock:/var/run/docker.sock:ro"
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
version: "3.9"
1+
version: "3.3"
2+
3+
# For local development, only database is running
4+
#
5+
# docker-compose up -d
6+
# aerich upgrade
7+
# python app/initial_data.py
8+
# uvicorn app.main:app --reload
9+
#
210

311
services:
412
db:
13+
restart: always
514
image: postgres
615
volumes:
716
- ./data/db:/var/lib/postgresql/data
8-
ports:
9-
- "5432:5432"
1017
environment:
1118
- POSTGRES_DB=${POSTGRES_DB}
1219
- POSTGRES_USER=${POSTGRES_USER}
1320
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
1421
env_file:
1522
- .env
16-
web:
17-
restart: always
18-
build:
19-
context: ./
20-
dockerfile: Dockerfile
2123
ports:
22-
- "80:80"
23-
depends_on:
24-
- db
24+
- ${POSTGRES_PORT}:5432
25+
healthcheck:
26+
test: ["CMD-SHELL", "pg_isready -U postgres"]
27+
interval: 5s
28+
timeout: 5s
29+
retries: 5
30+

0 commit comments

Comments
 (0)