# Deploy a production app

Deploy a web application with a database and prepare its release and operating processes. This guide uses a service named `web` and a database named `db`.

> [!note] Requirements
>
> You will need the following to get started:
>
> - Application source or a container image that starts your web server
> - A Northflank project and permission to create its resources
> - The application port, database type, and required environment variables

### 1. Prepare the database and secrets

[Deploy a database](https://northflank.com/docs/v1/application/databases-and-persistence/deploy-a-database) named `db`. Choose a database type and version that the application supports.

Prepare a [secret group](https://northflank.com/docs/v1/application/secure/manage-secret-groups) with the application's required variables. [Link the database credentials](https://northflank.com/docs/v1/application/databases-and-persistence/connect-database-secrets-to-workloads) and match the variable names that the application reads.

### 2. Build and deploy the application

If you use source code, [build and deploy your code](https://northflank.com/docs/v1/application/getting-started/build-and-deploy-your-code). If you already have an image, [deploy it from a registry](https://northflank.com/docs/v1/application/run/run-an-image-from-a-container-registry).

Name the service `web`. Select the secret group and use the application's start command and port. Wait for the deployment to start. If it fails, examine the [container logs](https://northflank.com/docs/v1/application/observe/view-logs).

Make sure that `web` can connect to `db`. Use a test request that reads and writes application data.

### 3. Configure traffic and readiness

[Configure the service port](https://northflank.com/docs/v1/application/network/configure-ports). If you use a custom domain, [add the domain](https://northflank.com/docs/v1/application/domains/add-a-domain-to-your-account) and [link it to the port](https://northflank.com/docs/v1/application/domains/link-a-domain-to-a-port).

[Configure health checks](https://northflank.com/docs/v1/application/observe/configure-health-checks) for the application. Make sure that a request to its public address returns the expected response.

### 4. Define the release process

Use [environments](https://northflank.com/docs/v1/application/release/set-up-environments) to define development stages. For releases with multiple actions, [configure a workflow](https://northflank.com/docs/v1/application/release/configure-workflows).

If a release changes the database schema, review [database migrations](https://northflank.com/docs/v1/application/release/run-migrations) before deployment. Define recovery for both the application image and its data. Reverting an image does not reverse a database migration.

### 5. Prepare for operations

1. Choose [service capacity](https://northflank.com/docs/v1/application/scale/scale-cpu-and-memory) and [instance count](https://northflank.com/docs/v1/application/scale/scale-instances).

2. Configure [database backups](https://northflank.com/docs/v1/application/databases-and-persistence/backup-restore-and-import-data) and review the restore procedure.

3. Review [metrics](https://northflank.com/docs/v1/application/observe/view-metrics) and configure [infrastructure alerts](https://northflank.com/docs/v1/application/observe/set-infrastructure-alerts).

4. Make sure that the team can find logs, identify the deployed revision, and use the recovery procedure.

For more detail, read the [production readiness guidance](https://northflank.com/docs/v1/application/production-workloads/get-production-ready-on-northflank). The application is ready for your production review when it serves requests, stores data, and has defined release and recovery processes.
