mkdir <app_dir> && cd <app_dir>
FROM elixir:latest RUN apt-get update -qq && apt-get install -y libpq-dev && apt-get install -y build-essential inotify-tools erlang-dev erlang-parsetools apt-transport-https ca-certificates && apt-get update && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && apt-get update && apt-get install --no-install-recommends yarn RUN mix local.hex --force && mix local.rebar --force RUN mix archive.install hex phx_new 1.4.0 --force RUN curl -sL https://deb.nodesource.com/setup_11.x | bash - && apt-get install -y nodejs WORKDIR /home/app
version: '3' services: web: build: . command: mix phx.server volumes: - .:/home/app ports: - "4000:4000" links: - db depends_on: - db test: image: <app_dir>_web command: mix test environment: MIX_ENV: test PORT: 4001 volumes: - .:/home/app db: image: postgres:latest ports: - '5432:5432' environment: POSTGRES_USER: <db_user> POSTGRES_PASSWORD: <db_user_password>
docker-compose run web mix phx.new . --app <app_name>
sudo chown -R $USER:$USER .
# Configure your database config :<app_name>, <App_name>.Repo, username: <db_user>, password: <db_user_password>, database: <app_name>_dev, hostname: "db", pool_size: 10
# Configure your database config :<app_name>, <App_name>.Repo, username: <db_user>, password: <db_user_password>, database: <app_name>_test, hostname: "db", pool_size: 10
docker-compose run web mix ecto.create
docker-compose run test mix ecto.create
docker-compose up -d
docker-compose run test
docker-compose run test mix test test/<app_name>_web/controllers/page_controller_test.exs
Source: https://habr.com/ru/post/439718/