Skip to content

d-led/d-zen

Repository files navigation

Dzen

To start your Phoenix server:

  • Install dependencies with mix deps.get
  • Start Postgres, e.g. via docker-compose up -d
  • Start Phoenix endpoint with mix phx.server or inside IEx with iex -S mix phx.server

Now you can visit localhost:4000 from your browser.

Ready to run in production? Please check our deployment guides.

Deployed

Deployed to Gigalixirhttps://red-dark-honeyeater.gigalixirapp.com

Log

  • Latest Elixir & Erlang installed
  • Gigalixir Docs
  • installed latest phoenix
    • mix local.hex
    • mix archive.install hex phx_new
  • created the app mix phx.new --no-ecto d-zen --app dzen
  • fetched the dependencies mix deps.get
  • local live-reloadable start: mix phx.server
  • registered & then logged into gigalixir: gigalixir login
  • created the app: APP_NAME=$(gigalixir create)
    • if not automatically set, gigalixir git:remote $APP_NAME
  • configured the versions
    • echo "elixir_version=1.13.3" > elixir_buildpack.config
    • echo "erlang_version=23.3.2" >> elixir_buildpack.config
    • echo "node_version=14.15.4" > phoenix_static_buildpack.config
  • deploy to gigalixir: git push gigalixir master
  • visit https://red-dark-honeyeater.gigalixirapp.com
  • added an Ecto Repo
    • mix ecto.create after all the required code changes
    • mix ecto.gen.migration create_counters to initialize the counters
  • created the free gigalixir DB tier: gigalixir pg:create --free

Changes

Learn more

Gigalixir Hands-On

IEx in the Container

docs

  • gigalixir account:ssh_keys:add "$(cat ~/.ssh/id_rsa.pub)" and wait a couple of minutes
  • gigalixir ps:remote_console

Resetting the DB

docs

# check the data
Dzen.Repo.all(Dzen.Counter)
# drop
Application.app_dir(:dzen, "priv/repo/migrations"), :down, [all: true])
# create
Ecto.Migrator.run(Dzen.Repo, Application.app_dir(:dzen, "priv/repo/migrations"), :up, [all: true])

Changing an Entity

# check the data
Dzen.Repo.all(Dzen.Counter)
# change the entity
Dzen.Repo.get_by(Dzen.Counter, id: 2)
|> Ecto.Changeset.change(%{value: 42})
|> Dzen.Repo.update()