docs/pages/extra/selfhost.mdx

105 lines
3.8 KiB
Plaintext

# Guide to Self-Deployment with Docker Compose
<Steps>
<Steps.Step>
**Install Docker and Docker Compose:**
Ensure that Docker and Docker Compose are installed on your system. You can follow the official Docker documentation for installation instructions:
- [Install Docker](https://docs.docker.com/get-docker/)
</Steps.Step>
<Steps.Step>
**Create a Docker Compose file:**
Create a new file named `docker-compose.yml` in your project directory and paste the following content into it:
```yaml
version: '3.8'
services:
postgres:
image: postgres
restart: unless-stopped
environment:
POSTGRES_USER: movie_web_user
POSTGRES_DB: movie_web_backend
POSTGRES_PASSWORD: YourPasswordHere
networks:
- sudo-flix-network
sudo-flix-backend:
image: ghcr.io/sussy-code/backend:latest
restart: unless-stopped
environment:
MWB_SERVER__CORS: "https://movie-backend.example.tld https://movie.example.tld"
MWB_SERVER__PORT: 8080
MWB_POSTGRES__CONNECTION: postgresql://movie_web_user:YourPasswordHere@postgres:5432/movie_web_backend
MWB_CRYPTO__SESSION_SECRET: 32CHARACTERLONGSECRET
MWB_META__NAME: Server name
MWB_META__DESCRIPTION: Server Description
MWB_POSTGRES__MIGRATE_ON_BOOT: "true"
MWB_SERVER__TRUSTPROXY: "true"
MWB_SERVER__TRUSTCLOUDFLARE: "true"
# This is needed to resolve errors running migrations on some platforms - does not affect the application
MIKRO_ORM_MIGRATIONS_DISABLE_FOREIGN_KEYS: "false"
ports:
- "8080:8080"
depends_on:
- postgres
networks:
- sudo-flix-network
sudo-flix-frontend:
build:
context: https://github.com/sussy-code/smov.git
args:
TMDB_READ_API_KEY: "YourTMDBReadAPIKeyHere"
CORS_PROXY_URL: "https://cors.example.tld https://second.cors.example.tld"
BACKEND_URL: "https://backend.example.tld"
DMCA_EMAIL: "YourEmail"
PWA_ENABLED: "true"
APP_DOMAIN: "YourDomainHere"
OPENSEARCH_ENABLED: "true"
GA_ID: "Google ID Here"
ports:
- "80:80"
networks:
- sudo-flix-network
restart: unless-stopped
sudo-flix-proxy:
image: ghcr.io/sussy-code/sudo-proxy:latest
ports:
- "3000:3000"
networks:
- sudo-flix-network
restart: unless-stopped
networks:
sudo-flix-network:
driver: bridge
```
**Important:**
* Replace `YourPasswordHere` with your secure database password.
* Generate a strong session secret and replace `32CharacterLongStringHere`.
* Replace `TMDBReadAPIKey` with your api key learn more [here](../client/tmdb.mdx).
* replace `yourDomainHere` with whatever you'll be using to access your main site, like sudo-flix.app
* replace `meta__name` and `meta__description`
</Steps.Step>
<Steps.Step>
**Start the Backend:** Open a terminal in the directory containing `docker-compose.yml` and execute:
```bash
docker compose up --detach
```
</Steps.Step>
</Steps>
### Accessing Your Backend
Your services should be accessible on `(YourPrivateIP):port`. To share it outside your local network, you'll need to configure port forwarding or cloudflared tunnel.
### Optional: Implementing a Reverse Proxy
To enhance your SSL and domain configuration, it's advisable to establish a reverse proxy, such as Nginx. For an optimal choice in this regard, Cloudflare Zero Trust Tunnel is recommended. You can find more information [here](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/create-remote-tunnel/).