Deploy Elixir, Phoenix apps on OpsCaptain

OpsCaptain can deploy Elixir and Phoenix applications using the heroku-buildpack-elixir and heroku-buildpack-phoenix-static. From the developers perspective, you simply deploy your code using the CLI and OpsCaptain configures the environment to compile your application using the buildpacks. If you are interested in customizing runtime parameters such as the version of erlang, elixir, node.js to be used to compile your application. Click on the buildpack links to learn about how to do this. OpsCaptain provides a Heroku compatible environment on your own servers so you can run your applications.

Prerequisites

Install the opscaptain-cli on your local machine and also log in. If you haven't, run the below commands from your terminal to install it and login:

npm install -g opscaptain-cli opscaptain login -em info@opscaptain.com -pw ******

You must have already added the server that will be used to host your Elixir app. To add a server to your OpsCaptain account, follow this guide here.

If you do not have a server yet, you can purchase a server or use the free tier or credit from one of the following clouds: AWS EC2, Microsoft Azure, Vultr, DigitalOcean and Google


Step 1. Create your app

From the dashboard: Log into the dashboard and create a new app using this link. Select the required database engine. If your app does not require a database, do not make a selection. Once the app and database are created, you can then proceed to deploy your code to it.

Step 2. Create the ocmanifest.json file in your application directory.

You will typically configure the ocmanifest.json file on your first deployment or when you need to change any environment variables.

The below example shows a sample ocmanifest.json file to deploy Elixir, Phoenix apps:

{ // The name you provided when creating the app in step 1 name: "elixir-hello-word", // Configure environment variables if any env: { "VARNAME": "VARVALUE" }, // If you are deploying Elixir buildpacks: ["elixir"] // Or If you are deploying Phoenix buildpacks: ["elixir","phoenix-static"] // Or If you are deploying Phoenix and want to serve // with Sass assets buildpacks: ["elixir","phoenix-static","ruby"] }

Step 3. Deploy your Elixir, Phoenix app

CD into the project directory. Once there, run the below command to deploy and that's it.

opscaptain deploy