ex_trainer/docker-compose.yml
Joao P Dubas 9be7566cbb
All checks were successful
continuous-integration/drone/push Build is passing
feat: execute service as distributed erlang (#96)
To create a cluster with distributed nodes, the following changes were made:

* Use [`dns_cluster`][0] to execute distributed nodes
* Add _script_ to execute distributed nodes locally

Also, improve local execution by:

* Use [`mix release`][1] to make easier [deploy `phoenix`][2]
* Use [`compose watch`][3] to synchronize code from the host with the service

Some minor improvements:

* Ignore files and folders in git and docker
* Remove boilerplate comments

[0]: https://github.com/phoenixframework/dns_cluster
[1]: https://hexdocs.pm/mix/Mix.Tasks.Release.html
[2]: https://hexdocs.pm/phoenix/releases.html
[3]: https://docs.docker.com/compose/how-tos/file-watch/

Co-authored-by: Joao P Dubas <joao.dubas@gmail.com>
Reviewed-on: #96
Co-authored-by: Joao P Dubas <joao.dubas+gitea@gmail.com>
Co-committed-by: Joao P Dubas <joao.dubas+gitea@gmail.com>
2024-09-22 18:56:27 +00:00

59 lines
1.4 KiB
YAML

---
services:
db:
image: 'postgres:16.4-alpine'
hostname: &db_host db
init: true
environment:
POSTGRES_USER: &db_user postgres
POSTGRES_PASSWORD: &db_pass postgres
POSTGRES_DB: postgres
volumes:
- './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:
target: builder
context: .
args:
BUILD_MIX_ENV: dev
hostname: &app_host ex_trainer
depends_on:
- db
init: true
develop:
watch:
- path: ./
ignore:
- ./build/
- ./deps/
target: /opt/app
action: sync
- path: ./config/
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
POSTGRES_USER: *db_user
POSTGRES_PASS: *db_pass
POSTGRES_NAME: wabanex_dev
working_dir: /opt/app
restart: unless-stopped
scale: 3
entrypoint: ./priv/docker/service/docker-entrypoint.sh
command: local-cookie
volumes:
db_data: {}