Skip to content

Instantly share code, notes, and snippets.

@Faolain
Faolain / Flexible Dockerized Phoenix Deployments.md
Created November 18, 2018 07:40 — forked from jswny/Flexible Dockerized Phoenix Deployments.md
A guide to building and running zero-dependency Phoenix (Elixir) deployments with Docker. Works with Phoenix 1.2 and 1.3.

Prelude

I. Preface and Motivation

This guide was written because I don't particularly enjoy deploying Phoenix (or Elixir for that matter) applications. It's not easy. Primarily, I don't have a lot of money to spend on a nice, fancy VPS so compiling my Phoenix apps on my VPS often isn't an option. For that, we have Distillery releases. However, that requires me to either have a separate server for staging to use as a build server, or to keep a particular version of Erlang installed on my VPS, neither of which sound like great options to me and they all have the possibilities of version mismatches with ERTS. In addition to all this, theres a whole lot of configuration which needs to be done to setup a Phoenix app for deployment, and it's hard to remember.

For that reason, I wanted to use Docker so that all of my deployments would be automated and reproducable. In addition, Docker would allow me to have reproducable builds for my releases. I could build my releases on any machine that I wanted in a contai

@Faolain
Faolain / phoenix_to_umbrella
Created March 15, 2018 16:35 — forked from emilsoman/phoenix_to_umbrella
How to move an existing phoenix app under an umbrella app
How to convert existing phoenix app to an umbrella app.
https://elixir-lang.slack.com/archives/phoenix/p1472921051000134
chrismccord [10:14 PM]
@alanpeabody yes, it's straightforward
[10:14]
1) mix new my_umbrella --umbrella
#Docker Container Logs
4/23/2017 9:29:13 PM Node 'hello@10.42.69.252' not responding to pings.
4/23/2017 9:29:14 PM Node 'hello@10.42.69.252' not responding to pings.
4/23/2017 9:29:14 PM Node 'hello@10.42.69.252' not responding to pings.
4/23/2017 9:29:15 PM Node 'hello@10.42.69.252' not responding to pings.
4/23/2017 9:29:16 PM 01:29:16.104 [info] Running Hello.Endpoint with Cowboy using http://localhost:8080
4/23/2017 9:29:16 PM Connecting to phoenix: [{10, 42, 69, 252}]
4/23/2017 9:29:16 PM pong
4/23/2017 9:29:16 PM Application is up!
@Faolain
Faolain / seed.ex
Created April 23, 2017 03:58 — forked from jerel/seed.ex
Run seeds in an Elixir Distillery app
defmodule :release_tasks do
def seed do
:ok = Application.load(:myapp)
[:postgrex, :ecto, :logger]
|> Enum.each(&Application.ensure_all_started/1)
Myapp.Repo.start_link
@Faolain
Faolain / poolboy_demo.ex
Created January 16, 2017 05:37 — forked from henrik/poolboy_demo.ex
Example of using Poolboy in Elixir to limit concurrency (e.g. of HTTP requests).
defmodule HttpRequester do
use GenServer
def start_link(_) do
GenServer.start_link(__MODULE__, nil, [])
end
def fetch(server, url) do
# Don't use cast: http://blog.elixirsips.com/2014/07/16/errata-dont-use-cast-in-a-poolboy-transaction/
timeout_ms = 10_000