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.
- Python 3.14 on your computer, the version the project runs on in Sevalla.
Create the project
Create a virtual environment and install Flask, the database extensions, Gunicorn and the PostgreSQL driver:
Keep local files out of the repository:
.gitignore
app/models.py
app/extensions.py
postgres://, which SQLAlchemy doesn’t accept, so the code switches the scheme to postgresql+psycopg://:
app/__init__.py
DB_URL is the variable Sevalla adds when you connect the database; without it, the project uses SQLite in the instance folder.
Generate the first migration, apply it to the local database and start the development server. The flask command finds the factory in the app package on its own, so it needs no --app option. Flask-Alembic keeps migrations in app/migrations:
http://127.0.0.1:8000/items. The response is [].
Prepare the project for Sevalla
Ingot, the default build strategy, needs no settings to build and start this project:- It looks for a Flask application, or a factory function named
create_appormake_app, at the top level of the modules it searches,app/__init__.pyamong them. It findscreate_appand starts the web process withgunicorn app:create_app(), so the project needs no start command. See Set the start command. - Gunicorn listens on
0.0.0.0and the port in thePORTenvironment variable, which Sevalla sets to the web process’s port (8080by default). - Ingot’s Gunicorn settings run 1 worker process with 4 threads. On a larger size, add a
WEB_CONCURRENCYenvironment variable with the number of worker processes you want, such as3. - Migrations don’t run in the web process. A job runs them once per deployment.
Pin the Python version
Without a version in the project, Ingot builds on its default Python line, 3.14 in Ingot 0.5.0, and a new Ingot release can move that default. Pin the version in.python-version, the first file Ingot reads it from. See Pin the Python version.
.python-version
List the dependencies
Ingot installsrequirements.txt with pip, into a virtual environment in the image:
app/migrations, 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.1
Create the database
In the sidebar, click Databases, then click Create database. Under Database, choose PostgreSQL and the newest version. Enter
orders-db as the Display name, choose a Data center and a Size, then click Create database. See Create a database for every field.2
Create the application
In the sidebar, click Applications, then click Create > Application. Under Source, click Private repository, then choose the Git provider, the Repository and the Branch. Under Location, choose the same Data center as the database. Keep the Size at H1 or choose a larger one, then click Create application. The application opens on its Overview tab with the status Not deployed yet: creating an application doesn’t deploy it.
3
Connect the database
Click the Networking tab. Under Connected services, click Add internal connection. Choose
orders-db as the Service, turn on Add environment variables to the application, and click Add internal connection. Sevalla adds DB_URL and the other connection variables to the application. See Connect an application.4
Add the environment variables
Click the Environment variables tab, then click Add environment variables. Add
FLASK_SECRET_KEY with a random string of 32 characters or more (generate one with python3 -c "import secrets; print(secrets.token_hex(32))"), keep Available during runtime selected, and click Add environment variables. Flask signs sessions with it.5
Create the migration job
Click the Processes tab, then click Create process. Choose Job, enter
Migrate as the Name and flask db upgrade as the Custom start command. Keep the Start policy at Before deployment and the Resource at H1, then click Create process.6
Deploy
Click the Overview tab, then click Deploy now under Recent deployments. Check the Branch and click Deploy.
7
Turn on auto-deploy
To deploy every push to the branch automatically, click the Settings tab, then click Update auto-deploy in the Auto-deploy section. Turn on Auto-deploy and click Update auto-deploy. See Deployments.


Verify the deployment
-
On the Deployments tab, click the deployment. Its Build log shows Ingot’s build plan: Python 3.14 from
.python-version, pip fromrequirements.txt, and Flask with the start command fromapp/__init__.py.Build log -
Wait for the deployment’s status to change to Deployed. The application’s status next to its name changes to Running. Before the web process rolls out, the build log shows
Migrate has been successful; if the job fails, the deployment fails and nothing changes for visitors. On the Logs tab, with Process set toMigrate, the job’s output ends withRunning upgrade -> <revision>, Create item table. -
Add an item and list the items, with your application’s domain. The domain is under the application’s name, for example
storefront-x7k2m.sevalla.app:The first command returns{"id":1,"name":"Coffee mug"}and the second[{"id":1,"name":"Coffee mug"}]: the application writes to and reads from the PostgreSQL database.
APP_ID and DEPLOYMENT_ID from Deploy with the API. Get deployment (getDeploymentV3) returns the status, success once the deployment is done:
getApplicationDeploymentLogsV3) returns the build log, build plan included; search keeps the lines that contain a text:
getApplicationRuntimeLogsV3) with search=Running%20upgrade returns INFO [alembic.runtime.migration] Running upgrade -> 1793297088, Create item table, with your migration’s revision. The CLI has sevalla apps deployments get, sevalla apps deployments logs and sevalla apps logs runtime, and the MCP server get_deployment, get_deployment_logs and search_runtime_logs.
Deploy with a Dockerfile
Ingot needs no Dockerfile. Write your own when you want full control of the image: the base image, the system packages and every layer. Add aDockerfile and a .dockerignore to the root of the repository:
Dockerfile
.dockerignore
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 an Ignored row with 7 patterns from .dockerignore. Then switch the application to the Dockerfile build strategy:
1
Choose the Dockerfile build strategy
On the application’s Settings tab, in the Build strategy section, click Update build strategy. Click Dockerfile, keep the Dockerfile path
Dockerfile and the Docker context ., then click Update build strategy.2
Deploy
Click the Overview tab, then click Deploy now under Recent deployments. Check the Branch and click Deploy.


