Skip to content

Commit 9477d33

Browse files
committed
Fixed some small things.
1 parent 6db7891 commit 9477d33

2 files changed

Lines changed: 23 additions & 35 deletions

File tree

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

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ services:
66
image: {{cookiecutter.project_name}}:{{"${" }}{{cookiecutter.project_name | upper }}_VERSION:-latest{{"}"}}
77
restart: always
88
env_file:
9-
- .env
9+
- path: .env
10+
required: false
1011
{%- if cookiecutter.traefik_labels == "True" %}
1112
labels:
1213
# Enables traefik for this container.
@@ -42,6 +43,10 @@ services:
4243
kafka:
4344
condition: service_healthy
4445
{%- endif %}
46+
{%- if cookiecutter.enable_migrations == 'True' %}
47+
migrator:
48+
condition: service_completed_successfully
49+
{%- endif %}
4550
{%- endif %}
4651
environment:
4752
{{cookiecutter.project_name | upper }}_HOST: 0.0.0.0
@@ -151,7 +156,7 @@ services:
151156
{%- if cookiecutter.enable_migrations == 'True' %}
152157

153158
migrator:
154-
image: {{cookiecutter.project_name}}:{{"${" }}{{cookiecutter.project_name | upper }}_VERSION:-latest{{"}"}}
159+
<<: *main_app
155160
restart: "no"
156161
{%- if cookiecutter.orm in ['sqlalchemy', 'ormar'] %}
157162
command: alembic upgrade head
@@ -160,29 +165,12 @@ services:
160165
{%- elif cookiecutter.orm == 'piccolo' %}
161166
command: piccolo migrations forwards all
162167
{%- endif %}
163-
{%- if cookiecutter.db_info.name == "sqlite" %}
164-
environment:
165-
{{cookiecutter.project_name | upper }}_DB_FILE: /db_data/db.sqlite3
166-
{%- if cookiecutter.orm == 'piccolo' %}
167-
PICCOLO_CONF: "{{cookiecutter.project_name}}.piccolo_conf"
168-
{%- endif %}
169-
volumes:
170-
- {{cookiecutter.project_name}}-db-data:/db_data/
171-
{%- else %}
172-
environment:
173-
{{cookiecutter.project_name | upper}}_DB_HOST: {{cookiecutter.project_name}}-db
174-
{{cookiecutter.project_name | upper}}_DB_PORT: {{cookiecutter.db_info.port}}
175-
{{cookiecutter.project_name | upper}}_DB_USER: {{cookiecutter.project_name}}
176-
{{cookiecutter.project_name | upper}}_DB_PASS: {{cookiecutter.project_name}}
177-
{{cookiecutter.project_name | upper}}_DB_BASE: {{cookiecutter.project_name}}
178-
{%- if cookiecutter.orm == 'piccolo' %}
179-
PICCOLO_CONF: "{{cookiecutter.project_name}}.piccolo_conf"
180-
{%- endif %}
181-
{%- endif %}
182168
{%- if cookiecutter.db_info.name != "sqlite" %}
183169
depends_on:
184170
db:
185171
condition: service_healthy
172+
{%- else %}
173+
depends_on: {}
186174
{%- endif %}
187175
{%- endif %}
188176

@@ -204,7 +192,7 @@ services:
204192
{%- if cookiecutter.enable_rmq == "True" %}
205193

206194
rmq:
207-
image: rabbitmq:3.9.16-alpine
195+
image: rabbitmq:4.2.1-management-alpine
208196
hostname: "{{cookiecutter.project_name}}-rmq"
209197
restart: always
210198
environment:
@@ -221,23 +209,23 @@ services:
221209
{%- if cookiecutter.enable_kafka == "True" %}
222210

223211
kafka:
224-
image: bitnami/kafka:3.7.1-debian-12-r0
212+
image: apache/kafka:4.1.1
225213
hostname: "{{cookiecutter.project_name}}-kafka"
226214
environment:
227-
KAFKA_CFG_NODE_ID: "0"
228-
KAFKA_CFG_PROCESS_ROLES: "controller,broker"
229-
KAFKA_CFG_LISTENERS: "PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094"
230-
KAFKA_CFG_ADVERTISED_LISTENERS: "PLAINTEXT://kafka:9092,EXTERNAL://localhost:9094"
231-
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: "CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT"
232-
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: "0@{{cookiecutter.project_name}}-kafka:9093"
233-
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: "CONTROLLER"
234-
KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "true"
235-
KAFKA_CFG_OFFSETS_TOPIC_REPLICATION_FACTOR: "1"
215+
KAFKA_NODE_ID: "0"
216+
KAFKA_PROCESS_ROLES: "controller,broker"
217+
KAFKA_LISTENERS: "PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094"
218+
KAFKA_ADVERTISED_LISTENERS: "PLAINTEXT://kafka:9092,EXTERNAL://localhost:9094"
219+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT"
220+
KAFKA_CONTROLLER_QUORUM_VOTERS: "0@{{cookiecutter.project_name}}-kafka:9093"
221+
KAFKA_CONTROLLER_LISTENER_NAMES: "CONTROLLER"
222+
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
223+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: "1"
236224
# Uncomment it to connect from localhost.
237225
# ports:
238226
# - 9094:9094
239227
healthcheck:
240-
test: kafka-topics.sh --list --bootstrap-server localhost:9092
228+
test: /opt/kafka/bin/kafka-topics.sh --list --bootstrap-server localhost:9092
241229
interval: 1s
242230
timeout: 3s
243231
retries: 30

fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_beanie/models/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
{%- endif %}
66

77
from beanie import Document
8-
from typing import Type, Sequence
8+
from collections.abc import Sequence
99

10-
def load_all_models() -> Sequence[Type[Document]]:
10+
def load_all_models() -> Sequence[type[Document]]:
1111
"""Load all models from this folder.""" # noqa: DAR201
1212
return [
1313
{%- if cookiecutter.add_dummy == "True" %}

0 commit comments

Comments
 (0)