feat: execute service as distributed erlang (#96)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
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>
This commit is contained in:
@@ -7,59 +7,52 @@ services:
|
||||
environment:
|
||||
POSTGRES_USER: &db_user postgres
|
||||
POSTGRES_PASSWORD: &db_pass postgres
|
||||
POSTGRES_DB: &db_name 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: &app_image 'joaodubas/ex_trainer:${EX_TRAINER_TAG:-dev}'
|
||||
image: 'joaodubas/ex_trainer:${EX_TRAINER_TAG:-dev}'
|
||||
build:
|
||||
target: builder
|
||||
context: .
|
||||
hostname: app
|
||||
args:
|
||||
BUILD_MIX_ENV: dev
|
||||
hostname: &app_host ex_trainer
|
||||
depends_on:
|
||||
- db
|
||||
init: true
|
||||
environment: &app_environment
|
||||
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
|
||||
volumes: &app_volumes
|
||||
- '.:/opt/app'
|
||||
- 'app_build:/opt/app/_build'
|
||||
- 'app_deps:/opt/app/deps'
|
||||
working_dir: /opt/app
|
||||
restart: unless-stopped
|
||||
entrypoint: sleep
|
||||
command: infinity
|
||||
db_setup:
|
||||
image: *app_image
|
||||
depends_on:
|
||||
- db
|
||||
profiles:
|
||||
- setup
|
||||
environment: *app_environment
|
||||
volumes: *app_volumes
|
||||
restart: 'no'
|
||||
command: |
|
||||
mix ecto.setup \
|
||||
&& MIX_ENV=test mix ecto.setup
|
||||
db_migrate:
|
||||
image: *app_image
|
||||
depends_on:
|
||||
- db
|
||||
profiles:
|
||||
- migrate
|
||||
environment: *app_environment
|
||||
volumes: *app_volumes
|
||||
restart: 'no'
|
||||
command: |
|
||||
mix ecto.migrate \
|
||||
&& MIX_ENV=test mix.ecto.migrate
|
||||
scale: 3
|
||||
entrypoint: ./priv/docker/service/docker-entrypoint.sh
|
||||
command: local-cookie
|
||||
|
||||
volumes:
|
||||
db_data: {}
|
||||
app_build: {}
|
||||
app_deps: {}
|
||||
|
Reference in New Issue
Block a user