diff --git a/content/5.extra/2.selfhost.md b/content/5.extra/2.selfhost.md new file mode 100644 index 0000000..8e5722f --- /dev/null +++ b/content/5.extra/2.selfhost.md @@ -0,0 +1,97 @@ +### Guide to full Self-Deployment of movie-web with Docker Compose + +1. **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/) + +2. **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: + - movie-web-network + + movie-web-backend: + image: ghcr.io/movie-web/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" + ports: + - "8080:8080" + depends_on: + - postgres + networks: + - movie-web-network + + movie-web-frontend: + build: + context: https://github.com/movie-web/movie-web.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: + - movie-web-network + restart: unless-stopped + + movie-web-proxy: + image: ghcr.io/movie-web/simple-proxy:2.1.4 + ports: + - "3000:3000" + networks: + - movie-web-network + restart: unless-stopped + + networks: + movie-web-network: + driver: bridge + + **Important:** + * Replace `YourPasswordHere` with your secure database password. + * Generate a strong session secret and replace `32CharacterLongStringHere`. + ``` + **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](https://movie-web.github.io/docs/client/tmdb). + * replace `yourDomainHere` with whatever you'll be using to access your main site, like movie-web.app + * replace `meta__name` and `meta__description` +2. **Start the Backend:** Open a terminal in the directory containing `docker-compose.yml` and execute: + + ```bash + docker compose up --detach + ``` +**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/).