pstream is dead; long live pstream
taciturnaxolotl.github.io/pstream-ng/
1---
2title: 'Deploy'
3---
4
5# Deploying the backend
6
7The 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.
8
9For configuration, check out the [configuration reference](./configuration.mdx).
10
11## Method 1 - Docker Deployment
12
13This method provides a straightforward setup with minimal configuration. For more extensive customization, see the [Configuration Reference](./configuration.mdx).
14
15**Prerequisites**
16
17- **Docker:** If you don't have Docker installed, download it from the official website: [Docker installation](https://www.docker.com/get-started)
18 **Setup**
19
20<Steps>
21 <Steps.Step>
22 **Create `docker-compose.yml`:**
23 ```yaml
24 services:
25 postgres:
26 image: postgres
27 environment:
28 POSTGRES_USER: pstream_user
29 POSTGRES_DB: pstream
30 POSTGRES_PASSWORD: YourPasswordHere
31 ports:
32 - "5432:5432"
33 networks:
34 - p-stream-network
35 p-stream:
36 image: ghcr.io/dumbutdumber/backend:latest
37 environment:
38 DATABASE_URL: postgresql://pstream_user:YourPasswordHere@postgres:5432/pstream
39 CRYPTO_SECRET: 32CharacterLongStringHere
40 META_NAME: unofficial-backend
41 ports:
42 - "80:80"
43 depends_on:
44 - postgres
45 networks:
46 - p-stream-network
47 networks:
48 p-stream-network:
49 driver: bridge
50 ```
51 **Important:**
52 * Replace `YourPasswordHere` with your secure database password.
53 * Generate a strong session secret and replace `32CharacterLongStringHere`.
54 </Steps.Step>
55
56 <Steps.Step>
57 **Start the Backend:** Open a terminal in the directory containing `docker-compose.yml` and execute:
58
59 ```bash
60 docker-compose up -d
61 ```
62
63 </Steps.Step>
64</Steps>
65
66### Accessing Your Backend
67
68Your backend should be accessible on `(YourPrivateIP):80`. To share it outside your local network, you'll need to configure port forwarding or cloudflared tunnel.
69
70## Method 2 - Railway (Easy)
71
72Railway offers a 30-day free trial that includes a one-time $5 credit. After the trial, you receive $1 in usage credits for free each month.
73
74[](https://railway.com/deploy/pstreambackend?referralCode=zvXFZF)
75
76<Steps>
77 <Steps.Step>
78 Login to your [Railway](https://railway.app) account if you have one,
79 otherwise create one [here](https://railway.app/login). - If you are signing
80 up, then verify your account by clicking the link in the email Railway sends
81 you. Ensure you setup your server location [here](https://railway.com/workspace)
82 to the closest one possible.
83 </Steps.Step>
84
85<Steps.Step>
86 Click the [`Deploy on
87 Railway`](https://railway.com/deploy/pstreambackend?referralCode=zvXFZF)
88 button above.
89</Steps.Step>
90
91<Steps.Step>Click on configure For the one that says Backend.</Steps.Step>
92
93<Steps.Step>
94 Fill in the required variable META_NAME the rest are optional and can be set
95 later on.
96</Steps.Step>
97
98<Steps.Step>
99 The `Deploy` button at the bottom of the template should be active, click on
100 it.
101</Steps.Step>
102
103<Steps.Step>
104 Once the `Backend` service has deployed, copy the URL from the `Deployments`
105 page. (Might take a second for it to be available after the service has
106 deployed)
107</Steps.Step>
108
109 <Steps.Step>
110 Congratulations! You have deployed the backend, you can now [set up the
111 client](../self-hosting/use-backend.mdx).
112 </Steps.Step>
113</Steps>