From 3a0bc3621fd7581ab3d5ff0046cb180f6b3a7737 Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Wed, 30 Apr 2025 17:19:18 +0000 Subject: [PATCH] chore: improve compose for git worktree (#142) * 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: https://gitea.dubas.dev/joao.dubas/ex_trainer/pulls/142 Co-authored-by: Joao P Dubas Co-committed-by: Joao P Dubas --- Makefile | 2 +- docker-compose.yml | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index e54935a..e6a4f12 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index fe914b2..98cc027 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: