Skip to content

Commit 406ed84

Browse files
committed
Merge tag '3.3.7' into develop
3.3.7
2 parents 3e806a6 + 98f07cd commit 406ed84

11 files changed

Lines changed: 56 additions & 8 deletions

File tree

.github/workflows/test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ jobs:
3131
with:
3232
python-version: '3.9'
3333
- name: Install deps
34-
uses: knowsuchagency/poetry-install@v1
34+
run: |
35+
pip install -U pip
36+
pip install poetry==1.1.13
37+
poetry install
3538
env:
3639
POETRY_VIRTUALENVS_CREATE: false
3740
- name: Setup GIT

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ WORKDIR /src
2222

2323
ENV PATH ${PATH}:/home/fastapi_template/.local/bin
2424

25-
RUN pip install poetry==1.1.11
25+
RUN pip install poetry==1.1.13
2626

2727
COPY . /src/
2828
RUN pip install .

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ usage: FastAPI template [-h] [--version] [--name PROJECT_NAME]
8181
[--ci {none,gitlab_ci,github}] [--redis] [--rabbit]
8282
[--migrations] [--kube] [--dummy] [--routers]
8383
[--swagger] [--prometheus] [--sentry] [--loguru]
84-
[--opentelemetry] [--force] [--quite]
84+
[--opentelemetry] [--traefik] [--force] [--quite]
8585

8686
optional arguments:
8787
-h, --help show this help message and exit
@@ -109,6 +109,7 @@ optional arguments:
109109
--sentry Add sentry integration
110110
--loguru Add loguru logger
111111
--opentelemetry Add opentelemetry integration
112+
--traefik Adds traefik labels to docker container
112113
--force Owerrite directory if it exists
113114
--quite Do not ask for features during generation
114115
```

fastapi_template/cli.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ def parse_args():
158158
default=None,
159159
dest="otlp_enabled",
160160
)
161+
parser.add_argument(
162+
"--traefik",
163+
help="Adds traefik labels to docker container",
164+
action="store_true",
165+
default=None,
166+
dest="traefik_labels",
167+
)
161168
parser.add_argument(
162169
"--force",
163170
help="Owerrite directory if it exists",
@@ -182,7 +189,7 @@ def ask_features(current_context: BuilderContext) -> BuilderContext:
182189
"name": "enable_redis",
183190
"value": current_context.enable_redis,
184191
},
185-
"Kubernetes": {
192+
"Kubernetes config (deprecated)": {
186193
"name": "enable_kube",
187194
"value": current_context.enable_kube,
188195
},
@@ -214,6 +221,10 @@ def ask_features(current_context: BuilderContext) -> BuilderContext:
214221
"name": "enable_loguru",
215222
"value": current_context.enable_loguru,
216223
},
224+
"Traefik labels for docker": {
225+
"name": "traefik_labels",
226+
"value": current_context.traefik_labels,
227+
},
217228
}
218229
if current_context.db != DatabaseType.none:
219230
features["Migrations support"] = {

fastapi_template/input_model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class BuilderContext(BaseModel):
122122
otlp_enabled: Optional[bool]
123123
enable_rmq: Optional[bool]
124124
enable_loguru: Optional[bool]
125+
traefik_labels: Optional[bool]
125126
force: bool = False
126127
quite: bool = False
127128

fastapi_template/template/cookiecutter.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
"enable_loguru": {
3636
"type": "bool"
3737
},
38+
"traefik_labels": {
39+
"type": "bool"
40+
},
3841
"add_dummy": {
3942
"type": "bool"
4043
},

fastapi_template/template/{{cookiecutter.project_name}}/.flake8

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,17 @@ per-file-ignores =
9595
WPS410,
9696

9797
exclude =
98+
./.cache,
9899
./.git,
100+
./.idea,
101+
./.mypy_cache,
102+
./.pytest_cache,
103+
./.venv,
99104
./venv,
100-
migrations,
105+
./env,
106+
./cached_venv,
107+
./docs,
108+
./deploy,
101109
./var,
110+
./.vscode,
111+
*migrations*,

fastapi_template/template/{{cookiecutter.project_name}}/.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ stages:
1010
except:
1111
- tags
1212
before_script:
13-
- pip install poetry==1.1.7
13+
- pip install poetry==1.1.13
1414
- poetry config virtualenvs.create false
1515
- poetry install
1616

fastapi_template/template/{{cookiecutter.project_name}}/deploy/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ RUN apt-get update && apt-get install -y \
77
&& rm -rf /var/lib/apt/lists/*
88
{%- endif %}
99

10-
RUN pip install poetry==1.1.8
10+
RUN pip install poetry==1.1.13
1111

1212
# Configuring poetry
1313
RUN poetry config virtualenvs.create false

fastapi_template/template/{{cookiecutter.project_name}}/deploy/docker-compose.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ services:
99
restart: always
1010
env_file:
1111
- .env
12+
{%- if cookiecutter.traefik_labels == "True" %}
13+
labels:
14+
# Enables traefik for this container.
15+
- traefik.enable=true
16+
- traefik.http.routers.{{cookiecutter.project_name}}.rule=Host(`{{ "${" }}{{cookiecutter.project_name | upper}}_TRAEFIK_HOST:-{{cookiecutter.project_name}}.localhost{{ "}" }}`)
17+
- traefik.http.routers.{{cookiecutter.project_name}}.entrypoints=http
18+
- traefik.http.routers.{{cookiecutter.project_name}}.service={{cookiecutter.project_name}}
19+
- traefik.http.services.{{cookiecutter.project_name}}.loadbalancer.server.port={{ "${" }}{{cookiecutter.project_name | upper}}_PORT:-8000{{ "}" }}
20+
networks:
21+
- default
22+
- traefik-shared
23+
{%- endif %}
1224
{%- if ((cookiecutter.db_info.name != "none" and cookiecutter.db_info.name != "sqlite") or
1325
(cookiecutter.enable_redis == "True") or
1426
(cookiecutter.enable_rmq == "True")) %}
@@ -159,3 +171,10 @@ volumes:
159171
{{cookiecutter.project_name}}-db-data:
160172
name: {{cookiecutter.project_name}}-db-data
161173
{% endif %}
174+
175+
{%- if cookiecutter.traefik_labels == "True" %}
176+
networks:
177+
# Network for traefik.
178+
traefik-shared:
179+
name: traefik-shared
180+
{% endif %}

0 commit comments

Comments
 (0)