Skip to content

Instantly share code, notes, and snippets.

@mattweldon
Last active September 3, 2021 16:48
Show Gist options
  • Save mattweldon/2e8ecb953216438ad168 to your computer and use it in GitHub Desktop.
Save mattweldon/2e8ecb953216438ad168 to your computer and use it in GitHub Desktop.
Getting Elixir / Phoenix running on Digital Ocean with edeliver

Build Server

  • Go to Digital Ocean
  • Create new droplet
  • London
  • Ubuntu
  • No apps
  • Add SSH keys

Setup Server

  • SSH to server as root
  • sudo apt-get install git
    • git config --global user.name "Your Name"
    • git config --global user.email "[email protected]"
  • wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb
  • sudo apt-get update
  • sudo apt-get install elixir
  • mix local.hex
  • archive.install https://github.com/phoenixframework/phoenix/releases/download/v1.0.3/phoenix_new-1.0.3.ez
  • sudo apt-get install erlang-base-hipe
  • sudo apt-get install build-essential
  • sudo apt-get install erlang-dev
  • chmod -R 777 /opt
  • mkdir /git
  • chmod -R 777 /git

Setup EDeliver Project

  • add edeliver dependency (pointing to master branch on GH for now...): {:edeliver, git: "https://github.com/boldpoker/edeliver.git"}
  • change {:phoenix_live_reload, "~> 1.0", only: :dev} to {:phoenix_live_reload, "~> 1.0"}
  • add , :edeliver, :phoenix_live_reload to applications list
  • mix deps.get
  • mix deps.compile
  • create .deliver/config file
  • populate config file with the following:
#!/usr/bin/env bash

APP="my_awesome_app" # name of your release

BUILD_HOST="server ip / hostname" # host where to build the release
BUILD_USER="root" # local user at build host
BUILD_AT="/git/my_awesome_app/builds" # build directory on build host
RELEASE_DIR="/git/my_awesome_app/builds/rel/my_awesome_app"
RELEASE_VERSION=0.0.1

STAGING_HOSTS="server ip / hostname" # staging / test hosts separated by space
STAGING_USER="git" # local user at staging hosts
TEST_AT="/test/my_awesome_app" # deploy directory on staging hosts. default is DELIVER_TO

PRODUCTION_HOSTS="server ip / hostname" # deploy / production hosts separated by space
PRODUCTION_USER="root" # local user at deploy hosts
DELIVER_TO="/opt/my_awesome_app" # deploy directory on production hosts

Establish Production Config

  • copy / paste config from dev.exs / test.exs
  • replace first endpoint block with the following:
config :my_awesome_app, MyAwesomeApp.Endpoint,
  http: [port: 4800],
  debug_errors: true,
  server: true,
  code_reloader: false,
  cache_static_lookup: false,
  check_origin: false,
  watchers: []
  • be sure to remove / turn off any config settings relating to live reload / code reload

Build On Server

  • mix edeliver build release --verbose
  • mix edeliver deploy release to production --verbose
  • mix edeliver start production --verbose
  • double check that everything is running at your-ip:4800
@dustinfarris
Copy link

How are you doing migrations? I get connection not available because of disconnection when i try to.

@nelsonic
Copy link

Got:

archive.install: command not found

Should be mix archive.install ...

also, current (stable) release for Phoenix is 1.2.1
but to get the latest version the download link should be:

mix archive.install https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez

for latest see: https://github.com/phoenixframework/phoenix/releases 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment