Single part at the root, COMPOSE_FILE in .env

This commit is contained in:
hh
2026-09-08 20:38:54 +02:00
parent 321e4b6b35
commit aac037676c
86 changed files with 68 additions and 27 deletions
-5
View File
@@ -1,5 +0,0 @@
[environment]
python = "backend/.venv"
[src]
exclude = ["backend/migrations"]
+5
View File
@@ -0,0 +1,5 @@
[environment]
python = "{{ prefix }}.venv"
[src]
exclude = ["{{ prefix }}migrations"]
@@ -1,4 +1,5 @@
RUN_ENVIRONMENT=dev
{% if layout == 'root' %}COMPOSE_FILE=docker-compose.yml:docker-compose.local.yml
{% endif %}RUN_ENVIRONMENT=dev
LOG__LEVEL=INFO
LOG__LEVEL_EXTERNAL=WARNING
LOG__SHOW_TIME=false
@@ -5,9 +5,11 @@
{%- if 'kurigram_userbot' in backend_services %}{% set _ = svc_modules.append("userbot") %}{% endif -%}
{%- if 'scheduler' in backend_services and 'taskiq_worker' not in backend_services %}{% set _ = svc_modules.append("scheduler") %}{% endif -%}
{%- set has_script = dynamic_config and svc_modules -%}
COMPOSE := docker compose --project-directory ..
.PHONY: fmt check build{% if database == 'postgres' %} migrate revision{% endif %}{% if has_script %} script{% endif %}{% if 'kurigram_userbot' in backend_services %} session{% endif %}
COMPOSE := docker compose{% if layout == 'part' %} --project-directory ..{% endif %}
{% if layout == 'root' %}SERVICES := $(COMPOSE) --profile services
EXTERNAL := $(COMPOSE) --profile external
{% endif %}
.PHONY: {% if layout == 'root' %}env external recreate rebuild restart logs down {% endif %}fmt check build{% if database == 'postgres' %} migrate revision{% endif %}{% if has_script %} script{% endif %}{% if 'kurigram_userbot' in backend_services %} session{% endif %}
fmt:
uv run ruff format
@@ -20,7 +22,27 @@ check:
build:
$(COMPOSE) build {{ svc_modules[0] }}
{% if database == 'postgres' %}
{% if layout == 'root' %}
env:
@test -f .env || cp .env.example .env
external:
$(EXTERNAL) up -d
recreate: external
$(SERVICES) up -d --force-recreate
rebuild: build recreate
restart:
$(SERVICES) restart
logs:
$(SERVICES) logs -f --tail=100
down:
$(EXTERNAL) --profile services down
{% endif %}{% if database == 'postgres' %}
migrate:
$(COMPOSE) --profile external run --rm migrator
@@ -9,21 +9,21 @@
{%- if 'kurigram_userbot' in backend_services %}{% set _ = app_services.append({'name': 'userbot', 'command': '[userbot]'}) %}{% endif -%}
{%- if 'scheduler' in backend_services %}{% set _ = app_services.append({'name': 'scheduler', 'command': ('[worker, scheduler]' if 'taskiq_worker' in backend_services else '[scheduler]')}) %}{% endif -%}
{%- macro backend_service(name, command) %} {{ name }}:
build: backend
build: {{ part_dir }}
image: {{ project_slug }}/backend
profiles: [{{ name }}, services]
restart: unless-stopped
env_file:
- path: .env
required: false
- path: backend/.env
{% if layout == 'part' %} - path: backend/.env
required: false
environment:
{% endif %} environment:
RUN_ENVIRONMENT: prod
volumes:
- ./backend/src:/app/src
{% if has_scripts %} - ./backend/scripts:/app/scripts
{% endif %}{% if name == 'userbot' %} - ./backend/sessions:/app/sessions
- ./{{ prefix }}src:/app/src
{% if has_scripts %} - ./{{ prefix }}scripts:/app/scripts
{% endif %}{% if name == 'userbot' %} - ./{{ prefix }}sessions:/app/sessions
{% endif %}{% if name == 'api' and serve_spa %} - ./frontend/build:/app/static:ro
{% endif %} command: {{ command }}
{% if svc_networks %} networks:
@@ -70,20 +70,20 @@ services:
- ${DB__HOST:-postgres}
migrator:
build: backend
build: {{ part_dir }}
image: {{ project_slug }}/backend
profiles: [migrate]
env_file:
- path: .env
required: false
- path: backend/.env
{% if layout == 'part' %} - path: backend/.env
required: false
environment:
{% endif %} environment:
RUN_ENVIRONMENT: prod
volumes:
- ./backend/src:/app/src
- ./backend/migrations:/app/migrations
- ./backend/alembic.ini:/app/alembic.ini
- ./{{ prefix }}src:/app/src
- ./{{ prefix }}migrations:/app/migrations
- ./{{ prefix }}alembic.ini:/app/alembic.ini
entrypoint: [alembic]
command: [upgrade, head]
depends_on: