SlideShare a Scribd company logo
Brien Wankel brien@labzero.com
Deploying Elixir and Phoenix Applications
There is no cure-all.
Choose the right cure for your particular ailment.
Basic deploy workflow
4
Code Build Deploy
Docker
1
https://www.docker.com/
Docker
Software container platform
7
docker
Code Build Deploy
Docker *
Dockerfile
Elixir with distillery release
FROM bitwalker/alpine-elixir:latest
# Set exposed ports
EXPOSE 5000
ENV PORT=5000
ENV MIX_ENV=prod
ADD yourapp.tar.gz ./
RUN tar -xzvf yourapp.tar.gz
USER default
CMD ./bin/yourapp foreground
Dockerfile
Elixir with Phoenix
FROM bitwalker/alpine-elixir-phoenix:latest
# Build Environment
ARG MIX_ENV
ENV MIX_ENV ${MIX_ENV:-prod}
ARG DB_PASSWORD
ENV DB_PASSWORD ${DB_PASSWORD:-nopassword}
# Set exposed ports
EXPOSE 4000
ENV PORT=4000
# Cache elixir deps
ADD mix.exs mix.lock ./
RUN mix do deps.get, deps.compile
# Same with npm deps
ADD package.json package.json
RUN npm install
# Continued on next slide
Dockerfile
Elixir with Phoenix (cont)
# continued from previous slide
ADD . .
# Run frontend build, compile, and digest assets
RUN brunch build --production && 
mix do compile, phoenix.digest
CMD ["mix", "phoenix.server"]
Building the image
docker build --build-arg MIX_ENV=develop 
--build-arg DB_PASSWORD=$DB_PASSWORD 
-t myrepository/myapp:latest .
Deploy as you please
Running tests
Running migrations
docker run myrepository/myapp:latest mix test
docker run myrepository/myapp:latest mix ecto.migrate
Use environment variables with caution!
Distillery and edeliver
2
https://github.com/bitwalker/distillery
Distillery
Packaging functionality for the Erlang VM
17
Code Build Deploy
distillery
https://github.com/boldpoker/edeliver
Edeliver
Deployment for Erlang and Elixir
19
Code Build Deploy
distillery
edeliver
Installation
mix.exs
# mix.exs
defmodule Clippyx.Mixfile do
use Mix.Project
def project do
[app: :clippyx,
version: "0.0.1",
elixir: "~> 1.4",
deps: deps()]
end
def application do
[applications: [
:logger,
:edeliver # IMPORTANT!
],
mod: {Clippyx, []}]
end
defp deps do
[
{:edeliver, "~> 1.4"},
{:distillery, "~> 1.2", warn_missing: false}
]
end
end
Configuration
Distillery
# rel/config.exs
use Mix.Releases.Config,
default_release: :clippyx,
default_environment: :dev
environment :dev do
set dev_mode: true
set include_erts: true
end
environment :prod do
set include_erts: true
set include_src: false
end
release :clippyx do
set version: current_version(:clippyx)
end
release :utils do
set version: "0.0.1"
set applications: [:application1, :application2]
end
Configuration
Edeliver
.deliver/config
#!/usr/bin/env bash
APP="clippyx" # name of your release
BUILD_HOST="build.myapp.com"
BUILD_USER="ubuntu"
BUILD_AT="/tmp/edeliver/clippyx/builds"
STAGING_HOSTS ="s1.stg.myapp.com s2.stg.myapp.com"
STAGING_USER ="ubuntu"
PRODUCTION_HOSTS ="s1.prd.myapp.com s2.prd.myapp.com"
PRODUCTION_USER ="ubuntu"
DELIVER_TO="/home/web"
Environment
Variables
# config/config.exs
use Mix.Config
config :clippyx, Clippyx.Robot,
adapter: Hedwig.Adapters.Console,
name: "clippy",
...
config :hedwig_github,
github_access_token: System.get_env("GITHUB_TOKEN")
config :hedwig_wunderground,
wunderground_token: System.get_env("WUNDERGRND_TKN")
config :mopidy, api_url: System.get_env("MOPIDY_API_URL")
# "${MOPIDY_API_URL}"
import_config "#{Mix.env}.exs"
A bit more setup
24
Local Host / CI Host
Setup SSH keys
Remote Build Host
● OTP
● Elixir
● git
● build-essential
● libssl-dev
Remote Deploy Targets
● NOTHING!
Build a release
$ mix edeliver build release
BUILDING RELEASE OF CLIPPYX APP ON BUILD HOST
-----> Authorizing hosts
-----> Ensuring hosts are ready to accept git pushes
warning: more than one branch.master.remote
-----> Pushing new commits with git to:
ubuntu@ec2...us-west-2.compute.amazonaws.com
-----> Resetting remote hosts to
79e8c15c8b35803924c6658dc8ec2941637d80a7
-----> Cleaning generated files from last build
-----> Fetching / Updating dependencies
-----> Compiling sources
-----> Generating release
-----> Copying release 0.1.0 to local release store
-----> Copying clippyx.tar.gz to release store
RELEASE BUILD OF CLIPPYX WAS SUCCESSFUL!
$ mix edeliver build upgrade --from=<git tag or revision>
Deploy a release
$ mix edeliver deploy release to production
DEPLOYING RELEASE OF CLIPPYX APP TO PRODUCTION HOSTS
-----> Authorizing hosts
-----> Uploading archive of release 0.1.0 from local release
store
-----> Extracting archive clippyx_0.1.0.tar.gz
DEPLOYED RELEASE TO PRODUCTION!
RELEASE BUILD OF CLIPPYX WAS SUCCESSFUL!
$ mix edeliver upgrade production
Administration
$ mix edeliver start production
EDELIVER CLIPPYX WITH START COMMAND
-----> starting production servers
production node:
user : ubuntu
host :
ec2-54-202-189-109.us-west-2.compute.amazonaws.com
path : /home/web
response: success
START DONE!
$ mix edeliver update production --start-release
Administration
mix edeliver stop production
mix edeliver restart production
mix edeliver ping production
mix edeliver version production
mix edeliver show migrations on production
mix edeliver migrate production
Things to look out for
● Distillery 1.0+ output_dir
● Race condition on slow hosts
Lab Zero Innovations Inc.
77 Battery Street
San Francisco, CA 94111
415.839.6861
info@labzero.com
Brien Wankel brien@labzero.com
@brienwankel
Thank you. Questions?
More info:
Distillery https://github.com/bitwalker/distillery)
Edeliver https://github.com/boldpoker/edeliver)

