- Set
PHOENIX_DOCKER_GENERATORto the path of this folder, for example if it's at$HOME/repos/phx-docker-gen, then put this in your .{z,bash}rc file:export PHOENIX_DOCKER_GENERATOR=$HOME/repos/phx-docker - Then stick the file
gen-phxin your path. - Run
gen-phx appname; appname should be underscore-case format. The script changes"hostname"from"localhost"to"db"in config/dev.exs; it needs to match the database service named in docker-compose.yml, in this case it isdb.
For an existing project, follow steps 1 and 2 above and run gen-phx-existing inside the project folder. It will add the 3 Docker files (or overwrite them if they exist, adjust the script per your needs), set up the containers and run migrations.
Different than the above 2: https://medium.com/swlh/use-docker-to-create-an-elixir-phoenix-development-environment-e1a81def1d2e
See this for options to pass to mix phx.new: https://hexdocs.pm/phoenix/Mix.Tasks.Phx.New.html