fix(deploy): postgres in the project, no restart on an empty list, image named with dashes #1

Merged
hh merged 2 commits from deploy-scheme into main 2026-10-08 18:46:03 +00:00
2 changed files with 5 additions and 5 deletions
Showing only changes of commit 2be4367f9f - Show all commits

No files matched your search

+3 -3
View File
@@ -13,7 +13,7 @@
{%- set has_script = dynamic_config and svc_modules -%} {%- set has_script = dynamic_config and svc_modules -%}
{%- set has_scripts = dynamic_config or 'kurigram_userbot' in backend_services -%} {%- set has_scripts = dynamic_config or 'kurigram_userbot' in backend_services -%}
COMPOSE := {% if layout == 'part' %}cd .. && {% endif %}docker compose COMPOSE := {% if layout == 'part' %}cd .. && {% endif %}docker compose
{% if svc_modules %}IMAGE := {{ project_slug }}/backend {% if svc_modules %}IMAGE := {{ project_slug | replace('_', '-') }}/backend
IMAGE_INPUTS := pyproject.toml uv.lock Dockerfile IMAGE_INPUTS := pyproject.toml uv.lock Dockerfile
CODE := src{% if has_scripts %} scripts{% endif %}{% if serve_spa %} ../frontend{% endif %} CODE := src{% if has_scripts %} scripts{% endif %}{% if serve_spa %} ../frontend{% endif %}
SERVICES := {{ app_services | join(' ') }} SERVICES := {{ app_services | join(' ') }}
@@ -39,13 +39,13 @@ pre-deploy:
@if $(call changed,refs/deploy/backend,$(IMAGE_INPUTS)) || ! docker image inspect $(IMAGE) >/dev/null 2>&1; then \ @if $(call changed,refs/deploy/backend,$(IMAGE_INPUTS)) || ! docker image inspect $(IMAGE) >/dev/null 2>&1; then \
$(MAKE) build && $(call stamp,refs/deploy/backend) && $(call stamp,refs/deploy/backend-code); \ $(MAKE) build && $(call stamp,refs/deploy/backend) && $(call stamp,refs/deploy/backend-code); \
fi fi
{% if database == 'postgres' %} @$(COMPOSE) config --services | grep -qx postgres && $(COMPOSE) up -d postgres || true {% if database == 'postgres' %} @if ($(COMPOSE) config --services) | grep -qx postgres; then ($(COMPOSE) up -d --wait postgres); fi
$(MAKE) migrate $(MAKE) migrate
{% endif %} {% endif %}
post-deploy: post-deploy:
@if $(call changed,refs/deploy/backend-code,$(CODE)); then \ @if $(call changed,refs/deploy/backend-code,$(CODE)); then \
running=$$($(COMPOSE) ps --services --status running | grep -x $(addprefix -e ,$(SERVICES))); \ running=$$($(COMPOSE) ps --services --status running | grep -x $(addprefix -e ,$(SERVICES))); \
[ -z "$$running" ] || $(COMPOSE) restart $$running; \ if [ -n "$$running" ]; then ($(COMPOSE) restart $$running); fi; \
$(call stamp,refs/deploy/backend-code); \ $(call stamp,refs/deploy/backend-code); \
fi fi
{% endif %}{% if layout == 'root' %} {% endif %}{% if layout == 'root' %}
@@ -14,7 +14,7 @@
{%- if 'scheduler' in backend_services %}{% set _ = app_services.append({'name': 'scheduler', 'command': ('[worker, scheduler]' if 'taskiq_worker' in backend_services else '[scheduler]')}) %}{% 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 }}: {%- macro backend_service(name, command) %} {{ name }}:
build: {{ part_dir }} build: {{ part_dir }}
image: {{ project_slug }}/backend image: {{ project_slug | replace('_', '-') }}/backend
profiles: [{{ name }}, services] profiles: [{{ name }}, services]
restart: unless-stopped restart: unless-stopped
env_file: env_file:
@@ -87,7 +87,7 @@ services:
migrator: migrator:
build: {{ part_dir }} build: {{ part_dir }}
image: {{ project_slug }}/backend image: {{ project_slug | replace('_', '-') }}/backend
profiles: [migrate] profiles: [migrate]
env_file: env_file:
- path: .env - path: .env