---
title: 'Deploy'
---

# Deploying the backend

The only officially recognized hosting method is through Docker (or similar container runtimes). It can be scaled horizontally to all your heart's content and is the safest way to host the backend.

For configuration, check out the [configuration reference](2.configuration.md).

::alert{type="info"}
The postgres database will need to be populated with [migrations](0.introduction.md#migrations) if `postgres.migrateOnBoot` isn't enabled.
::

## Method 1 - Docker

This method will help you set up the backend with the bare minimum configuration options. You'll most likely want to [add some more environment variables](2.configuration.md) to customize your experience more thoroughly.

The command below will not work unless customized by you, change the [`MWB_POSTGRES__CONNECTION`](2.configuration.md#postgresconnection) and [`MWB_CRYPTO__SESSION_SECRET`](2.configuration.md#cryptosessionsecret) to something valid for the backend to function.

If you're using a hosted postgres database like [Neon](https://neon.tech/){target="\_blank"}, you'll also want to enable SSL support for the backend using the [`postgres.ssl`](2.configuration.md#postgresssl) option.

For other versions of the image, [check out the package page](https://github.com/movie-web/backend/pkgs/container/backend){target="\_blank"}.

```sh
docker run \
    -p 80:80 \
    -e MWB_POSTGRES__CONNECTION=postgresql://localhost:5432 \
    -e MWB_CRYPTO__SESSION_SECRET=add-your-own-secret \
    -e MWB_META__NAME=unofficial-movie-web \
    ghcr.io/movie-web/backend:latest
```

After running that command, your backend [_should_](../1.self-hosting/4.troubleshooting.md) now be available on `localhost:80`. if you want to be able to connect to the backend outside of your local network (for example sharing it with your friends), then you'll need set up to port forwarding.

## Method 2 - Railway (Easy)

Railway offers you $5 of credit once you verify your account, which is enough to run the backend for around 5 months (~$0.90 per month).

[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/TS4mw5)

1. Login to your [Railway](https://railway.app) account if you have one, otherwise create one [here](https://railway.app/login).
   1. If you are signing up, then verify your account by clicking the link in the email Railway sends you.
   1. If you created your account with an email, then to verify your account further, go to your account, then plans and verify your account with a GitHub account.
1. Click the [`Deploy on Railway`](https://railway.app/template/TS4mw5) button above.
1. If a `Configure` button is displayed, click on it and allow Railway to access your GitHub account. 
1. Fill in the required variables or change the default values.
1. The `Deploy` button at the bottom of the template should be active, click on it.
1. Once the `Backend` service has deployed, copy the URL from the `Deployments` page. (Might take a second for it to be available after the service has deployed)
1. Congratulations! You have deployed the backend, you can now [set up the client](../1.self-hosting/2.use-backend.md).
