Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

⚙️ Automatic server provisioning and configuration for Elixir and Phoenix Deployment

Notifications You must be signed in to change notification settings

dkarter/deploy-elixir-example

Repository files navigation

Automating Elixir Deployment - Example Repo

TOC

What Is This?

This is a companion repository for a series of posts I wrote for the Hashrocket blog:

Demo

See it live!

demo

Deployment Instructions

Setup Pulumi

  1. Get a Digital Ocean API key

  2. Export it in your shell:

    export DIGITALOCEAN_TOKEN='your token.......'
  3. Install dependencies:

    $ mix setup
  4. Select a stack:

    $ mix pulumi stack select prod

    Look in infra/Pulumi.prod.yaml and change it according to your needs.

    You will need a domain name with name servers pointed at:

    ns1.digitalocean.com
    ns2.digitalocean.com
    ns3.digitalocean.com
    

    This may take a bit to propagate.

  5. Run pulumi up:

    mix pulumi up --yes

Setup Ansible

  1. Create a vault password file:

    $ echo 'topsecret' > ansible/.vault-password

    Replace topsecret with a password generated by your password manager.

  2. Remove existing secret files and create your own using the password you specified above:

    $ cd ansible
    $ rm inventories/group_vars/all/secret/all.yml
    $ ansible-vault create inventories/group_vars/all/secret/all.yml

    It should look like this:

    ---
    secret_admin_email: admin@example.com

    Replace with your own email, save and exit the file.

    Now do the same for the phoenix secrets file:

    $ rm inventories/group_vars/application/secret/phoenix.yml
    $ ansible-vault create inventories/group_vars/application/secret/phoenix.yml

    It should look like this:

    ---
    secret_secret_key_base: 'run mix phx.gen.secret to generate'
    secret_erlang_cookie: 'run mix phx.gen.secret to generate'

    In a separate terminal generate the secrets using mix phx.gen.secret, paste them into the file, save and exit.

  3. Change directories back up to the root of the project and run:

    $ mix ansible

Deploy Using eDeliver

Once the server is fully provisioned by Pulumi and Ansible, you should be able to build a release:

$ mix edeliver build release

The output should look like:

BUILDING RELEASE OF EXAMPLE APP ON BUILD HOST
-----> Authorizing hosts
-----> Ensuring hosts are ready to accept git pushes
-----> Pushing new commits with git to: deploy@example.com
-----> Resetting remote hosts to 26b6853c000982d80466818c7a1028e392b60483
-----> Cleaning generated files from last build
-----> Updating git submodules
-----> Fetching / Updating dependencies
-----> Build static assets
-----> Compiling sources
-----> Generating release
-----> Copying release 0.1.0+1-26b6853 to local release store
-----> Copying example.tar.gz to release store
RELEASE BUILD OF EXAMPLE WAS SUCCESSFUL!

Copy the release version and use it to deploy the release to production:

$ mix edeliver deploy release to production --version=0.1.0+1-26b6853

When the deploy is finished, restart the production release:

$ mix edeliver restart production

Running Locally

To start your Phoenix server:

  • Setup the project with mix setup
  • Start Phoenix endpoint with mix phx.server

Now you can visit localhost:4000 from your browser.

About

Hashrocket logo

Deploy Elixir Example is kindly supported by Hashrocket, a multidisciplinary design and development consultancy. If you'd like to work with us or join our team, don't hesitate to get in touch.

About

⚙️ Automatic server provisioning and configuration for Elixir and Phoenix Deployment

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

AltStyle によって変換されたページ (->オリジナル) /