Quickstart: Deploy an Elixir Phoenix App
This guide explains how to deploy a minimal yet production-ready Elixir Phoenix application on seenode.
Deploy a Phoenix Template
Section titled “Deploy a Phoenix Template”Get started in seconds by deploying our pre-configured Phoenix template.
Phoenix Template
Deploy a minimal Phoenix application designed for zero-configuration deployment.Deploying an Existing Phoenix Project
Section titled “Deploying an Existing Phoenix Project”Follow these steps to deploy your existing Phoenix application from a Git repository.
-
Prepare Your Phoenix App
Ensure your project has the necessary files and configuration for seenode to run it.
Project Structure
Your project should have a standard Phoenix structure.
Directorymy-phoenix-app/
- mix.exs
- mix.lock
Directoryconfig/
- config.exs
- prod.exs
Directorylib/
- …
Directorypriv/
- …
- build.sh
Configure for Production
In your
config/prod.exs
, ensure your endpoint is configured to listen on the port defined by an environment variable. This allows seenode to correctly route traffic to your application.config/prod.exs import Configconfig :hello,generators: [timestamp_type: :utc_datetime]# Configures the endpointconfig :hello, HelloWeb.Endpoint,url: [host: System.get_env("PHX_HOST") || "localhost", port: 80],adapter: Bandit.PhoenixAdapter,render_errors: [formats: [html: HelloWeb.ErrorHTML, json: HelloWeb.ErrorJSON],layout: false],pubsub_server: Hello.PubSub,live_view: [signing_salt: "Kute9Cn2"],http: [port: String.to_integer(System.get_env("PORT") || "80")],server: true# ... rest of configuration ...Port Configuration
Your Phoenix application should be configured to listen on port 80 by default in production. The app will automatically bind to port 80 unless overridden by the
PORT
environment variable. -
Create a Build Script (Optional)
To streamline deployments, you can create a
build.sh
script to install dependencies, compile your project, and deploy assets.build.sh #!/usr/bin/env bash# exit on errorset -o errexit# Initial setupmix local.hex --forcemix local.rebar --force# Install dependenciesmix deps.get --only prod# Compile and build assetsMIX_ENV=prod mix compileMIX_ENV=prod mix assets.buildMIX_ENV=prod mix assets.deployMake the script executable:
chmod +x build.sh
Advanced Build Configurations
For more complex Phoenix applications, you might need additional build steps:
With Database Migrations
build.sh #!/usr/bin/env bash# exit on errorset -o errexit# Initial setupmix local.hex --forcemix local.rebar --force# Install dependenciesmix deps.get --only prod# Compile and build assetsMIX_ENV=prod mix compileMIX_ENV=prod mix assets.buildMIX_ENV=prod mix assets.deploy# Run database migrations (if needed)MIX_ENV=prod mix ecto.migrateChaining Commands Directly
Instead of using a build script, you can chain commands in the build command field:
Terminal window mix local.hex --force && mix local.rebar --force && mix deps.get --only prod && MIX_ENV=prod mix compile && MIX_ENV=prod mix assets.build && MIX_ENV=prod mix assets.deployStart Command with Migrations
You can also run migrations as part of your start command:
Terminal window MIX_ENV=prod mix ecto.migrate && MIX_ENV=prod mix phx.server -
Deploy on seenode
Follow these steps to deploy your Phoenix application:
-
Create Web Service
From the seenode Dashboard, create a new Web Service and connect the Git repository for your Phoenix application.
-
Configure Build and Start Commands
seenode automatically detects an Elixir project. Configure the build and start commands:
Build Command (choose one approach):
Option A - Using build script:
Terminal window ./build.shOption B - Direct commands:
Terminal window mix local.hex --force && mix local.rebar --forcemix deps.get --only prodMIX_ENV=prod mix compileMIX_ENV=prod mix assets.buildMIX_ENV=prod mix assets.deployStart Command:
Terminal window MIX_ENV=prod mix phx.server -
Configure Environment Variables and Port
On the same configuration screen, add your environment variables and port configuration:
- Environment Variables: Add
SECRET_KEY_BASE
- generate one locally withmix phx.gen.secret
. This is required for production and is used to sign/encrypt cookies and other secrets. - Port: Set to
80
(or leave default if your app uses the PORT environment variable)
- Environment Variables: Add
-
Deploy
Choose your preferred instance size and click Create Web Service.
-
Monitor Deployment
Watch your deployment progress in real-time through the Logs tab.
-
Access Your App
Once complete, your Phoenix app will be live and accessible at your service’s public URL.
-
Next Steps
Section titled “Next Steps”Now that your Phoenix app is deployed, here are some recommended next steps:
Set up a Custom Domain (Coming Soon)
Configure a custom domain to point to your new web service.Connect to a Database
Instantly scaffold and connect PostgreSQL and MySQL databases