📦 Building and pushing docker image using Dockerfile... where Ingot’s build plan was, then Migrate has been successful: the job runs flask db upgrade in the new image. curl https://storefront-x7k2m.sevalla.app/items still returns [{"id":1,"name":"Coffee mug"}], from the same database, and the deployment’s Dockerfile tab shows your Dockerfile. See Dockerfile.
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 image, runs theMigrate job, then replaces the web process’s instances. For a schema change, run flask db revision "<message>" locally and commit the new migration with the code. After you install a package, run pip freeze > requirements.txt again. See Deployments.
Add a custom domain
Add the domain on the application’s Domains tab. Flask doesn’t check the host, so no code change is needed. Custom domains need a web process larger than H1.Troubleshoot the deployment
For more causes, see Troubleshoot Ingot builds and Troubleshoot builds and deployments. To add caching, background tasks or health checks, see the Flask guides.
Deploy with the API
These calls make the same deployment as Deploy to Sevalla, in an order that an agent or a script runs as is. Each step names the API operation, then the CLI command and the MCP tool that do the same. The CLI reads the key fromSEVALLA_API_TOKEN and prints tables; with --json it prints the API’s JSON, except that lists are bare arrays rather than the API’s data field.
Before you start:
- Put an API key in
SEVALLA_API_KEY. The key needs the Company developer role or Company admin; see API keys. The commands usecurl,jqandopenssl. - Push the repository and connect its Git account to Sevalla, as in Before you begin. No API call reports whether the account is connected: if it isn’t, or Sevalla’s GitHub App can’t see the repository, creating the application fails with
400and a message that starts withCannot access repository https://github.com/acme/storefront: Repository not found or you don't have access.and says where to grant access. - Look up the location and the sizes. The first command picks the location by its region ID, here
eu-frankfurt-1(Frankfurt, Germany); see Locations for the others. List clusters (listClustersV3), List process resource types (listProcessResourceTypesV3) and List database resource types (listDatabaseResourceTypesV3) return them; the CLI hassevalla resources clusters,sevalla resources process-typesandsevalla resources db-types, and the MCP serverget_platform_options.
null, run its curl command without jq: the response’s message says what went wrong.
1
Create the database
Create database (CLI:
createDatabaseV3). You choose the password here, because the API never returns it and DB_URL needs it:sevalla databases create --name orders-db --type postgresql --db-version 18 --cluster "$CLUSTER_ID" --resource-type "$DB1_ID" --db-name storefront --db-user storefront --db-password "$DB_PASSWORD". MCP: create_database generates its own password and never returns it. Call it once the application exists, with connect_to_application_id set to the application and env_var_name set to DB_URL: it then also adds the internal connection and DB_URL, in place of the step that connects the database and the DB_URL line of the next step. Its URL starts with postgresql://, which SQLAlchemy 2.1 connects with psycopg 3 too, so database_url() needs no change.2
Create the application
Create application (CLI:
createApplicationV3). It creates the web process and doesn’t deploy: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; by default it starts a deployment before the database, the variable and the job exist.3
Set the web process size
The API creates the web process at S1, not the dashboard’s H1. List processes (It prints
listProcessesV3) finds it, and Update process (updateProcessV3) sets H1:h1. CLI: sevalla apps processes update "$WEB_ID" --app-id "$APP_ID" --resource-type "$H1_ID". MCP: scale_process with size_id and apply_now set to false.4
Wait for the database
Get database (CLI:
getDatabaseV3) until its status is ready, then keep its internal hostname and port:sevalla databases get "$DB_ID" --json. MCP: get_database.5
Connect the database
Create internal connection (CLI:
createApplicationInternalConnectionV3):sevalla databases connections internal-create "$DB_ID" --target-id "$APP_ID" --target-type app. MCP: sevalla_api_create with createApplicationInternalConnectionV3 and the same body.6
Add the environment variables
Unlike the dashboard, the API doesn’t add the connection’s variables. Create environment variable (It prints one line per variable, such as
createEnvironmentVariableV3), once per variable, adds DB_URL in the dashboard’s format and FLASK_SECRET_KEY, both available during runtime only (the API’s default is build and runtime):{"key":"DB_URL","is_runtime":true,"is_buildtime":false}. CLI: sevalla apps env-vars create "$APP_ID" --key DB_URL --value "postgres://storefront:$DB_PASSWORD@$DB_HOST:$DB_PORT/storefront", and the same for FLASK_SECRET_KEY; the CLI makes them available during build and runtime. MCP: set_environment_variables with both, runtime true and buildtime false.7
Create the migration job
Create process (CLI:
createProcessV3). A job needs job_start_policy, and every process needs scaling_strategy and resource_type_id:sevalla apps processes create "$APP_ID" --name Migrate --type job --command "flask db upgrade" --job-start-policy beforeDeployment --resource-type "$H1_ID". MCP: sevalla_api_create with createProcessV3 and the same body.8
Deploy
Trigger deployment (CLI:
triggerDeploymentV3) deploys the latest commit on the branch:sevalla apps deployments trigger "$APP_ID". MCP: trigger_deployment.9
Wait for the deployment
Get deployment (It prints
getDeploymentV3) until status is success or failed:success when the deployment finishes, or failed; after 30 minutes without either, it prints the status it last read. On failed, read the build log with Get application deployment logs (getApplicationDeploymentLogsV3), as in Verify the deployment. CLI: sevalla apps deployments get "$DEPLOYMENT_ID" --app-id "$APP_ID". MCP: get_deployment, then get_deployment_logs.10
Turn on auto-deploy
Update application (It prints
updateApplicationV3):true. CLI: sevalla apps update "$APP_ID" --data '{"auto_deploy": true}'. MCP: sevalla_api_update with updateApplicationV3 and the same body.listApplicationDomainsV3) returns the domain to run the checks in Verify the deployment against:
[]. To build from the Dockerfile instead, send {"build_type": "dockerfile", "dockerfile_path": "Dockerfile", "docker_context": "."} to Update application, then deploy and wait again. CLI: sevalla apps update "$APP_ID" --build-type dockerfile --dockerfile-path Dockerfile.