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
.
What is it for?
The "template" makes use of a Docker Compose project and its include feature to allow you to easily use and maintain a large number of services.
Each individual app has its own compose.yaml
file, which will usually have its own .env
file for configuration,
and then the main compose.yaml
file includes all of them. Each individual app will also have its own profile
.
The .env
files handle most of the configuration for the services, which means you usually don't have to ever edit the compose.yaml
file itself,
just the documented .env
files.
This means that when using the compose project, it counts as one single file with all the services in it. This makes it easy to reference other containers, and not having to deal with multiple networks, etc.
This compose.yaml
uses Traefik 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.
We use Authelia as an authentication service, which allows us to protect our services. Authelia is not applied to every single service, but only to the ones that require authentication. This is done through Traefik labels. I will discuss how to add Authelia to a service later on.
A quick summary of what is included in this template is:
- Default server management services
- Stremio related services
- Debrid media server services
- Seanime
- Minecraft server
- Plausible analytics
- Vaultwarden
- SearXNG
- Zipline
What is the full list of services that are available in the template?
Traefik is included as our 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.
Authelia is included for authentication.
To help with managing the server, the following services are included:
- Dozzle - A simple real time log viewer for docker containers with a web based UI.
- Watchtower - Automatically update your Docker containers to the latest version.
- 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. - A simple dashboard to monitor your server.
- Honey - Beautiful, customisable, startpage for your server to access all your services.
Stremio Addons and Utilities
- AIOStreams
- AIOStremio
- Comet
- MediaFusion
- StremThru
- Stremio-Jackett
- Jackettio
- EasyNews+
- MediaFlow Proxy
- Catalog Providers
- TMDB Addon
- Stremio Trakt Addon
- Stremio Catalog Addon
- OMG TV Stremio Addon
- Stremio Server
- 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
Debrid Media Server
These services require a lot of work to set up, and documentation for it is not finished yet, I suggest only using this template as a reference
Indexers and Utilities
- Prowlarr
- Jackett
- NZBHydra2
- This is an indexer for NZB indexers. Which is mostly useful for Torbox users with the BYOI feature.
- Zilean
- This is a DMM scraper.
- FlareSovlerr / Byparr
- Useful for bypassing Cloudflare's anti-bot protection for scraping purposes.
- Cloudflare Warp
- 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.
- Gluetun
- Tweakio
- A torrentio indexer built to work with the *arrs.
- Torbox Manager
This template also includes other applications:
- Seanime - Beautiful open-source media server with a web interface and desktop app for anime and manga.
- SearXNG - Privacy-respecting metasearch engine.
- Plausible Analytics - Simple, privacy-friendly and open-source web analytics. (Used on this site)
- Minecraft server
- Vaultwarden - An unofficial Bitwarden compatible server written in Rust.
Customising the template
The template is designed to be easily customisable. You can add your own services, remove services, and modify the configuration of the services.
My compose.yaml makes use of profiles to make it easier to deploy only specific services.
Each individual service has its own profile, so seanime has a profile called seanime
, and so on.
There are also profiles that are a group of services that are related to each other. For example, the stremio
profile contains services that are related to Stremio.
Currently there are only 2 grouped profiles - stremio
and indexers
.
The individual profiles are simply the names of the folder names in the apps
directory.
As every single service has a profile, you must define a profile, either in the COMPOSE_PROFILES
environment variable or through the --profile
flag when running the docker compose
command.
Otherwise, no services will be started.
However, there is a 'required' profile which includes Traefik and Authelia, which is required for external access to the services.
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.
Other than choosing the profiles, you could also modify the root compose.yaml
file and remove a compose.yaml from the include list.
e.g. If you wanted to use the stremio profile, but not the TMDB addon, you could remove the - tmdb-addon/compose.yaml
line under the include:
section.
Setup
Requirements
- A server with Docker installed per https://get.docker.com/. (Other methods like snap are not recommended).
- A domain with name servers preferably changed to Cloudflares.
- You may use free subdomains from services like DuckDNS, Afraid.org or No-IP, but I recommend using a domain you own.
note
Should you choose to use these free services, you most likely will not be able to change name servers. This means you will have to manually create DNS records for each subdomain you want to use.
- You may use free subdomains from services like DuckDNS, Afraid.org or No-IP, but I recommend using a domain you own.
- Ports 80 and 443 open on your server. This is required for Traefik to work correctly.
tip
If you are using Oracle Cloud, you can follow these steps to open the ports.
Steps
-
Connect to your server, typically done using the following command, replacing
your-server-ip
with your server's IP address:ssh ubuntu@your-server-ip
tipIf you are using a different user, you should change the
ubuntu
part of the command to your username. -
The first step is to download the template, preferably to
/opt/docker
, using the following commands:cd /opt
git clone https://github.com/Viren070/docker-compose-vps-template.git docker
cd docker
tipYou can change the permissions of the
/opt/docker
directory to your user using the following command:sudo chown $(id -u):$(id -g) -R /opt/docker
This will allow you to edit files in the directory without needing to use
sudo
. -
Next, you should navigate into the directory that contains the
compose.yaml
file.cd apps
-
You can now confirm that the files have been downloaded by running the following command:
ls -a
You should see a list of folders, an .env file, and a
compose.yaml
file. -
Next, you should edit the
.env
files to fill in the necessary environment variables. I'd recommend that you start with the root.env
file only.There are many ways to fill these values in, you could:
-
use a CLI text editor like
nano
orvim
to edit the file directly through the terminal.nano .env
-
Use VS Code to edit the file directly on the server using the
Remote - SSH
extension. (recommended)- Install the
Remote - SSH
extension in VS Code. - Open the command palette (Ctrl + Shift + P) and type
Remote-SSH: Connect to Host...
. - Enter the SSH connection string for your server (e.g.
ubuntu@your-server-ip
). - Once connected, navigate to the
/opt/docker/apps
directory (Ctrl + K
+Ctrl + O
/File
>Open Folder...
). - You will be able to see all the files and folders in the sidebar. Edit the
.env
files for each service from here by simply clicking on them and then editing them. You can also use the terminal in VS Code to run commands on the server. Make sure to save the files after editing them. (Ctrl + S
/File
>Save
).
- Install the
-
Use XPipe as a remote file explorer and then use your preferred text editor to edit the files. (also recommended)
- Download and install XPipe from here.
- Open XPipe and click on the
+
button to add a new connection. - You can either let XPipe search automaticallly using the SSH config files or manually add a Remote Host connection.
- After adding the connection, you can go to the file browser tab on the right (or
Ctrl + 2
) and navigate to the/opt/docker/apps
directory. - You can then right click on the
.env
file and selectOpen with...
and select your preferred text editor. - After editing the file, make sure to save it.
-
Edit all the files locally (so clone the repository to your local machine first) using your preferred method and then upload them to your server using
scp
.
infoYou should only fill in the environment variables for the services you are going to deploy. If you add a profile, the full set of environment variables for each app under that profile will be required.
-
-
After filling in the root .env, you should start the 'required' profile, this allows you to check that Traefik and Authelia are working correctly.
docker compose --profile required up -d
This will start the Traefik and Authelia services. You can check the logs for any errors by running:
docker compose --profile required logs -f
-
You can then start adding and configuring more services, either by adding more profiles or using the 'all' profile and manually removing the compose files you don't want to use from the
include:
section of the rootcompose.yaml
file. Make sure to fill in any.env
files for the other services if they exist within the folder for that app. -
If you are not using cloudflare-ddns (which automatically creates the DNS records), you should ensure that for every hostname in the root
.env
files, you have a DNSA record
handling it pointing it to your servers public IP.warningIf 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.
tipYou 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.However, this can cause issues and will cause any subdomain to be routed to your server. For example, if you're running a minecraft server, it will mean that any subdomain will be routed to your server.
-
After you have filled in the environment variables, you can now deploy the services. You should make sure you defined the
COMPOSE_PROFILES
environment variables as this will determine which profiles are started. If you did not set it, no services will be started.Then, you can run the following command:
docker compose up -d
- You can also specify the profiles through the
--profile
flag, e.g.docker compose --profile required --profile stremio --profile seanime up -d
- 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 that are defined in
the root
.env
file.
Modifying the profiles
You may want to omit some services from the profiles, this is possible by removing the profile from the service in the compose.yaml
file.
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
and tmdb-addon_mongo
services.
Remove the highlighted lines below:
services:
tmdb-addon:
image: viren070/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_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=letsencrypt"
- "traefik.http.services.tmdb.loadbalancer.server.port=3232"
- "flame.type=app"
- "flame.name=TMDB Addon"
- "flame.url=https://${TMDB_ADDON_HOSTNAME?}"
depends_on:
tmdb-addon_mongo:
condition: service_healthy
profiles:
- tmdb-addon
- stremio
- all
tmdb-addon_mongo:
image: mongo:latest
container_name: tmdb-addon_mongo
restart: unless-stopped
volumes:
- ${DOCKER_DATA_DIR}/tmdb-addon/db:/data/db
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
interval: 10s
timeout: 10s
retries: 5
start_period: 40s
profiles:
- tmdb-addon
- stremio
- all
You could instead remove the include line from the root compose.yaml
for the tmdb-addon
service.
This would mean that the service would not be included in the deployment at all.
Adding the 'tmdb-addon' profile to the DOCKER_COMPOSE_PROFILES
environment variable would also not work unless this line is added back.
include:
...
- tautulli/compose.yaml
- tmdb-addon/compose.yaml
- torbox-manager/compose.yaml
...
networks:
default:
name: ${DOCKER_NETWORK:-aio_default}
external: ${DOCKER_NETWORK_EXTERNAL:-false}