chore: improve compose for git worktree (#142)
All checks were successful
continuous-integration/drone/push Build is passing

* Avoid multiple project names in `docker compose` by setting a common name.
* Simplify `develop` watch rules:
  * When `mix.lock` is changed, rebuild the image.
  * When any other file is changed, sync and restart the service.
    * Except for directories that are related to deps/build/test/lsp.
* Remove `file` argument from `docker compose` in `Makefile`

Reviewed-on: #142
Co-authored-by: Joao P Dubas <joao.dubas+gitea@gmail.com>
Co-committed-by: Joao P Dubas <joao.dubas+gitea@gmail.com>
This commit is contained in:
João Paulo Dubas 2025-04-30 17:19:18 +00:00 committed by João Paulo Dubas
parent d4299d4d7a
commit 3a0bc3621f
2 changed files with 10 additions and 12 deletions

View File

@ -1,6 +1,6 @@
.DEFAULT_GOAL := help
COMPOSE = docker compose -f docker-compose.yml -f docker-compose.override.yml
COMPOSE = docker compose
.PHONY: system_setup
system_setup: ## setup system deps

View File

@ -1,4 +1,6 @@
---
name: ${EX_TRAINER_PROJECT_NAME:-ex_trainer}
services:
db:
image: 'postgres:17.4-alpine'
@ -12,6 +14,7 @@ services:
- './priv/docker/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql'
- 'db_data:/var/lib/postgresql/data'
restart: unless-stopped
app:
image: 'joaodubas/ex_trainer:${EX_TRAINER_TAG:-dev}'
build:
@ -26,23 +29,17 @@ services:
init: true
develop:
watch:
- path: ./mix.lock
action: rebuild
- path: ./
ignore:
- ./build/
- ./deps/
target: /opt/app
action: sync
- path: ./config/
- ./.elixir_ls/
- ./cover/
- ./report/
target: /opt/app
action: sync+restart
- path: ./lib/wabanex/application.ex
target: /opt/app
action: sync+restart
- path: ./mix.exs
target: /opt/app
action: sync+restart
- path: ./mix.lock
action: rebuild
environment:
DNS_CLUSTER_QUERY: *app_host
POSTGRES_HOST: *db_host
@ -54,6 +51,7 @@ services:
scale: 3
entrypoint: ./priv/docker/service/docker-entrypoint.sh
command: local-cookie
test:
image: 'joaodubas/ex_trainer:test'
build: