Skip to content

Commit

Permalink
Updated databases.
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Kirilin <[email protected]>
  • Loading branch information
s3rius committed Jun 30, 2024
1 parent 64a109a commit 076b03c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions fastapi_template/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def checker(ctx: BuilderContext) -> bool:
),
additional_info=Database(
name="mysql",
image="bitnami/mysql:8.0.30",
image="mysql:8.4",
async_driver="mysql+aiomysql",
driver_short="mysql",
driver="mysql",
Expand All @@ -178,7 +178,7 @@ def checker(ctx: BuilderContext) -> bool:
),
additional_info=Database(
name="postgresql",
image="postgres:13.8-bullseye",
image="postgres:16.3-bullseye",
async_driver="postgresql+asyncpg",
driver_short="postgres",
driver="postgresql",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,16 @@ jobs:
{%- endif %}
{%- if cookiecutter.db_info.name == "mysql" %}
MYSQL_ROOT_PASSWORD: "{{ cookiecutter.project_name }}"
MYSQL_ROOT_USER: "{{ cookiecutter.project_name }}"
MYSQL_USER: "{{ cookiecutter.project_name }}"
MYSQL_DATABASE: "{{ cookiecutter.project_name }}"
MYSQL_AUTHENTICATION_PLUGIN: "mysql_native_password"
{%- endif %}
{%- if cookiecutter.db_info.name == "mongodb" %}
MONGO_INITDB_ROOT_USERNAME: "{{ cookiecutter.project_name }}"
MONGO_INITDB_ROOT_PASSWORD: "{{ cookiecutter.project_name }}"
{%- endif %}
{%- if cookiecutter.db_info.name == "mysql" %}
options: >-
--health-cmd="mysqladmin ping -u root"
--health-cmd="mysqladmin ping --user={{ cookiecutter.project_name }} --password={{ cookiecutter.project_name }}"
--health-interval=15s
--health-timeout=5s
--health-retries=6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,24 @@ services:
hostname: {{cookiecutter.project_name}}-db
restart: always
environment:
MYSQL_ROOT_USER: "{{cookiecutter.project_name}}"
MYSQL_ROOT_USER: "root"
MYSQL_ROOT_PASSWORD: "{{cookiecutter.project_name}}"
MYSQL_USER: "{{cookiecutter.project_name}}"
MYSQL_PASSWORD: "{{cookiecutter.project_name}}"
MYSQL_DATABASE: "{{cookiecutter.project_name}}"
MYSQL_AUTHENTICATION_PLUGIN: "mysql_native_password"
MYSQL_HOST: "0.0.0.0"
healthcheck:
test: mysqladmin ping -h localhost
test:
- CMD
- mysqladmin
- ping
- --user={{cookiecutter.project_name}}
- --password={{cookiecutter.project_name}}
interval: 10s
timeout: 5s
retries: 40
volumes:
- {{cookiecutter.project_name}}-db-data:/bitnami/mysql/data
- "{{cookiecutter.project_name}}-db-data:/bitnami/mysql/data"
{%- endif %}

{%- if cookiecutter.enable_migrations == 'True' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ env = [
{%- else %}
"{{cookiecutter.project_name | upper}}_DB_BASE={{cookiecutter.project_name}}_test",
{%- endif %}
{%- if cookiecutter.db_info.name == "mysql" %}
"{{cookiecutter.project_name | upper}}_DB_USER=root"
{%- endif %}
{%- if cookiecutter.orm == "piccolo" %}
"PICCOLO_CONF={{cookiecutter.project_name}}.piccolo_conf",
{%- endif %}
Expand Down

0 comments on commit 076b03c

Please sign in to comment.