Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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 "your@email.co.uk"
  • 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

You might need to also follow the steps here to build the phoenix.digest

https://github.com/boldpoker/edeliver/wiki/Run-additional-build-tasks

Actually you can omit the RELEASE_VERSION="x.y.z" in the edeliver config. edeliver autodetects the current release version when building. Then you would not have to change the version in two files, if it is incremented: only in mix.exs, not in .deliver/config.

If you don't like to increment the version at all every time you build/deploy a new release but still want to be able to identify the deployed version, you can test the new --auto-version=git feature from the upgrade-command branch which will be included into the next major edeliver release (1.2). This option causes edeliver to append the git hash to the release version when building the release or upgrade. To enable it permanently you can add the AUTO_RELEASE_VERSION=git option to the edeliver config.

Btw, if you want to use different configurations per host or just don't want to include the production config into the release file, the LINK_SYS_CONFIG=/path/ or the LINK_VM_ARGS=/path/ option might be helpful.

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

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