More Related Content

PDF
Przemysław Iwanek - ABC AWS, budowanie infrastruktury przy pomocy Terraform
PPTX
Docker Ecosystem: Part V - Docker Registry
PDF
Web scale infrastructures with kubernetes and flannel
PDF
Docker command
PPTX
CoreOS in a Nutshell
PDF
Investigation of testing with ansible
PDF
How to create your own hack environment
PDF
Testing your infrastructure with litmus
Przemysław Iwanek - ABC AWS, budowanie infrastruktury przy pomocy Terraform
Docker Ecosystem: Part V - Docker Registry
Web scale infrastructures with kubernetes and flannel
Docker command
CoreOS in a Nutshell
Investigation of testing with ansible
How to create your own hack environment
Testing your infrastructure with litmus

What's hot (20)

PDF
CoreOS + Kubernetes @ All Things Open 2015
PDF
Ansible-for-openstack
PDF
Vagrant for real (codemotion rome 2016)
PPTX
Docker SDN (software-defined-networking) JUG
PDF
Ansible Crash Course
PDF
BitTorrent on iOS
PDF
Drone your Ansible
PDF
Deep drive into Nova
PPTX
Building a Docker v1.12 Swarm cluster on ARM
PDF
Docker deploy
PDF
Provisioning & Deploying with Docker
PDF
Ansible is the simplest way to automate. SymfonyCafe, 2015
PDF
Docker up and running
PDF
Learning kubernetes
PDF
Docker remote-api
PDF
Docker orchestration using core os and ansible - Ansible IL 2015
PPTX
Docker ansible-make-chef-puppet-unnecessary-minnihan
PDF
Dockerizing Symfony Applications - Symfony Live Berlin 2014
 
PDF
어릴 적 할머니가 들려주신 옛 wsgi
PDF
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
CoreOS + Kubernetes @ All Things Open 2015
Ansible-for-openstack
Vagrant for real (codemotion rome 2016)
Docker SDN (software-defined-networking) JUG
Ansible Crash Course
BitTorrent on iOS
Drone your Ansible
Deep drive into Nova
Building a Docker v1.12 Swarm cluster on ARM
Docker deploy
Provisioning & Deploying with Docker
Ansible is the simplest way to automate. SymfonyCafe, 2015
Docker up and running
Learning kubernetes
Docker remote-api
Docker orchestration using core os and ansible - Ansible IL 2015
Docker ansible-make-chef-puppet-unnecessary-minnihan
Dockerizing Symfony Applications - Symfony Live Berlin 2014
 
어릴 적 할머니가 들려주신 옛 wsgi
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Ad

Viewers also liked (19)

PDF
Revisión de rinitis: ARIA y Guía ARIA México
PDF
PDF
Gdz matematika ister_2013_zoshit
PDF
PPTX
Presentation on csr
PPTX
P4 to OpenDataPlane Compiler - BUD17-304
DOC
Стандартний запис числа
DOCX
Evaluación de Tres Tipos de Enraizantes en Estaquillas de Mussaenda
PDF
La “Marca Canadiense”: La violencia y las compañías mineras canadienses en Am...
DOCX
Historia Real y Verdadera, Bullying, Sociedad, Humanidad, Gente, Arte, Photog...
PPTX
Disaster management@akshay kumar
PPTX
Stone ppt by akshay
PPTX
Feng shui money frog
PDF
Gdz ruskiy pashkovskaya
PDF
Gdz nimecka sotnikova_2013
PPTX
Gece görüş si̇stemleri̇ - Barış Danacıoğlu
PPTX
Sigilografía y Diplomática
PDF
Panini. Novedades Marvel mayo 2017
PDF
Topic Modeling Edgar Allen Poe
Revisión de rinitis: ARIA y Guía ARIA México
Gdz matematika ister_2013_zoshit
Presentation on csr
P4 to OpenDataPlane Compiler - BUD17-304
Стандартний запис числа
Evaluación de Tres Tipos de Enraizantes en Estaquillas de Mussaenda
La “Marca Canadiense”: La violencia y las compañías mineras canadienses en Am...
Historia Real y Verdadera, Bullying, Sociedad, Humanidad, Gente, Arte, Photog...
Disaster management@akshay kumar
Stone ppt by akshay
Feng shui money frog
Gdz ruskiy pashkovskaya
Gdz nimecka sotnikova_2013
Gece görüş si̇stemleri̇ - Barış Danacıoğlu
Sigilografía y Diplomática
Panini. Novedades Marvel mayo 2017
Topic Modeling Edgar Allen Poe
Ad

Similar to Lab Zero Lunchdown: Deploying Elixir and Phoenix Applications (20)

PPTX
Docker & Elixir @kloeckner.i
PDF
Messaging with the Docker
PPTX
Phoenix 1.3 Umbrella App deployment via Distillery-Docker-Docker_Compose
PDF
Dockercon EU 2014
PPTX
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
PDF
How to automate elixir phoenix deployment with distillery and edeliver on ubu...
PDF
Elixir Deployment Tools
PDF
Hot deployments with distillery
PDF
Unleashing Docker with Pipelines in Bitbucket Cloud
PPTX
Docker Meetup Paris: enterprise Docker
PPTX
Ruby on Rails and Docker - Why should I care?
PPTX
Docker Ecosystem on Azure
PDF
Deliver Python Apps with Docker
PDF
Docker for the Rubyist
PPTX
Tribal Nova Docker feedback
PPTX
Mini-Training: Docker
PPTX
Docker open stack boston
PPTX
OpenStack Boston
PDF
Docker and OpenStack Boston Meetup
PDF
Be a better developer with Docker (revision 3)
Docker & Elixir @kloeckner.i
Messaging with the Docker
Phoenix 1.3 Umbrella App deployment via Distillery-Docker-Docker_Compose
Dockercon EU 2014
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
How to automate elixir phoenix deployment with distillery and edeliver on ubu...
Elixir Deployment Tools
Hot deployments with distillery
Unleashing Docker with Pipelines in Bitbucket Cloud
Docker Meetup Paris: enterprise Docker
Ruby on Rails and Docker - Why should I care?
Docker Ecosystem on Azure
Deliver Python Apps with Docker
Docker for the Rubyist
Tribal Nova Docker feedback
Mini-Training: Docker
Docker open stack boston
OpenStack Boston
Docker and OpenStack Boston Meetup
Be a better developer with Docker (revision 3)

Recently uploaded (20)

PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
composite construction of structures.pdf
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPT
Project quality management in manufacturing
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
DOCX
573137875-Attendance-Management-System-original
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
Digital Logic Computer Design lecture notes
PDF
Well-logging-methods_new................
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Welding lecture in detail for understanding
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
Geodesy 1.pptx...............................................
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Construction Project Organization Group 2.pptx
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
composite construction of structures.pdf
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Project quality management in manufacturing
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
573137875-Attendance-Management-System-original
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Digital Logic Computer Design lecture notes
Well-logging-methods_new................
UNIT-1 - COAL BASED THERMAL POWER PLANTS
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Welding lecture in detail for understanding
Lesson 3_Tessellation.pptx finite Mathematics
Arduino robotics embedded978-1-4302-3184-4.pdf
Geodesy 1.pptx...............................................
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Construction Project Organization Group 2.pptx
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx

Lab Zero Lunchdown: Deploying Elixir and Phoenix Applications