Skip to content

Commit 399c563

Browse files
authored
Changed docker-compose and updated CIs. (#217)
1 parent c2473b2 commit 399c563

File tree

9 files changed

+40
-350
lines changed

9 files changed

+40
-350
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ python3 -m fastapi_template
2424
# Answer all the questions
2525
# 🍪 Enjoy your new project 🍪
2626
cd new_project
27-
docker-compose -f deploy/docker-compose.yml --project-directory . build
28-
docker-compose -f deploy/docker-compose.yml --project-directory . up --build
27+
docker-compose up --build
2928
```
3029

3130
If you want to install it from sources, try this:
@@ -90,6 +89,7 @@ Options:
9089
Choose Object–Relational Mapper lib
9190
--ci [none|gitlab_ci|github] Select a CI for your app
9291
--redis Add redis support
92+
--add_users Add fastapi-users support
9393
--rabbit Add RabbitMQ support
9494
--taskiq Add Taskiq support
9595
--migrations Add Migrations
@@ -104,5 +104,7 @@ Options:
104104
--traefik Adds traefik labels to docker container
105105
--kafka Add Kafka support
106106
--gunicorn Add gunicorn server
107+
--cookie-auth Add authentication via cookie support
108+
--jwt-auth Add JWT auth support
107109
--help Show this message and exit.
108110
```

fastapi_template/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ def checker(ctx: BuilderContext) -> bool:
597597
entries=[
598598
MenuEntry(
599599
code="cookie_auth",
600-
cli_name="cookie auth",
600+
cli_name="cookie-auth",
601601
user_view="Add authentication via cookie support",
602602
description=(
603603
"Adds {cookie} authentication support.".format(
@@ -610,7 +610,7 @@ def checker(ctx: BuilderContext) -> bool:
610610
),
611611
MenuEntry(
612612
code="jwt_auth",
613-
cli_name="jwt auth",
613+
cli_name="jwt-auth",
614614
user_view="Add JWT auth support",
615615
description=(
616616
"Adds {name} authentication support.".format(

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

Lines changed: 0 additions & 115 deletions
This file was deleted.

fastapi_template/template/{{cookiecutter.project_name}}/.github/workflows/tests.yml

Lines changed: 14 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -13,128 +13,31 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4
16+
- name: Install poetry
17+
run: pipx install poetry
1618
- name: Set up Python
1719
uses: actions/setup-python@v5
1820
with:
1921
python-version: '3.11'
22+
cache: 'poetry'
2023
- name: Install deps
2124
run: poetry install
2225
- name: Run lint check
2326
run: poetry run pre-commit run -a {{ '${{' }} matrix.cmd {{ '}}' }}
2427
pytest:
2528
runs-on: ubuntu-latest
26-
{%- if ((cookiecutter.db_info.name != "none" and cookiecutter.db_info.name != "sqlite") or
27-
(cookiecutter.enable_rmq == "True") or
28-
(cookiecutter.enable_kafka == "True")) %}
29-
services:
30-
{%- if cookiecutter.db_info.name != "none" and cookiecutter.db_info.name != "sqlite" %}
31-
32-
{{cookiecutter.project_name}}-db:
33-
image: {{ cookiecutter.db_info.image }}
34-
env:
35-
{%- if cookiecutter.db_info.name == "postgresql" %}
36-
POSTGRES_PASSWORD: {{ cookiecutter.project_name }}
37-
POSTGRES_USER: {{ cookiecutter.project_name }}
38-
POSTGRES_DB: {{ cookiecutter.project_name }}
39-
{%- endif %}
40-
{%- if cookiecutter.db_info.name == "mysql" %}
41-
MYSQL_ROOT_PASSWORD: "{{ cookiecutter.project_name }}"
42-
MYSQL_USER: "{{ cookiecutter.project_name }}"
43-
MYSQL_DATABASE: "{{ cookiecutter.project_name }}"
44-
{%- endif %}
45-
{%- if cookiecutter.db_info.name == "mongodb" %}
46-
MONGO_INITDB_ROOT_USERNAME: "{{ cookiecutter.project_name }}"
47-
MONGO_INITDB_ROOT_PASSWORD: "{{ cookiecutter.project_name }}"
48-
{%- endif %}
49-
{%- if cookiecutter.db_info.name == "mysql" %}
50-
options: >-
51-
--health-cmd="mysqladmin ping --user={{ cookiecutter.project_name }} --password={{ cookiecutter.project_name }}"
52-
--health-interval=15s
53-
--health-timeout=5s
54-
--health-retries=6
55-
{%- endif %}
56-
{%- if cookiecutter.db_info.name == "postgresql" %}
57-
options: >-
58-
--health-cmd="pg_isready"
59-
--health-interval=10s
60-
--health-timeout=5s
61-
--health-retries=5
62-
{%- endif %}
63-
ports:
64-
- {{ cookiecutter.db_info.port }}:{{ cookiecutter.db_info.port }}
65-
{%- endif %}
66-
{%- if cookiecutter.enable_rmq == "True" %}
67-
68-
{{cookiecutter.project_name}}-rmq:
69-
image: rabbitmq:3.9.16-alpine
70-
env:
71-
RABBITMQ_DEFAULT_USER: "guest"
72-
RABBITMQ_DEFAULT_PASS: "guest"
73-
RABBITMQ_DEFAULT_VHOST: "/"
74-
options: >-
75-
--health-cmd="rabbitmq-diagnostics check_running -q"
76-
--health-interval=10s
77-
--health-timeout=5s
78-
--health-retries=8
79-
ports:
80-
- 5672:5672
81-
{%- endif %}
82-
{%- if cookiecutter.enable_kafka == "True" %}
83-
84-
{{cookiecutter.project_name}}-zookeeper:
85-
image: "bitnami/zookeeper:3.7.1"
86-
env:
87-
ALLOW_ANONYMOUS_LOGIN: "yes"
88-
ZOO_LOG_LEVEL: "ERROR"
89-
options: >-
90-
--health-cmd="zkServer.sh status"
91-
--health-interval=10s
92-
--health-timeout=5s
93-
--health-retries=8
94-
95-
{{cookiecutter.project_name}}-kafka:
96-
image: bitnami/kafka:3.2.0
97-
env:
98-
KAFKA_BROKER_ID: "1"
99-
ALLOW_PLAINTEXT_LISTENER: "yes"
100-
KAFKA_CFG_LISTENERS: "PLAINTEXT://0.0.0.0:9092"
101-
KAFKA_CFG_ADVERTISED_LISTENERS: "PLAINTEXT://localhost:9092"
102-
KAFKA_CFG_ZOOKEEPER_CONNECT: "{{cookiecutter.project_name}}-zookeeper:2181"
103-
options: >-
104-
--health-cmd="kafka-topics.sh --list --bootstrap-server localhost:9092"
105-
--health-interval=10s
106-
--health-timeout=5s
107-
--health-retries=8
108-
ports:
109-
- 9092:9092
110-
{%- endif %}
111-
{%- endif %}
11229
steps:
113-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v4
31+
- name: Create .env
32+
run: touch .env
11433
- name: Set up Python
115-
uses: actions/setup-python@v2
34+
uses: actions/setup-python@v5
11635
with:
117-
python-version: '3.9'
118-
- name: Install deps
119-
uses: knowsuchagency/poetry-install@v1
120-
env:
121-
POETRY_VIRTUALENVS_CREATE: false
122-
- name: Run pytest check
123-
run: poetry run pytest -vv --cov="{{cookiecutter.project_name}}" .
124-
env:
125-
{{ cookiecutter.project_name | upper }}_HOST: "0.0.0.0"
126-
{%- if cookiecutter.db_info.name != "none" %}
127-
{%- if cookiecutter.db_info.name != "sqlite" %}
128-
{{ cookiecutter.project_name | upper }}_DB_HOST: localhost
129-
{%- endif %}
130-
{%- if cookiecutter.db_info.name == "mongodb" %}
131-
{{ cookiecutter.project_name | upper }}_DB_BASE: admin
132-
{%- endif %}
133-
{%- endif %}
134-
{%- if cookiecutter.enable_rmq == "True" %}
135-
{{ cookiecutter.project_name | upper }}_RABBIT_HOST: localhost
136-
{%- endif %}
137-
{%- if cookiecutter.enable_kafka == "True" %}
138-
{{ cookiecutter.project_name | upper }}_KAFKA_BOOTSTRAP_SERVERS: '["localhost:9092"]'
139-
{%- endif %}
36+
python-version: '3.11'
37+
- name: Update docker-compose
38+
uses: KengoTODA/actions-setup-docker-compose@v1
39+
with:
40+
version: "2.28.0"
41+
- name: run tests
42+
run: docker-compose run --rm api pytest -vv
14043

0 commit comments

Comments
 (0)