From 7b23ca69653cd4ae5e68bf9a479ff7e44739dcbe Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 16 Oct 2019 11:12:42 +0200 Subject: [PATCH 1/2] Improve docker setup Signed-off-by: Thomas Citharel --- Dockerfile | 2 +- Makefile | 7 ++++++- docker-compose.yml | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index a37e586dc..c90b043b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,4 +7,4 @@ RUN mix local.hex --force && mix local.rebar --force WORKDIR /app -EXPOSE 4000 4001 4002 +EXPOSE 4000 diff --git a/Makefile b/Makefile index b874b19b4..f4e610f77 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,12 @@ init: start: stop @bash docker/message.sh "starting Mobilizon with docker" - docker-compose up -d + 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 c6904c86b..99e57ea55 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,7 +30,7 @@ services: MOBILIZON_DATABASE_USERNAME: postgres MOBILIZON_DATABASE_DBNAME: mobilizon_dev MOBILIZON_DATABASE_HOST: postgres - command: "mix phx.deps_migrate_serve" + command: "mix phx.server" volumes: pgdata: .: From 4938f853d50ad2edd89abb5cd95578696dbe7ef2 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 16 Oct 2019 11:20:30 +0200 Subject: [PATCH 2/2] Improve docs a bit Signed-off-by: Thomas Citharel --- support/guides/development/development.md | 2 +- support/guides/development/tests.md | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/support/guides/development/development.md b/support/guides/development/development.md index b1fca76d5..56a9cb14e 100644 --- a/support/guides/development/development.md +++ b/support/guides/development/development.md @@ -39,4 +39,4 @@ Just run : ```bash make start ``` -to build and launch a database container and an API container running on localhost. +to build and launch a database container and an API container running on `localhost:4000`. diff --git a/support/guides/development/tests.md b/support/guides/development/tests.md index 003a01d3b..bb46b2f97 100644 --- a/support/guides/development/tests.md +++ b/support/guides/development/tests.md @@ -9,6 +9,8 @@ To launch all the tests: mix test ``` +> If you're using Docker, you can use `make test` + If you want test coverage: ```bash @@ -41,6 +43,11 @@ Not done yet. We use [Cypress](https://cypress.io) for End-to-end testing. +You first need to run the webserver with the `e2e` environment: `MIX_ENV=e2e mix phx.server`. The same environment parameters as the `dev` environment must be provided. +This allows to run database operations in the sandbox and not pollute your database. + +Then, run `MIX_ENV=e2e mix run priv/repo/e2e.seed.exs` to have some initial data inside your instance for the tests. + When inside the `js` directory, you can do either ```bash npx cypress run