This is a Elixir Phoenix Quickstart for Nullstone. This is based off the official Phoenix Up and Running guide.
- Create postgresql datastore.
- Create a public web app. (Remember
app-name
for later) - Add the postgresql datastore (from step 1) to the app.
- Add the
SECRET_KEY_BASE for Rails Cookies
capability to the app. (this capability works for Rails and Phoenix) - Provision
nullstone up --wait --block=<app-name> --env=<env-name>
- Build, push, and deploy
docker build -t phoenix-quickstart .
nullstone launch --source=phoenix-quickstart --app=<app-name> --env=<env-name>
You can run this project locally inside Docker or using elixir alone.
To use docker, this project contains docker-compose.yml
that runs with MIX_ENV=dev
.
This setup ensures that using Docker doesn't inhibit typical development workflows:
- Hot reload is configured so that changes to the app doesn't require a reboot
- Dependencies are installed on boot of docker container
The app
in docker-compose.yml
is configured to automatically reload changes to files.
You do not need to rebuild/restart the phoenix app when making changes to code.
However, when updating dependencies, you will need to restart your docker container. The dependencies will be installed on boot of the docker container.
docker compose restart app
This app was generated following these steps.
mix phx.new --app=elixir_phoenix_quickstart .
- Change
config/dev.exs
to ensure local docker works:
# Binding to loopback ipv4 address prevents access from other machines.
# Change to `ip: {0, 0, 0, 0}` to allow access from other machines.
http: [ip: {0, 0, 0, 0}, port: String.to_integer(System.get_env("PORT") || "9000")],
- Change
config/dev.exs
to use env var for database url:
# Configure your database
config :elixir_phoenix_quickstart, ElixirPhoenixQuickstart.Repo,
url: System.get_env("DATABASE_URL"),
# username: "postgres",
# password: "postgres",
# hostname: "localhost",
# database: "elixir_phoenix_quickstart_dev",
...
mix phx.gen.release --docker
- Replace final stage of
Dockerfile
FROM nullstone/phoenix
# Only copy the final release from the build stage
COPY --from=builder /app/_build/${MIX_ENV}/rel/elixir_phoenix_quickstart ./