Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Elixir Releases

Elixir Releases

Getting Elxir deployed can be challenging. Especially if you want to do it the Erlang way. This talk provides some guidelines on what to take care of.

Leif Gensert

July 13, 2017
Tweet

More Decks by Leif Gensert

Other Decks in Programming

Transcript

  1. Elixir Releases

    View Slide

  2. View Slide

  3. The Way
    /app/*.rb
    /lib/*.rb
    Gemfile
    $ install requirements
    $ export RAILS_ENV=production
    $ bundle install
    $ bundle exec rails server

    View Slide

  4. gjaldon/heroku-buildpack-phoenix-static
    HashNuke/heroku-buildpack-elixir

    View Slide

  5. ?

    View Slide

  6. Build Run
    $ mix deps.get
    $ mix release
    $ _build/app start
    app.tar.gz:
    - Binaries
    - Erlang runtime (optional)
    - Sources (optional)

    View Slide

  7. Watch
    Out

    View Slide

  8. Build Run
    $ mix deps.get
    $ mix release —env=prod
    $ _build/app start
    app.tar.gz





    View Slide

  9. $ docker run image_that_is_like_runtime build.sh

    View Slide

  10. $ _build/app start
    ** (Postgrex.Error) ERROR
    42P01 (undefined_table):
    relation "users" does not
    exist



    View Slide

  11. $ mix ecto.migrate
    -bash: mix: command not
    found


    View Slide

  12. $ _build/app migrate
    $ _build/app start
    https://github.com/bitwalker/distillery/blob/master/docs/Running%20Migrations.md

    View Slide

  13. Configuration
    staging
    demo
    testing
    sandbox
    production

    View Slide

  14. use Mix.Config
    config :app, App.Repo, [
    database: "app",
    username: "user",
    password: "supersecret",
    hostname: “db-server”,
    port: 5432,
    ]
    {'Elixir.QualityControl.Repo',
    [{database,<>},
    {username,<>},
    {password,<>},
    {hostname,<>},
    {loggers,[]},
    {port,5433}]},
    config.exs
    sys.config

    View Slide

  15. use Mix.Config
    config :app, App.Repo, [
    database: "app",
    username: “user",
    password:
    System.get_env(“PG_PASS"),
    hostname: “db-server”,
    port: 5432,
    ]
    config.exs
    sys.config
    {'Elixir.QualityControl.Repo',
    [{database,<>},
    {username,<>},
    {password,nil},
    {hostname,<>},
    {loggers,[]},
    {port,5433}]},

    View Slide

  16. Replace Variables on Build System
    {:system, ENV, default}
    Check In Credentials
    REPLACE_OS_VARS=true
    Build Config Layer

    View Slide

  17. Why

    View Slide

  18. Because it's cool?

    View Slide

  19. Size
    300 MB 50 MB

    View Slide

  20. Resources

    View Slide

  21. Code Reload

    View Slide

  22. Comfortable

    View Slide

  23. Start Early
    Think About Config
    Use Distillery

    View Slide