From 87376da52e3ca43e1f49a23307ec80d0309b3c86 Mon Sep 17 00:00:00 2001 From: Viren070 Date: Tue, 4 Mar 2025 01:21:40 +0000 Subject: [PATCH] feat: add improved guide on using my template compose --- docs/oracle.mdx | 248 ------------------------- docs/selfhosting/docker.mdx | 229 +++++++++++++++++++++++ docs/selfhosting/index.mdx | 16 ++ docs/selfhosting/oracle.mdx | 275 ++++++++++++++++++++++++++++ docs/selfhosting/template.mdx | 332 ++++++++++++++++++++++++++++++++++ sidebars.ts | 13 ++ 6 files changed, 865 insertions(+), 248 deletions(-) delete mode 100644 docs/oracle.mdx create mode 100644 docs/selfhosting/docker.mdx create mode 100644 docs/selfhosting/index.mdx create mode 100644 docs/selfhosting/oracle.mdx create mode 100644 docs/selfhosting/template.mdx diff --git a/docs/oracle.mdx b/docs/oracle.mdx deleted file mode 100644 index 01ad882..0000000 --- a/docs/oracle.mdx +++ /dev/null @@ -1,248 +0,0 @@ ---- -title: Oracle VPS -description: A guide on setting up an Oracle VPS. -keywords: [viren070, guides, viren070's guides] ---- - -# Free Oracle VPS - -## Introduction - -Oracle Cloud offers a Compute Instance with 4 OCPUs, 24GB RAM, and 200GB storage within their "Always Free" resources. -This guide will show you how to set that up. - -A VPS can be used for a variety of purposes, such as hosting a website, running a game server, or even as a remote desktop. -You can even use it to host all your [Stremio](/stremio/) addons and a debrid media server. - -:::info -To use the Oracle Cloud Free Tier, you need a valid credit/debit card. Virtual/Prepaid cards are not accepted. -::: - -## Setup - -### Setting up our VM instance - -1. Sign up for an Oracle Cloud account. - - 1. Go to the [Oracle Cloud website](https://www.oracle.com/cloud/free/) and click on "Start for free". - 2. Sign up for an account by filling in your details. - - :::tip - Many people tend to have issues with the verification process when - signing up for Oracle Cloud. If you face any issues, try one of the - following: - - - Ensure your billing address matches the address **exactly** as it appears on your bank statement or banking app. - - Use an inPrivate window on [Microsoft Edge](https://www.microsoft.com/en-us/edge) - - Use a different email address. - - Use a different card. - - Disable any adblockers/VPNs. -
- If you still face issues, you can try using a contacting Oracle support - through the live chat widget in the bottom right corner of the Oracle - Cloud website. - - ::: - -2. Once you have signed up, you will be taken to the Oracle Cloud dashboard. Click on `Create a VM instance` under the `Build` section. - - ![Oracle Cloud Dashboard](/img/oracle/dashboard.png) - -3. Give your instance a name. - -4. Configure the image and shape - - 1. Scroll down to `Image and shape`, and click on `Change Image`. Select the 'Ubuntu' image and 'Canonical Ubuntu 24.04' image name. - - ![Change Image](/img/oracle/select_image.png) - - 2. Just below the image, you will see the `Shape` section. Click on `Change Shape` and select the `Ampere` series `VM.Standard.A1.Flex` shape. Set the OCPUs to 4, and the memory to 24GB. - ![Change Shape](/img/oracle/select_shape.png) - -5. Generate an SSH key pair. If you already have an SSH key pair, you can skip this step. - - 1. Open a terminal on your local machine. - 2. Run the following command to generate an SSH key pair, replacing `your_email@example.com` with your email address. - - ```bash - ssh-keygen -t ed25519 -C "your_email@example.com" - ``` - - - When prompted for which file to save the key in, press `Enter` to save it in the default location. If you already have an SSH key pair, you can save it in a different location. But make sure to remember where you saved it. - - When prompted to enter a passphrase, you **should** enter one. You can generate a passphrase using a password manager like [Bitwarden](https://bitwarden.com/) or [Proton Pass](https://proton.me/pass). - -
- :::info - On older systems, where the ed25519 algorithm is not supported, you can use the rsa algorithm: - - ```bash - ssh-keygen -t rsa -b 4096 -C "your_email@example.com" - ``` - - ::: - - 3. We will now need to add our SSH key to our SSH agent. Before we do that, we need to start the SSH agent. Open a new **Administrator** PowerShell window and run the following commands: - ``` - Get-Service -Name ssh-agent | Set-Service -StartupType Manual - Start-Service ssh-agent - ``` - 4. Run the following command in your **non-administrator** terminal to add your SSH key to the SSH agent: - - ```bash - ssh-add C:/Users/your_username/.ssh/id_ed25519 - ``` - - - If you saved your SSH key in a different location, replace `C:/Users/your_username/.ssh/id_ed25519` with the path to your SSH key. - - 5. You will now have two files in your `~/.ssh` directory: `id_ed25519` and `id_ed25519.pub`. The `.pub` file is your public key, which you will need for the next step. - -6. In the `Add SSH keys` section, click the `Upload public key files (.pub)` button and upload the `.pub` file you generated in the previous step. - -7. Configure our boot volume. - - 1. Scroll down to `Boot volume` and check the `Specify a custom boot volume size` box. - 2. Set the boot volume size to 200. - 3. Set the `Boot volume performance to `120`. - -8. Finally, click on `Create` to create your VM instance. - -:::tip -You may encounter an `Out of capacity` error when creating your VM instance. This is because the free tier has a limited number of instances available: -![Out of capacity error](/img/oracle/availability_error.png) - -You can try again later, or you can try creating the instance in a different `Availability Domain` by scrolling back up to the top to the `Placement` section. - -You can also switch to a PAYG account, which will allow you to create instances without any restrictions. As long as you stay within the free tier limits, you won't be charged. -You can also set up a $1 budget alert to ensure you don't go over the free tier limits. - -
- How to upgrade to a PAYG account -
- -1. Go back to the Oracle Cloud dashboard. -2. Click on the hamburger menu in the top left corner and scroll down to `Billing and Cost Management`. -3. Under the `Billing` section, click on `Upgrade and Manage Payment` -4. Click on `Upgrade to Pay-As-You-Go` and follow the instructions. - -It can take up to 24 hours for the upgrade to take effect. You will receive an email once the upgrade is complete. - -
-
- -
- How to set up a $1 budget alert -
- - 1. Go back to the Oracle Cloud dashboard. - 2. Click on the hamburger menu in the top left corner and scroll down to `Billing and Cost Management`. - 3. Under the `Cost Management` section, click on `Budgets`. - 4. Click on `Create Budget`. - 5. Use the following settings: - - Budget Name: `dont_charge_me` - - Budget Amount: `1` - - Day of the month to begin budget processing: `1` - - Threshold Metric: `Forecast Spend` - - Threshhold Type: `Percentage of Budget` - - Threshold: `1%` - - Email Recipients: Your email address - - Email message: `Your current usage exceeds Always Free resources. Please check your usage to avoid charges.` - 6. Click on `Create`. -
-
- -
- How to check if my current usage is forecast to exceed the free tier limits -
- - 1. Go back to the Oracle Cloud dashboard. - 2. Click on the hamburger menu in the top left corner and scroll down to `Billing and Cost Management`. - 3. Under the `Cost Management` section, click on `Cost Analysis`. - 4. Check the `Show Forecast` box. - 5. Set the `End Date` to a future date, such as after a few months. - 6. Click on `Apply`. - 7. You will now see a forecast of your usage. There will be a graph showing your usage over time, and a table showing your usage by service. - 8. Ensure it is all 0. -
- -
- -::: - -9. Your instance will now begin provisioning. This can take a few minutes. Once it is done, make your way to the dashboard of your instance. You should - already be on the dashboard, but if you aren't, you can find it by clicking on the hamburger menu in the top left corner and scrolling down to `Compute` and then `Instances`. - -### Connecting to our VM instance - -10. Copy the public IP address of your instance. - - ![Instance Dashboard](/img/oracle/instance_dashboard.png) - -11. Open a terminal on your local machine and run the following command, replacing `your_ip` with the public IP address of your instance. - - ```bash - ssh ubuntu@your_ip - ``` - - - If you are prompted to add the host to your list of known hosts, type `yes` and press `Enter`. - - If you set a passphrase for your SSH key, you will be prompted to enter it. (You will not see any characters as you type, but it is being entered.) - :::tip - To avoid having to type the IP address every time you want to connect to your instance, you can create a Windows Terminal Profile. - - To do this: - - 1. Open Windows Terminal and click on the down arrow next to the tabs. Then, while holding down the `Shift` key, click on `Settings`. - 2. This will open the `settings.json` file in your default text editor. It will look something like this: - - ```json - { - "$help": ..., - "$schema": ..., - "actions": ..., - ... - "profiles": { - "defaults": {}, - "list": [ - ... - ] - } - } - ``` - - 3. Add the following profile to the `profiles` list, replacing `your_ip` with the public IP address of your instance: - - ```json - { - "closeOnExit": "never", - "name": "Oracle VPS", - "commandline": "ssh ubuntu@your_ip", - }, - ``` - - ::: - -12. You are now connected to your VM instance. You can now install any software you need, set up a web server, or do anything - else you need to do. - -## Extra guides - -### Hosting Stremio addons - -If you are interesting in self hosting Stremio addons, you can use my [template compose.yaml](https://github.com/Viren070/stremio-addons-docker-compose-template). -The template contains more than just Stremio addons, so ensure you modify it to your needs. - -### Opening ports - -By default, all ports are closed on your Oracle VPS. You will need to open the ports you want to use. - -1. Go to the dashboard of your instance. -2. Under `Primary VNIC`, click on the link next to `Subnet:`. -3. Under `Security Lists`, click on the `Default Security List for vcn-...`. -4. Click on `Add Ingress Rules`. -5. Add the following rules: - - `Source Type`: `CIDR` - - `Source CIDR`: `0.0.0.0/0` - - `IP Protocol`: `TCP` - - `Source Port Range`: `All` - - `Destination Port Range`: The port you want to open, such as `443` for HTTPS. - - `Description`: A description of the rule, such as `Allow HTTPS traffic`. -6. Click on `Add Ingress Rules`, or `Another Ingress Rule` if you want to add more rules. diff --git a/docs/selfhosting/docker.mdx b/docs/selfhosting/docker.mdx new file mode 100644 index 0000000..f532c0f --- /dev/null +++ b/docs/selfhosting/docker.mdx @@ -0,0 +1,229 @@ +--- +title: Docker +description: A guide on installing Docker and explaining the basics. +keywords: [viren070, guides, viren070's guides] +--- + +# Docker + +## Prerequisites + +Before you start, you need to have a VPS. +If you don't have a VPS, you can get a free one from Oracle Cloud, which you should have already set up in the [previous guide](/selfhosting/oracle). + +I will be explaining, in detail, how docker works as I do not think you should blindly copy templates without understanding what they do. +This will help you troubleshoot issues and make changes to the templates as needed. (and hopefully minimise the amount of people asking for help, though I am always happy to help and you can reach out to me on [Discord](https://discord.viren070.me)) + +If you are already familiar with Docker, you can skip ahead to the [installation section](#installing-docker). + +## What is Docker? + +Docker is a platform for developing, shipping, and running applications in containers. +It allows you to package your application and all its dependencies into a single image that can be run on any machine. +This makes it easy to deploy applications in a consistent and reproducible way. + +In simple terms, it allows you to run applications in isolated environments called "**_containers_**". +Each container has its own filesystem, networking, and process space, so you can run multiple containers on the same machine without them interfering with each other. + +We use **images** sourced from registries like Docker Hub to create containers. +Images are read-only templates that contain everything needed to run an application, including the code, runtime, libraries, environment variables, and configuration files. + +For a more in-depth explanation, you can check the [official Docker documentation](https://docs.docker.com/get-started/docker-overview/). + +## How to use Docker + +Docker is controlled using the `docker` command-line tool. For more information on the commands available, you can check the [Docker CLI reference](https://docs.docker.com/reference/cli/docker/) and/or this [Learn X in Y minutes](https://learnxinyminutes.com/docs/docker/) guide. + +For this guide, we will be using Docker to run services in containers through Docker Compose and a `compose.yaml` file. (Read this [guide on YAML Syntax](https://learnxinyminutes.com/docs/yaml/) if you are unfamiliar with it.) + +A compose.yaml file is a configuration file that defines how to run services in containers. +It specifies the services, networks, and volumes needed to run the application and how they interact with each other. + +Here is an example of a `compose.yaml` file that defines a simple web server service: + +```graphql +services: + + myservice1: + image: image1:tag1 + container_name: mycontainer1 + ports: + - "8080:80" + environment: + - ENV_VAR1=value1 + - ENV_VAR2=${SERVICE1_VAR2:-default_value} # optional value that defaults to default_value or an empty string if no default is provided + - ENV_VAR3=${SERVICE1_VAR3?Error message} # required value that throws an error if not set + env_file: + - .custom.env + volumes: + - ./tmp:/tmp + - image-data:/data + labels: + - "mylabel1=myvalue1" + restart: unless-stopped + + myservice2: + image: image2:tag2 + container_name: mycontainer2 + restart: unless-stopped + expose: + - 8080 + environment: + ENV_VAR2: value2 + volumes: + - ./tmp:/tmp + - /opt/image2:/data + labels: + mylabel2: myvalue2 + +volumes: + image-data: + +``` + +In this example, we define two services, `myservice1` and `myservice2`, each with its own image, ports, environment variables, volumes, labels, and restart policy. + +Let me break down the components of the `compose.yaml` file: + +At the root level, we have the `services` key, which is a nested collection of service definitions. +This tells Docker Compose which services to run and how to configure them. +Each service definition has the following keys: + +- `image`: The image to use for the service. + + - You can use an image from a registry like [Docker Hub](https://hub.docker.com) or a local image. For example, if we wanted to use my image for `AIOStreams`, we would use `viren070/aiostreams:latest`. + This image is viewable at [https://hub.docker.com/r/viren070/aiostreams](https://hub.docker.com/r/viren070/aiostreams). + - We can also **optionally** specify a tag to use with the image. If no tag is specified, Docker will default to `latest`. A tag is a version identifier for an image, typically following [semantic versioning](https://semver.org/). + - Docker Hub is the default registry for Docker images, but you can also use other registries like [GitHub Container Registry](https://ghcr.io) or [Quay](https://quay.io) e.g. for the image, you would use `ghcr.io/viren070/aiostreams:latest`. + + :::tip + Sometimes, there is no image available for the service you want to run, in that case, you can create your own image using a `Dockerfile`. This can also be a remote + `Dockerfile` that is hosted on GitHub or GitLab. + +
+ How to use a remote Dockerfile +
+ ```graphql + services: + myservice: + build: + context: https://github.com/mccoy88f/OMG-Premium-TV.git + dockerfile: Dockerfile + image: myservice:latest + ``` + + In this example, we are using a `Dockerfile` hosted on GitHub to build the image for the `myservice` service. + We tell Docker Compose to use the `Dockerfile` in the root of the repository at `https://github.com/mccoy88f/OMG-Premium-TV.git` + to build the image for the service and then name the image `myservice:latest`. + +
+
+ + ::: + +- `container_name`: The name to use for the container. + - This is optional, and if not specified, Docker will generate a name for you using the format `__`. +- `restart`: The restart policy for the container. + - This specifies when the container should be restarted. The possible values are `no`, `always`, `on-failure`, `unless-stopped`, and `always`. + - By setting the restart policy to `unless-stopped`, the container will be restarted unless it is explicitly stopped by the user. +- `environment`: Environment variables to set in the container. + - This is a list of key-value pairs or a list of strings in the format `KEY=VALUE`. This gives the container access to environment variables that can be used to configure the application. + - However, environment variables can also be used throughout the compose.yaml file using the `${}` syntax. This allows you to reference other environment variables or provide default values. + These environment variables are loaded from the `.env` file in the current directory and any other system environment variables. + - Since $ is a special character in YAML, if we want to use a literal $, we need to escape it with another $, e.g. `$$`. +- We can also load environment variables from a file using the `env_file` key. This will load the environment variables from the specified file into the container. + +### Volumes + +Volumes are used to persist data generated by and used by Docker containers. +They are directories on the host machine that are mounted into the container. +This allows the container to read and write data to the host machine's filesystem. + +If we do not use volumes, the data generated by the container will be lost when the container is stopped or removed. +If a folder within the container is storing user data, we should use a volume to persist that data, otherwise it will be lost when the container is restarted. + +The syntax for defining a volume is, in general, `host-path:container-path`. Host path is the path on the host machine, and container path is the path within the container. + +There are two types of volumes: named volumes and bind mounts. +Named volumes are managed by Docker and are stored in a specific location on the host machine - `/var/lib/docker/volumes`. +Bind mounts are specified by providing the path to a directory on the host machine. This allows you to specify the exact location where the data should be stored. + +To use a named volume, you can define it in the `volumes` section of the `compose.yaml` file. +For example, `volumes: image-data:` defines a named volume called `image-data`. +We use `image-data:/data` to mount the named volume `image-data` to the `/data` directory within the container. + +To use a bind mount, you can specify the host path directly in the `volumes` section. Either an absolute path or a relative path can be used. +For example, `./tmp:/tmp` mounts the `tmp` directory in the current working directory to the `/tmp` directory within the container. +And `/opt/image2:/data` mounts the `/opt/image2` directory on the host machine to the `/data` directory within the container. + +### Ports + +Ports are used to expose services running inside a container to the outside world. +They allow external clients to communicate with the services running inside the container. + +The expose key, functionally does almost nothing, it is a way to document the ports that the container listens on. +It does not actually publish the ports, to do that, you need to use the ports key. + +We use this when there is no need to expose the port to the host machine, but we still want to document it. +For example, if we were putting all our services behind a reverse proxy, we would not need to map the ports to the host machine, as our reverse proxy would be able to communicate with the services directly, and then we would only +map the reverse proxy's port to the host machine. (typically port 80 and/or 443) + +The syntax for defining a port is `host-port:container-port`, e.g. `8080:80`. +Host port is the port on the host machine, and container port is the port on which the service is listening inside the container. +For example, our `myservice1` service is listening on port `80` inside the container, and we are exposing it on port `8080` on the host machine. +This will make the service accessible at `http://host-ip:8080` or `http://localhost:8080`. + +Without defining the ports key, the service will not be accessible from outside the container. + +:::note +If you are running the container on a server that is not your local machine, you may need to open the port on the server's firewall to allow incoming connections. +::: + +## Installing Docker + +To install Docker on your VPS, you can follow the official installation guide at [https://get.docker.com](https://get.docker.com). + +The installation process is straightforward and involves running a script that installs Docker and its dependencies. + +The steps are copied here for convenience: + +1. Download the script: + + ```bash + $ curl -fsSL https://get.docker.com -o install-docker.sh + ``` + +2. Verify the script's content (optional): + + ```bash + $ cat install-docker.sh + ``` + +3. Run the script with `--dry-run` to verify the steps it executes (optional): + + ```bash + $ sh install-docker.sh --dry-run + ``` + +4. Run the script either as root, or using `sudo` to perform the installation: + + ```bash + $ sudo sh install-docker.sh + ``` + +After running the script, Docker should be installed on your VPS. + +You can verify the installation by running the following command: + +```bash +$ docker --version +``` + +This should output the version of Docker installed on your VPS. + +## Conclusion + +In this guide, we learned about Docker and how to use it to run services in containers. +We also learned how to define services in a `compose.yaml` file and the different keys that can be used to configure a service. + +In the next guide, we will go through my [template compose.yaml](/selfhosting/template) and how to use it to host Stremio addons, Seanime, A debrid media server and more. diff --git a/docs/selfhosting/index.mdx b/docs/selfhosting/index.mdx new file mode 100644 index 0000000..33d94e2 --- /dev/null +++ b/docs/selfhosting/index.mdx @@ -0,0 +1,16 @@ +--- +title: Self Hosting +description: A guide on how to self host services with Docker on a VPS. +keywords: [viren070, guides, viren070's guides] +--- + +# Self Hosting + +This series of guides will show you how to self host services with Docker on a completely free VPS from oracle using Traefik as a reverse proxy completely from +scratch. + +```mdx-code-block +import DocCardList from '@theme/DocCardList'; + + +``` diff --git a/docs/selfhosting/oracle.mdx b/docs/selfhosting/oracle.mdx new file mode 100644 index 0000000..6f97631 --- /dev/null +++ b/docs/selfhosting/oracle.mdx @@ -0,0 +1,275 @@ +--- +title: Oracle VPS +description: A guide on setting up an Oracle VPS. +keywords: [viren070, guides, viren070's guides] +--- + +# Free Oracle VPS + +## Introduction + +Oracle Cloud offers a Compute Instance with 4 OCPUs, 24GB RAM, and 200GB storage within their "Always Free" resources. +This guide will show you how to set that up. + +A VPS can be used for a variety of purposes, such as hosting a website, running a game server, or even as a remote desktop. +You can even use it to host all your [Stremio](/stremio/) addons and a debrid media server. + +:::info +To use the Oracle Cloud Free Tier, you need a valid credit/debit card. Virtual/Prepaid cards are not accepted. +::: + +## Setup + +### Setting up our VM instance + +1. Sign up for an Oracle Cloud account. + + 1. Go to the [Oracle Cloud website](https://www.oracle.com/cloud/free/) and click on "Start for free". + 2. Sign up for an account by filling in your details. + + :::tip + Many people tend to have issues with the verification process when + signing up for Oracle Cloud. If you face any issues, try one of the + following: + + - Ensure your billing address matches the address **exactly** as it appears on your bank statement or banking app. + - Use an inPrivate window on [Microsoft Edge](https://www.microsoft.com/en-us/edge) + - Use a different email address. + - Use a different card. + - Disable any adblockers/VPNs. + + If you still face issues, you can try using a contacting Oracle support + through the live chat widget in the bottom right corner of the Oracle + Cloud website. + + ::: + +2. Once you have signed up, you will be taken to the Oracle Cloud dashboard. Click on `Create a VM instance` under the `Build` section. + + ![Oracle Cloud Dashboard](/img/oracle/dashboard.png) + +3. Give your instance a name. + +4. Configure the image and shape + + 1. Scroll down to `Image and shape`, and click on `Change Image`. Select the 'Ubuntu' image and 'Canonical Ubuntu 24.04' image name. + + ![Change Image](/img/oracle/select_image.png) + + 2. Just below the image, you will see the `Shape` section. Click on `Change Shape` and select the `Ampere` series `VM.Standard.A1.Flex` shape. Set the OCPUs to 4, and the memory to 24GB. + ![Change Shape](/img/oracle/select_shape.png) + +5. Generate an SSH key pair. If you already have an SSH key pair, you can skip this step. + + 1. Open a terminal on your local machine. + 2. Run the following command to generate an SSH key pair, replacing `your_email@example.com` with your email address. + + ```bash + ssh-keygen -t ed25519 -C "your_email@example.com" + ``` + + - When prompted for which file to save the key in, press `Enter` to save it in the default location. If you already have an SSH key pair, you can save it in a different location. But make sure to remember where you saved it. + - When prompted to enter a passphrase, you **should** enter one. You can generate a passphrase using a password manager like [Bitwarden](https://bitwarden.com/) or [Proton Pass](https://proton.me/pass). + +
+ :::info + On older systems, where the ed25519 algorithm is not supported, you can use the rsa algorithm: + + ```bash + ssh-keygen -t rsa -b 4096 -C "your_email@example.com" + ``` + + ::: + + 3. We will now need to add our SSH key to our SSH agent. Before we do that, we need to start the SSH agent. Open a new **Administrator** PowerShell window and run the following commands: + ``` + Get-Service -Name ssh-agent | Set-Service -StartupType Manual + Start-Service ssh-agent + ``` + 4. Run the following command in your **non-administrator** terminal to add your SSH key to the SSH agent: + + ```bash + ssh-add C:/Users/your_username/.ssh/id_ed25519 + ``` + + - If you saved your SSH key in a different location, replace `C:/Users/your_username/.ssh/id_ed25519` with the path to your SSH key. + + 5. You will now have two files in your `~/.ssh` directory: `id_ed25519` and `id_ed25519.pub`. The `.pub` file is your public key, which you will need for the next step. + +6. In the `Add SSH keys` section, click the `Upload public key files (.pub)` button and upload the `.pub` file you generated in the previous step. + +7. Configure our boot volume. + + 1. Scroll down to `Boot volume` and check the `Specify a custom boot volume size` box. + 2. Set the boot volume size to 200. + 3. Set the `Boot volume performance to `120`. + +8. Finally, click on `Create` to create your VM instance. + +:::tip +You may encounter an `Out of capacity` error when creating your VM instance. This is because the free tier has a limited number of instances available: +![Out of capacity error](/img/oracle/availability_error.png) + +You can try again later, or you can try creating the instance in a different `Availability Domain` by scrolling back up to the top to the `Placement` section. + +You can also switch to a PAYG account, which will allow you to create instances without any restrictions. As long as you stay within the free tier limits, you won't be charged. +You can also set up a $1 budget alert to ensure you don't go over the free tier limits. + +
+ How to upgrade to a PAYG account +
+ +1. Go back to the Oracle Cloud dashboard. +2. Click on the hamburger menu in the top left corner and scroll down to `Billing and Cost Management`. +3. Under the `Billing` section, click on `Upgrade and Manage Payment` +4. Click on `Upgrade to Pay-As-You-Go` and follow the instructions. + +It can take up to 24 hours for the upgrade to take effect. You will receive an email once the upgrade is complete. + +
+
+ +
+ How to set up a $1 budget alert +
+ + 1. Go back to the Oracle Cloud dashboard. + 2. Click on the hamburger menu in the top left corner and scroll down to `Billing and Cost Management`. + 3. Under the `Cost Management` section, click on `Budgets`. + 4. Click on `Create Budget`. + 5. Use the following settings: + - Budget Name: `dont_charge_me` + - Budget Amount: `1` + - Day of the month to begin budget processing: `1` + - Threshold Metric: `Forecast Spend` + - Threshhold Type: `Percentage of Budget` + - Threshold: `1%` + - Email Recipients: Your email address + - Email message: `Your current usage exceeds Always Free resources. Please check your usage to avoid charges.` + 6. Click on `Create`. +
+
+ +
+ How to check if my current usage is forecast to exceed the free tier limits +
+ + 1. Go back to the Oracle Cloud dashboard. + 2. Click on the hamburger menu in the top left corner and scroll down to `Billing and Cost Management`. + 3. Under the `Cost Management` section, click on `Cost Analysis`. + 4. Check the `Show Forecast` box. + 5. Set the `End Date` to a future date, such as after a few months. + 6. Click on `Apply`. + 7. You will now see a forecast of your usage. There will be a graph showing your usage over time, and a table showing your usage by service. + 8. Ensure it is all 0. +
+ +
+ +::: + +9. Your instance will now begin provisioning. This can take a few minutes. Once it is done, make your way to the dashboard of your instance. You should + already be on the dashboard, but if you aren't, you can find it by clicking on the hamburger menu in the top left corner and scrolling down to `Compute` and then `Instances`. + +### Connecting to our VM instance + +10. Copy the public IP address of your instance. + + ![Instance Dashboard](/img/oracle/instance_dashboard.png) + +11. Open a terminal on your local machine and run the following command, replacing `your_ip` with the public IP address of your instance. + + ```bash + ssh ubuntu@your_ip + ``` + + - If you are prompted to add the host to your list of known hosts, type `yes` and press `Enter`. + - If you set a passphrase for your SSH key, you will be prompted to enter it. (You will not see any characters as you type, but it is being entered.) + :::tip + To avoid having to type the IP address every time you want to connect to your instance, you can create a Windows Terminal Profile. + +
+ How to create a Windows Terminal Profile +
+ To do this: + + 1. Open Windows Terminal and click on the down arrow next to the tabs. Then, while holding down the `Shift` key, click on `Settings`. + 2. This will open the `settings.json` file in your default text editor. It will look something like this: + + ```json + { + "$help": ..., + "$schema": ..., + "actions": ..., + ... + "profiles": { + "defaults": {}, + "list": [ + ... + ] + } + } + ``` + + 3. Add the following profile to the `list` array in the `profiles` object, replacing `your_ip` with the public IP address of your instance: + + ```json + { + "closeOnExit": "never", + "name": "Oracle VPS", + "commandline": "ssh ubuntu@your_ip", + }, + ``` + It should look something like this (the `...` represents other objects in the file, that are abstracted for brevity): + ```json + { + "$help": ..., + "$schema": ..., + "actions": ..., + ... + "profiles": { + "defaults": {}, + "list": [ + { + "closeOnExit": "never", + "name": "Oracle VPS", + "commandline": "ssh ubuntu@your_ip", + }, + ... + ] + } + } + ``` + 4. Save the file and close the text editor. + 5. Close Windows Terminal and reopen it. When you click on the down arrow next to the tabs, you should see a new profile called `Oracle VPS`. Click on it to connect to your instance. + +
+
+ ::: + +12. You are now connected to your VM instance. You can now install any software you need, set up a web server, or do anything + else you need to do. + +## Extra guides + +### Hosting Stremio addons + +If you are interesting in self hosting Stremio addons, you can use my [template compose.yaml](https://github.com/Viren070/stremio-addons-docker-compose-template). +The template contains more than just Stremio addons, so ensure you modify it to your needs. + +### Opening ports + +By default, all ports are closed on your Oracle VPS. You will need to open the ports you want to use. + +1. Go to the dashboard of your instance. +2. Under `Primary VNIC`, click on the link next to `Subnet:`. +3. Under `Security Lists`, click on the `Default Security List for vcn-...`. +4. Click on `Add Ingress Rules`. +5. Fill in the following details: + - `Source Type`: `CIDR` + - `Source CIDR`: `0.0.0.0/0` + - `IP Protocol`: `TCP` + - `Source Port Range`: `All` + - `Destination Port Range`: The port you want to open, such as `443` for HTTPS. + - `Description`: A description of the rule, such as `Allow HTTPS traffic`. +6. Click on `Add Ingress Rules`, or `Another Ingress Rule` if you want to add more rules. diff --git a/docs/selfhosting/template.mdx b/docs/selfhosting/template.mdx new file mode 100644 index 0000000..0df17d6 --- /dev/null +++ b/docs/selfhosting/template.mdx @@ -0,0 +1,332 @@ +--- +title: Template +description: A guide on using my template Docker Compose file. +keywords: [viren070, guides, viren070's guides] +--- + +# Template + +This guide will show you how to use my template Docker Compose file to quickly deploy services. + +Having followed my previous guides, you should have a basic understanding of how to deploy services with Docker Compose. +This section will focus on using [my template `compose.yaml`](https://github.com/Viren070/stremio-addons-docker-compose-template). + +## What is it for? + +The "template" is just a standard `compose.yaml` file that contains a bunch of services in one file. +It makes use of environment variables so that the `compose.yaml` file can be used by anyone without having to edit the file itself. +Only the `.env` file needs to be edited to fill in the necessary environment variables. + +This `compose.yaml` uses [Traefik](https://traefik.io) as a reverse proxy to route traffic to the correct service. +All our services are put behind Traefik, which allows us to access all services on the same port (80/443) and Traefik will route the traffic to the correct service. +This means that port 80 and 443 are the only ports that need to be open on your server. + +
+What services are available in the template? +
+ **Stremio related services:** + + - [AIOStreams](https://github.com/Viren070/AIOStreams) + - [AIOStremio](https://github.com/Viren070/AIOStremio) + - [Comet](https://github.com/g0ldyy/comet) + - [MediaFusion](https://github.com/mhdzumair/MediaFusion) + - [StremThru](https://github.com/MunifTanjim/stremthru) + - [Stremio-Jackett](https://github.com/aymene69/stremio-jackett) + - [Jackettio](https://github.com/arvida42/jackettio) + - [EasyNews+](https://github.com/sleeyax/stremio-easynews-addon) + - [MediaFlow Proxy](https://github.com/mhdzumair/mediaflow-proxy) + - [Catalog Providers](https://github.com/redd-ravenn/stremio-catalog-providers) + - [TMDB Addon](https://github.com/mrcanelas/tmdb-addon) + - [Stremio Trakt Addon](https://github.com/redd-ravenn/stremio-trakt-addon) + - [Stremio Server](https://github.com/Stremio/server-docker) + - This is the official Stremio server docker image. This handles the downloading and transcoding of streams. This is useful if you use Stremio on devices + that don't have a server bundled with it, like on iOS on Stremio Web. It will allow you to stream torrents on those devices. Debrid streams may not be transcoded on all clients, however. + - [Addon Manager](https://github.com/redd-ravenn/stremio-addon-manager) + + **Supporting services:** + + - [Prowlarr](https://github.com/Prowlarr/Prowlarr) + - [Jackett](https://github.com/Jackett/Jackett) + - [NZBHydra2](https://github.com/theotherp/nzbhydra2) + - This is an indexer for NZB indexers. Which is mostly useful for Torbox users with the BYOI feature. + - [Zilean](https://github.com/iPromKnight/zilean) + - This is a [DMM](https://debridmediamanager.com) scraper. + - [FlareSovlerr](https://github.com/FlareSolverr/FlareSolverr) / [Byparr](https://github.com/ThePhaseless/Byparr) + - Useful for bypassing Cloudflare's anti-bot protection for scraping purposes. + - [Cloudflare Warp](https://github.com/cmj2002/warp-docker) + - This is a Cloudflare Warp client. It allows you to bypass blocks. For example, Torrentio blocks requests from some VPS providers (like Oracle Cloud). + In this case, you can use Cloudflare Warp to proxy your requests through it which can be used for AIOStreams, Prowlarr, etc. + - [Traefik](https://github.com/traefik/traefik) + - This is a reverse proxy. It is used to route traffic to the correct service. It means that you can access all services on the same port (80/443) and Traefik will route the traffic to the correct service. + It also allows for automatic SSL certificate generation using Let's Encrypt, which is required for Stremio addons as Stremio requires HTTPS to install addons. + + **Server management services:** + + To help with managing the server, the following services are included: + + - [Dozzle](https://github.com/amir20/dozzle) - A simple real time log viewer for docker containers with a web based UI. + - [Watchtower](https://github.com/containrrr/watchtower) - Automatically update your Docker containers to the latest version. + - [Uptime Kuma](https://github.com/louislam/uptime-kuma) - A self-hosted monitoring tool for your services. + - This is useful for monitoring the status of your services and receiving alerts. You do have to set up your services manually, but this can be done through the web interface. + - [Dash.](https://github.com/MauriceNino/dashdot) - A simple dashboard to monitor your server. + - [Honey](https://github.com/dani3l0/honey) - Beautiful, customisable, startpage for your server to access all your services. + - [Flame](https://github.com/pawelmalak/flame) - A simple startpage, requiring minimal setup, for your server. + + I have provided 2 startpages, Honey and Flame. You can choose which one you want to use. You can also use both if you want. + The reason being that Honey requires a bit more setup, as you need to edit honey's config.json file and replace the urls with your own. + I have provided my template which has all the images, so its not too hard to do. Flame is a bit more simple and requires no setup. + But, it also has no images and you would have to provide that yourself for each service. Honey, IMO, looks far better. + + **Other services:** + + This template also includes other services: + + - [Seanime](https://github.com/5rahim/seanime) - Beautiful open-source media server with a web interface and desktop app for anime and manga. + - [SearXNG](https://github.com/searxng/searxng) - Privacy-respecting metasearch engine. + - [Plausible Analytics](https://github.com/plausible/analytics/) - Simple, privacy-friendly and open-source web analytics. (Used on this site) + +
+
+ +### Profiles + +My compose.yaml makes use of profiles to make it easier to deploy only specific services. +A profile is a group of services that are related to each other. For example, the `stremio` profile contains services that are related to Stremio. + +The profiles are as follows: + +- `default` +- `stremio` +- `debrid_media_server` +- `nzbhydra2` +- `indexers` +- `seanime` +- `plausible` +- `searxng` +- `all` + +The default profile cannot be specified, it will always be included no matter what profiles you choose or don't choose. +Other profiles contain services that are related to the profile name. + +
+What services are included in each profile? +
+ + The obvious ones are as follows: + - `all` includes all services. + - `nzbhydra2` only includes NZBHydra2. + - `seanime` only includes Seanime. + - `plausible` only includes Plausible. + - `searxng` only includes SearXNG. + + The rest can be seen in the table below: + + | Service / Profile | default | stremio | debrid_media_server | indexers | + |:-----------------:|:------------------:|:------------------:|:-------------------:|:------------------:| + | Traefik | :white_check_mark: | - | - | - | + | Flame | :white_check_mark: | - | - | - | + | dash. | :white_check_mark: | - | - | - | + | honey | :white_check_mark: | - | - | - | + | Uptime Kuma | :white_check_mark: | - | - | - | + | Watchtower | :white_check_mark: | - | - | - | + | Dozzle | :white_check_mark: | - | - | - | + | AIOStreams | :x: | :white_check_mark: | :x: | :x: | + | TMDB Addon | :x: | :white_check_mark: | :x: | :x: | + | Easynews+ | :x: | :white_check_mark: | :x: | :x: | + | Comet | :x: | :white_check_mark: | :x: | :x: | + | MediaFlow Proxy | :x: | :white_check_mark: | :x: | :x: | + | MediaFusion | :x: | :white_check_mark: | :x: | :x: | + | StremThru | :x: | :white_check_mark: | :x: | :x: | + | Stremio-Jackett | :x: | :white_check_mark: | :x: | :x: | + | Jackettio | :x: | :white_check_mark: | :x: | :x: | + | Zilean | :x: | :white_check_mark: | :white_check_mark: | :x: | + | Prowlarr | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | + | Jackett | :x: | :white_check_mark: | :x: | :white_check_mark: | + | NZBHydra2 | :x: | :x: | :x: | :white_check_mark: | + | Flaresolverr | :x: | :white_check_mark: | :white_check_mark: | :x: | + | Byparr | :x: | :white_check_mark: | :white_check_mark: | :x: | + | Stremio Server | :x: | :white_check_mark: | :x: | :x: | + | Warp | :x: | :white_check_mark: | :white_check_mark: | :x: | + | AIOStremio | :x: | :white_check_mark: | :x: | :x: | + | OMG TV Addon | :x: | :white_check_mark: | :x: | :x: | + | Addon Manager | :x: | :white_check_mark: | :x: | :x: | + | Stremio Catalogs | :x: | :white_check_mark: | :x: | :x: | + | Stremio Trakt | :x: | :white_check_mark: | :x: | :x: | + | Seanime | :x: | :x: | :x: | :x: | + | SearXNG | :x: | :x: | :x: | :x: | + | Plausible | :x: | :x: | :x: | :x: | + | Blackholes | :x: | :x: | :white_check_mark: | :x: | + | Radarr/Sonarr | :x: | :x: | :white_check_mark: | :x: | + | Plex | :x: | :x: | :white_check_mark: | :x: | + | Zurg | :x: | :x: | :white_check_mark: | :x: | + | RClone | :x: | :x: | :white_check_mark: | :x: | + +
+
+ +After you have chosen which profiles you are going to use, keep them in mind, as you will now need to fill in +the .env file with the necessary environment variables. + +## Setup + +1. First, you should ensure Docker is installed per https://get.docker.com/ (If you followed my previous guides, you should already have Docker installed). + +2. Next, you should make sure both port 80 and 443 are open on your server. This is required for Traefik to work correctly. + :::tip + If you are using Oracle Cloud, you can follow [these steps](/selfhosting/oracle#opening-ports) to open the ports. + ::: + +3. Then, connect to your server on a terminal. Typically using the command below, or if you created a Windows Terminal profile, you can use that. + + ```bash + ssh ubuntu@your-server-ip + ``` + +4. I would recommend creating another directory to store the files in. You can replace `server` with any name you want. This will be the name that docker uses for the "project" name. + + ```bash + mkdir server + cd server + ``` + +5. Then, we run the following command to download the necessary files. This script + will download the files and place them in the correct directories. + + ```bash + curl https://raw.githubusercontent.com/Viren070/stremio-addons-docker-compose-template/refs/heads/main/install.sh | bash + ``` + +6. You can now confirm that the files have been downloaded by running the following command: + + ```bash + ls -a + ``` + + You should see the following files and directories: + + ```bash + . .. .env compose.yaml data + ``` + +7. Next, you should edit the `.env` file to fill in the necessary environment variables. You can do this by running the following command. + + ```bash + nano .env + ``` + + - You should only fill in the environment variables for the services you are going to deploy. + However, note that if you want to omit a service from a profile, you will have to edit the `compose.yaml` file. This is detailed later. + Otherwise, the full profile environment variables will be required. e.g. If you are using the stremio profile, + all the environment variables under the stremio profile will be required, unless you edit the `compose.yaml` file. + + :::tip + If you are having issues using a CLI text editor like nano, you can instead edit the file on your local machine using a text editor like Notepad++ or Visual Studio Code. + And then upload the file to your server using `scp` or simply copy-pasting the contents. + ::: + +8. Now, you should ensure that for every hostname you set in the `.env` file, you have a DNS `A record` handling it pointing it to your servers **public IP**. + :::warning + If you are using Cloudflare, you should disable the proxy (orange cloud) for the DNS record. This is because Traefik needs to connect directly to your server. + ::: + :::tip + You can create a wildcard DNS by using an A record with `*` as the subdomain. e.g. `*.yourdomain.com`. This will allow you to use any subdomain while only + needing to create one DNS record. + ::: + +9. After you have filled in the environment variables, you can now deploy the services. However, the command you use will depend on which services you want to deploy. + + - If you want to deploy only the default services, you can run the following command: + + ```bash + sudo docker compose up -d + ``` + + - If you want to deploy the stremio profile services, you can run the following command: + + ```bash + sudo docker compose up -d --profile stremio + ``` + + - If you want to deploy multiple profiles, you can run the following command: + + ```bash + sudo docker compose up -d --profile stremio --profile nzbhydra2 + ``` + +10. After running the command, it may take some time for the services to start up. Once it is done, you should be able to access them at the hostnames you + set in the `.env` file. + +## Modifying the profiles + +You may want to deploy only 1 or 2 services from a profile, or maybe you want to omit a few services from a profile. + +This section will show you how to do that. + +
+I want to use the stremio profile but don't want the TMDB Addon +
+ + Within the `compose.yaml` file, you can remove the `stremio` profile from the `tmdb-addon` service. + + ```graphql + services: + tmdb-addon: + image: mrcanelas/tmdb-addon:latest + container_name: tmdb-addon + restart: unless-stopped + expose: + - 3232 + environment: + - PORT=3232 + - TMDB_API=${TMDB_API_KEY?} # https://www.themoviedb.org/settings/api + - FANART_API=${FANART_API_KEY?} # https://fanart.tv/get-an-api-key/ + - HOST_NAME=tmdb-${TMDB_ADDON_HOSTNAME?} + - MONGODB_URI=mongodb://mongodb:27017/tmdb + - META_TTL=604800 # 1 week + - CATALOG_TTL=86400 # 1 day + - NO_CACHE=false # Enable cache, set to true to disable + labels: + - "traefik.enable=true" + - "traefik.http.routers.tmdb.rule=Host(`${TMDB_ADDON_HOSTNAME?}`)" + - "traefik.http.routers.tmdb.entrypoints=websecure" + - "traefik.http.routers.tmdb.tls.certresolver=myresolver" + - "traefik.http.services.tmdb.loadbalancer.server.port=3232" + - "flame.type=app" + - "flame.name=TMDB Addon" + - "flame.url=https://${TMDB_ADDON_HOSTNAME?}" + depends_on: + mongodb: + condition: service_healthy + profiles: + - stremio <--- Remove this line to not deploy the TMDB Addon in the stremio profile + - all + ``` + +
+
+ +
+ + I only want to deploy AIOStreams and MediaFlow + + +
+ You can start by only deploying the default services + ```bash + sudo docker compose up -d + ``` + + Then you can deploy the services you want by specifying the services you want to deploy using their service names which can be found in the `compose.yaml` file. + ```bash + sudo docker compose up -d aiostreams mediaflow + ``` + + :::warning + For this specific example, you would also have to edit the environment variables for AIOStreams to not refer to + the self hosted instances of the other addons. + + If your VPS is blocked by Torrentio, so include that as well. + ::: + +
+
diff --git a/sidebars.ts b/sidebars.ts index 8963545..9a75242 100644 --- a/sidebars.ts +++ b/sidebars.ts @@ -94,6 +94,19 @@ const sidebars: SidebarsConfig = { }, ], }, + { + type: "category", + label: "Self Hosting", + link: { + type: "doc", + id: "selfhosting/index", + }, + items: [ + "selfhosting/oracle", + "selfhosting/docker", + "selfhosting/template", + ], + }, { type: "category", label: "Reading",