https://github.com/nullstone-io/elixir-phoenix-quickstart
Elixir Phoenix Quickstart for Nullstone
https://github.com/nullstone-io/elixir-phoenix-quickstart
Last synced: 19 days ago
JSON representation
Elixir Phoenix Quickstart for Nullstone
- Host: GitHub
- URL: https://github.com/nullstone-io/elixir-phoenix-quickstart
- Owner: nullstone-io
- License: mit
- Created: 2022-05-05T02:26:56.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-08-18T14:54:13.000Z (almost 3 years ago)
- Last Synced: 2025-05-06T08:58:39.659Z (about 1 year ago)
- Language: Elixir
- Size: 58.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Elixir Phoenix Quickstart
This is a Elixir Phoenix Quickstart for [Nullstone](https://nullstone.io).
This is based off the official Phoenix [Up and Running](https://hexdocs.pm/phoenix/up_and_running.html) guide.
## How to launch via Nullstone
1. Create postgresql datastore.
2. Create a public web app. (Remember `app-name` for later)
3. Add the postgresql datastore (from step 1) to the app.
4. Add the `SECRET_KEY_BASE for Rails Cookies` capability to the app. (this capability works for Rails and Phoenix)
5. Provision
```shell
nullstone up --wait --block= --env=
```
6. Build, push, and deploy
```shell
docker build -t phoenix-quickstart .
nullstone launch --source=phoenix-quickstart --app= --env=
```
## How to run locally
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
### Hot reload
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.
### Update dependencies
However, when updating dependencies, you will need to restart your docker container.
The dependencies will be installed on boot of the docker container.
```shell
docker compose restart app
```
## Details about quickstart
This app was generated following these steps.
1. `mix phx.new --app=elixir_phoenix_quickstart .`
2. Change `config/dev.exs` to ensure local docker works:
```elixir
# 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")],
```
3. Change `config/dev.exs` to use env var for database url:
```elixir
# 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",
...
```
4. `mix phx.gen.release --docker`
5. 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 ./
```