refactor: drop make deploy, the fleet deploys from infra/komodo; short readme
This commit is contained in:
1 parent
940a599515
commit
74abd9c592
3 files changed
+7
-36
No files matched your search
@@ -1,24 +1,6 @@
|
|||||||
# infra
|
# infra
|
||||||
|
|
||||||
Copier template for the root of a project. With `layout: parts` it ships a `docker-compose.yml` that includes every part, a `Makefile` that drives compose and delegates `fmt`, `check` and `build` to parts, a `README.md` and an `.env.example` whose `COMPOSE_FILE` adds each part's `docker-compose.override.yml` and whose `COMPOSE_PROFILES` selects what runs on the machine. With `layout: single` a part template renders straight into the root and infra ships only `.gitignore`, `CLAUDE.md` and pre-commit hooks.
|
Copier template for the root of a project: compose that includes every part, a Makefile that delegates to parts, `.gitignore`, `CLAUDE.md`, pre-commit hooks and `renovate.jsonc`. A part is a directory with `docker-compose.yml` (profiles per service: `services` for the app, `external` for databases), `docker-compose.override.yml.example`, a Makefile with `fmt`, `check`, `build` and `.env.example`.
|
||||||
|
|
||||||
A part is a directory with:
|
|
||||||
|
|
||||||
- `docker-compose.yml` with root-relative paths and a profile per service, plus `docker-compose.override.yml.example` for what differs between machines
|
|
||||||
- `Makefile` with `fmt`, `check` and `build` targets
|
|
||||||
- `.env.example` appended to the root `.env` by `make env`
|
|
||||||
- `CLAUDE.md` with the part's checking commands
|
|
||||||
|
|
||||||
Application services carry the `services` profile, databases and other infrastructure carry `external`.
|
|
||||||
|
|
||||||
`mcp_servers` writes `.mcp.json` with the Context7 and Svelte docs servers.
|
|
||||||
|
|
||||||
The root also gets a `renovate.jsonc` that is nothing but an `extends` on the
|
|
||||||
shared preset in `templates/renovate`. It does not subscribe the repo to
|
|
||||||
anything on its own: the bot walks an explicit list, so a new repo still has to
|
|
||||||
be added to `repositories` in `projects/personal/renovate/renovate-config.js`
|
|
||||||
of `infra/komodo`, and needs the `renovate`, `wait-3d` and `deps-code` labels
|
|
||||||
(`giteaproject <org>/<repo>` creates them).
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
copier copy --trust -d layout=parts -d 'parts=["backend","frontend"]' <this-repo> <dest>
|
copier copy --trust -d layout=parts -d 'parts=["backend","frontend"]' <this-repo> <dest>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
PARTS := $(patsubst %/Makefile,%,$(wildcard */Makefile))
|
PARTS := $(patsubst %/Makefile,%,$(wildcard */Makefile))
|
||||||
|
|
||||||
.PHONY: env recreate rebuild restart logs down deploy fmt check build pre-deploy post-deploy
|
.PHONY: env recreate rebuild restart logs down fmt check build
|
||||||
|
|
||||||
env:
|
env:
|
||||||
@fresh=; test -f .env || { awk 'FNR == 1 && NR > 1 { print "" } 1' .env.example $(addsuffix /.env.example,$(PARTS)) > .env; fresh=1; }; \
|
@fresh=; test -f .env || { awk 'FNR == 1 && NR > 1 { print "" } 1' .env.example $(addsuffix /.env.example,$(PARTS)) > .env; fresh=1; }; \
|
||||||
@@ -30,9 +30,5 @@ logs:
|
|||||||
down:
|
down:
|
||||||
docker compose down
|
docker compose down
|
||||||
|
|
||||||
deploy: pre-deploy
|
fmt check build:
|
||||||
docker compose up -d
|
|
||||||
$(MAKE) post-deploy
|
|
||||||
|
|
||||||
fmt check build pre-deploy post-deploy:
|
|
||||||
@for part in $(PARTS); do $(MAKE) -C $$part $@ || exit 1; done
|
@for part in $(PARTS); do $(MAKE) -C $$part $@ || exit 1; done
|
||||||
@@ -2,17 +2,10 @@
|
|||||||
{% if project_description and project_description != project_name %}
|
{% if project_description and project_description != project_name %}
|
||||||
{{ project_description }}
|
{{ project_description }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
Runs in Docker, locally the same way as in production. Each part in `{{ parts | join('/`, `') }}/` brings its own `docker-compose.yml`, included from the root one. `COMPOSE_PROFILES` in `.env` selects the services that run on this machine. `docker-compose.override.yml` in each part holds what differs between machines: published ports and the aliases on the external `caddy` network.
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make env
|
make env # .env and docker-compose.override.yml from the examples
|
||||||
make recreate
|
make recreate # the services in COMPOSE_PROFILES
|
||||||
|
make check
|
||||||
```
|
```
|
||||||
|
|
||||||
`make env` creates `.env` from the examples of every part and copies each `docker-compose.override.yml.example`. `make recreate` starts the selected profiles, `make rebuild` builds the images first, `make logs`, `make restart` and `make down` do what they say.
|
Parts: `{{ parts | join('/`, `') }}/`, each with its own Makefile.
|
||||||
|
|
||||||
To deploy, `git pull && make deploy`. It runs `make pre-deploy` in every part, which builds images only when their inputs changed and applies migrations, 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.
|
|
||||||
|
|
||||||
`make fmt`, `make check` and `make build` run in every part. Part-specific targets live in the part's own Makefile: `make -C {{ parts[0] }} ...`.
|
|
||||||
Reference in new issue
Block a user