prod environment, builds its assets with mix assets.deploy and assembles a release that brings its own copy of the Erlang runtime. The web process starts it with /app/bin/storefront start, and Phoenix listens on the port that Sevalla sets in the PORT environment variable. This guide deploys a Phoenix 1.8 application with a LiveView catalog stored in a Sevalla PostgreSQL database, and runs the Ecto migrations in a job before each deployment.
At a glance
Environment variables
Before you begin
- A Sevalla company with a payment method, and a GitHub, GitLab or Bitbucket account for the repository. See Git providers.
- Elixir 1.20 with Erlang/OTP 29 on your computer.
Create the project
Install the Phoenix project generator, then create a project namedstorefront and fetch its dependencies:
mix phx.new also creates a Git repository in the folder.
Generate a LiveView catalog of products, with its Ecto schema and migration:
scope "/" block in lib/storefront_web/router.ex:
Prepare the project for Sevalla
Add the release files that Phoenix generates for deployments:rel/overlays/bin/server, which starts the release with PHX_SERVER=true, rel/overlays/bin/migrate, which runs the Ecto migrations without Mix, and the Storefront.Release module that migrate calls.
Then set the Elixir version in mix.exs. Phoenix’s generator writes "~> 1.17"; raise it to the version you develop with:
- Sets
PHX_SERVER=true, so the release starts the web server, andLANG=C.UTF-8, the UTF-8 locale Elixir expects. - Starts the release with
/app/bin/storefront start.config/runtime.exsreadsPORT, which Sevalla sets to the web process’s port (8080by default), and Bandit listens on all interfaces. - Doesn’t run migrations. A job runs them once per deployment, before the new version starts.
config/prod.exs turns on force_ssl with rewrite_on: [:x_forwarded_proto]. Sevalla’s proxy ends HTTPS and sets X-Forwarded-Proto, so Phoenix treats requests to your domain as HTTPS, redirects http:// addresses to https://, and sends a strict-transport-security header.
Commit everything and push it to your Git provider:
Deploy to Sevalla
These steps build with Ingot. To build from your own Dockerfile instead, see Deploy with a Dockerfile.Create the database
orders-db as the Display name, choose a Data center and a Size, then click Create database. See Create a database for every field.Create the application
Connect the database
orders-db as the Service and turn on Add environment variables to the application. In the list of variables, rename DB_URL to DATABASE_URL, the name config/runtime.exs reads, then click Add internal connection. See Connect an application.Add the environment variables
Create the migration job
Migrate as the Name and /app/bin/migrate as the Custom start command. Keep the Start policy at Before deployment and the Resource at H1, then click Create process.Deploy
Turn on auto-deploy


ssl: true commented out in config/runtime.exs. The internal connection stays on Sevalla’s private network, and PostgreSQL databases in Google Cloud locations don’t accept TLS connections. DATABASE_URL starts with postgres://, which Ecto accepts as it does ecto://.
Verify the deployment
-
On the Deployments tab, click the deployment. Its Build log shows Ingot’s build plan: Elixir 1.20 from
mix.exs, Erlang/OTP 29, Phoenix, the assets step and the release’s start script.The two warnings are reminders that Ingot prints for every Phoenix project whoseBuild logconfig/runtime.exsreads these variables, even when you’ve set them. Later, the build log showsRelease created at /releaseand, during the rollout,Migrate has been successful. If the job fails, the deployment fails and the previous version keeps running. - Wait for the deployment’s status to change to Deployed. The application’s status next to its name changes to Running.
-
Click the domain under the application’s name, for example
storefront-x7k2m.sevalla.app. Phoenix’s welcome page opens withPeace of mind from prototype to production. -
Add
/products/newto the address, enter a name and a price, and click Save Product. The catalog opens withProduct created successfullyand the new product: the form ran over LiveView’s WebSocket connection, and the product is in PostgreSQL.


