From 010f56acf283c470c54359bc365cb1790a119c5c Mon Sep 17 00:00:00 2001 From: JohanBaskovec Date: Tue, 22 Oct 2019 22:16:18 +0200 Subject: [PATCH] Fix error when running `make` / `docker-compose up` This fixes an error when running the mobilizon_api container (either with `make` or `docker-compose up`): the command `mix phx.server` was run first in the mobilizon_api container, but it made the container restart every ~10 seconds because of missing dependencies errors. As a result it became impossible to install the depencies using `docker-compose exec api sh -c "cd js && yarn install && cd ../"`, because that would give this error: `Error response from daemon: Container 8ff288ad74565bb0773f9b5f8fb39ab62925c16ea0ca77c5d2579cc3013a8464 is restarting, wait until the container is running`. This commit fixes this error by running the dependency installation commands (and compilation and db migration) before `mix phx.server`. --- Makefile | 5 ----- docker-compose.yml | 10 +++++++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index f4e610f77..7f7cda3c9 100644 --- a/Makefile +++ b/Makefile @@ -5,11 +5,6 @@ init: start: stop @bash docker/message.sh "starting Mobilizon with docker" docker-compose up -d api - docker-compose exec api sh -c "cd js && yarn install && cd ../" - docker-compose exec api mix deps.get - docker-compose exec api mix compile - docker-compose exec api mix ecto.create - docker-compose exec api mix ecto.migrate @bash docker/message.sh "started" stop: @bash docker/message.sh "stopping Mobilizon" diff --git a/docker-compose.yml b/docker-compose.yml index 99e57ea55..caa767380 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,7 +30,15 @@ services: MOBILIZON_DATABASE_USERNAME: postgres MOBILIZON_DATABASE_DBNAME: mobilizon_dev MOBILIZON_DATABASE_HOST: postgres - command: "mix phx.server" + command: > + sh -c "cd js && + yarn install && + cd ../ && + mix deps.get && + mix compile && + mix ecto.create && + mix ecto.migrate && + mix phx.server" volumes: pgdata: .: