Compare commits
2
Commits
v0.5.0
...
a5345a9e4c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5345a9e4c | ||
|
|
2be4367f9f |
No files matched your search
@@ -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
|
||||||
|
|||||||
@@ -17,4 +17,6 @@ make recreate
|
|||||||
|
|
||||||
{% if backend_services %}To deploy, `git pull && make deploy`. It runs `make pre-deploy`, which builds the image only when `pyproject.toml`, `uv.lock` or `Dockerfile` changed{% if database == 'postgres' %} and applies migrations{% endif %}, then `docker compose up -d`, then `make post-deploy`, which restarts the services whose mounted code changed. A deploy system with its own `up` step calls the two hooks around it. What was built and started is remembered as `refs/deploy/*` in the clone.
|
{% if backend_services %}To deploy, `git pull && make deploy`. It runs `make pre-deploy`, which builds the image only when `pyproject.toml`, `uv.lock` or `Dockerfile` changed{% if database == 'postgres' %} and applies migrations{% endif %}, then `docker compose up -d`, then `make post-deploy`, which restarts the services whose mounted code changed. A deploy system with its own `up` step calls the two hooks around it. What was built and started is remembered as `refs/deploy/*` in the clone.
|
||||||
|
|
||||||
|
In the fleet, production is deployed from `infra/komodo` instead (git mode of Komodo, see `docs/architecture.md` there): Komodo clones this repo, and a layer plus `deploy.sh` in the stack's directory tag images by the hash of what they bake in, write `.env` from sops and run migrations before the code. The repo only has to stay a plain recipe: images built from `build:` in compose, migrations as the `migrator` service when there is a database, `caddy/site.caddy`. `make deploy` and `refs/deploy/*` are for a checkout deployed by hand.
|
||||||
|
|
||||||
{% endif %}`make fmt` formats, `make check` runs ruff and ty.{% if targets %} Also {{ targets | join(", ") }}.{% endif %}
|
{% endif %}`make fmt` formats, `make check` runs ruff and ty.{% if targets %} Also {{ targets | join(", ") }}.{% endif %}
|
||||||
Reference in new issue
Block a user