CONNECTED TO Phoenix.LiveView.Socket with Transport: :websocket. If the deployment fails, read its build log, then see Troubleshoot Ingot builds.
To check the deployment from a terminal or an AI agent, read its status with Get deployment (getDeploymentV3) until it’s success, and its build log with Get application deployment logs (getApplicationDeploymentLogsV3), as in Deploy with the API. Then request the endpoints:
getApplicationRuntimeLogsV3) with search finds the migrations that the Migrate job ran:
LiveView and WebSockets
Sevalla’s proxy passes WebSocket connections through to the application with no settings. Phoenix accepts a LiveView connection only from a page on the host inPHX_HOST (the endpoint’s check_origin default). A page served from another domain gets 403 for /live/websocket, its LiveViews don’t connect, and the runtime logs show Could not check origin for Phoenix.Socket transport. with the origin of the request.
To check it from a terminal or an AI agent, open the WebSocket with curl, once with the application’s own origin and once with another one. Phoenix answers 101 (switching to the WebSocket) and 403:
sevalla.app domain, list both origins in config/runtime.exs, next to url::
403.
Run more than one instance
Every instance of the web process is a separate Erlang node with its own LiveView processes, and each browser keeps its WebSocket connection to one instance, so LiveView works with several instances. The nodes don’t form a cluster: Phoenix’s generatedDNSCluster needs a DNS name that lists every instance’s address, and the web process’s internal hostname resolves to a single service address. Leave DNS_CLUSTER_QUERY unset. Messages that Phoenix.PubSub broadcasts reach the subscribers on the same instance only.
Deploy with a Dockerfile
Ingot needs no Dockerfile. Write one when you want full control of the image: the base image, system packages and every layer. This Dockerfile starts from the one thatmix phx.gen.release --docker generates. Add a Dockerfile and a .dockerignore to the root of the repository:
Dockerfile, so you can keep it in a repository that builds with Ingot, but it adds the .dockerignore patterns to its own (its build plan shows Ignored 17 patterns from .dockerignore), and the Ingot build passes with this file. Then switch the application to the Dockerfile build strategy:
Choose the Dockerfile build strategy
Dockerfile and the Docker context ., then click Update build strategy.Deploy
📦 Building and pushing docker image using Dockerfile... instead of Ingot’s build plan, and still shows Migrate has been successful: the job runs /app/bin/migrate from the new image. The welcome page and the LiveView catalog work as in Verify the deployment, and the deployment’s Dockerfile tab shows the file the image was built from. When you push a change to the code only, the build log shows CACHED for the steps up to the one the change affects, including mix deps.get and mix deps.compile.
With the API, Update application (updateApplicationV3) switches the build strategy. Then deploy and wait as in Deploy with the API:
sevalla apps update $APP_ID --build-type dockerfile --dockerfile-path Dockerfile. The new deployment’s build log names the Dockerfile build:
Deploy changes
With Auto-deploy on, every push to the branch starts a deployment; otherwise, click Deploy now for each change. Each deployment builds the release, runs theMigrate job, then replaces the web process’s instances. For a schema change, run mix ecto.gen.migration <name> locally and commit the migration in priv/repo/migrations with the code. When you add a dependency, commit the updated mix.lock. See Deployments.
Use environment variables
Add variables on the application’s Environment variables tab; they apply at the next deployment. Read them inconfig/runtime.exs with System.get_env/1, which runs each time the release starts. config/config.exs and config/prod.exs are evaluated while the release is built, so a variable they read is fixed in the image: the build log warns when they read one. See Environment variables.
Add a custom domain
To serve the application from your own domain, such asshop.example.com, add the domain on the application’s Domains tab and create the DNS records that Sevalla shows. Then set PHX_HOST to shop.example.com, so Phoenix builds its URLs with it, add both domains to check_origin as in LiveView and WebSockets, and deploy. Custom domains need a web process larger than H1, so scale the web process first. See Custom domains.
Troubleshoot
Deploy with the API
These calls make the same deployment as Deploy to Sevalla, in an order that a script or an AI agent runs as it is. Each step names the Sevalla API operation, then the CLI command and the MCP server tool that do the same. You need:- An API key with the Company developer role, or the
APP:CREATE,APP:READ,APP:UPDATE,DATABASE:CREATE,DATABASE:READandDATABASE:UPDATEpermissions, in theSEVALLA_API_KEYenvironment variable. The CLI reads the key fromSEVALLA_API_TOKEN. - The repository on a Git provider that’s connected to your Sevalla account. See Git providers. Creating the application checks it: when Sevalla can’t read the repository, the call returns
400withCannot access repository https://github.com/acme/storefront: Repository not found or you don't have access., followed by where to grant access. curl,jqandopenssl.
Choose the location
listClustersV3) returns the locations your company can use, each with its id, the display_name that the dashboard shows and its region ID in location. Keep the ID of the one you want by its region ID, such as eu-frankfurt-1 for Frankfurt, Germany. Locations lists them all. The database and the application must be in the same location:sevalla resources clusters. MCP: get_platform_options.Find the newest PostgreSQL version
listDatabaseVersionsV3) returns the versions you can create in the location:sevalla resources db-versions --cluster $CLUSTER_ID --type postgresql. MCP: create_database picks the newest version when you leave version out.Find the DB1 size
listDatabaseResourceTypesV3) returns the database sizes by name. DB1, the smallest, is the dashboard’s default:sevalla resources db-types. MCP: get_platform_options.Create the database
createDatabaseV3) needs a password: generate one and keep it, because Get database (getDatabaseV3) doesn’t return it. The call returns at once, with the status creating:sevalla databases create --name orders-db --type postgresql --db-version $PG_VERSION --cluster $CLUSTER_ID --resource-type $DB_SIZE_ID --db-name orders --db-user storefront --db-password $DB_PASSWORD. MCP: create_database with connect_to_application_id and env_var_name set to DATABASE_URL also connects the application and stores the URL, with the scheme postgresql://, which Ecto accepts as well as postgres://.Wait for the database
getDatabaseV3) returns the status, creating and then ready once the database accepts connections, and the internal hostname and port that the application connects to:sevalla databases get $DB_ID. MCP: get_database.Create the application
createApplicationV3) creates the application with a web process. It builds with Ingot (build_type is ingot) and isn’t deployed yet:sevalla apps create --name storefront --cluster $CLUSTER_ID --source privateGit --git-type github --repository https://github.com/acme/storefront --branch main. MCP: create_application with deploy set to false.Find the domain
listApplicationDomainsV3) returns the domain that Sevalla gives the application. It appears a few seconds after the application is created, so ask until it’s there:sevalla apps domains list --app-id $APP_ID. MCP: get_application.Connect the database
createApplicationInternalConnectionV3) connects the application to the database over the private network and returns the connection’s id. Unlike the dashboard, it doesn’t add environment variables:sevalla apps internal-connections create $APP_ID --target-id $DB_ID --target-type database. MCP: sevalla_api_create with createApplicationInternalConnectionV3.Add the environment variables
createEnvironmentVariableV3) adds the database URL in the format that the dashboard’s internal connection uses, a new SECRET_KEY_BASE and the domain in PHX_HOST, available at runtime only. openssl rand -base64 48 prints 64 random characters, as mix phx.gen.secret does:sevalla apps env-vars create $APP_ID --key PHX_HOST --value $HOST, once per variable; it always makes a variable available during the build and runtime. MCP: set_environment_variables with buildtime set to false.Find the web process
listProcessesV3) returns the web process that the application was created with:sevalla apps processes list --app-id $APP_ID. MCP: get_application.Find the H1 size
listProcessResourceTypesV3) returns the sizes by name, in lowercase:sevalla resources process-types. MCP: get_platform_options.Create the migration job
createProcessV3) creates the Migrate job. The API needs the size, a scaling_strategy and the job_start_policy, which the dashboard fills in for you:sevalla apps processes create $APP_ID --name Migrate --type job --command /app/bin/migrate --resource-type $H1_ID --job-start-policy beforeDeployment. MCP: sevalla_api_create with createProcessV3 and the same body.Set the size
updateProcessV3) sets the size:sevalla apps processes update $WEB_ID --app-id $APP_ID --resource-type $H1_ID. MCP: scale_process with size_id.Turn on auto-deploy
updateApplicationV3) turns on automatic deployments for every push to the branch:sevalla apps update $APP_ID --data '{"auto_deploy":true}'. MCP: sevalla_api_update with updateApplicationV3.Deploy
triggerDeploymentV3) deploys the latest commit on the branch:sevalla apps deployments trigger $APP_ID --branch main. MCP: trigger_deployment.Wait for the deployment
getDeploymentV3) returns the deployment’s status: waiting and inProgress while it runs, then success, failed, cancelled or skipped. Poll it until the status is final, for up to 30 minutes:sevalla apps deployments get $DEPLOYMENT_ID --app-id $APP_ID. MCP: get_deployment.Read the build log
getApplicationDeploymentLogsV3) returns the build log, oldest line first: the build plan from Verify the deployment, the build and the rollout. When the status is failed, the last lines say why. With search, it finds the job’s result:sevalla apps deployments logs $DEPLOYMENT_ID --app-id $APP_ID. MCP: get_deployment_logs.Check the application