Docker Compose Template

repository·main·Indexed 41 days ago

https://github.com/viren070/docker-compose-template

A Docker Compose template for self-hosting applications on a VPS, featuring Traefik as a reverse proxy and Authelia for centralized authentication. It provides a ready-to-use infrastructure for managing multiple services via Docker profiles, including configurations for Actual Budget, AdGuard Home, aiomanager, aiometadata, aiolists, and aiostreams.

Tokens
96.4K
Snippets
266
Records
361
Agent score
52%

What's inside docker-compose-template

  1. Prerequisites for deploying the VPS Template

    main

    Before deploying this template, ensure you have the following infrastructure ready:

    • A VPS with Docker installed: Follow the official instructions at https://get.docker.com.
    • Open Ports: Ports 80 and 443 must be open on your VPS firewall.
    • Domain & DNS:
      • You need a domain with DNS records pointing to your VPS IP for every subdomain you intend to use.
      • Free options like DuckDNS or Afraid.org are supported.
      • Recommended: Use Cloudflare for your nameservers. This allows you to use the included cloudflare-ddns profile to automatically maintain DNS records, which is not possible with DuckDNS or Afraid.org.
  2. Deploy additional services using Docker Compose profiles

    main

    Once the core services are running, you can deploy additional applications using Docker Compose profiles.

    1. Edit the .env file in the apps directory.
    2. Add the desired service names to the COMPOSE_PROFILES environment variable.
    3. Ensure you are in the root apps directory (e.g., /opt/docker/apps).
    4. Run the deployment command:
      docker compose up -d

    Method 2: Using CLI flags

    You can bypass the .env profile setting by specifying profiles directly in your commands:

    docker compose --profile stremio --profile seanime up -d

    Important Notes:

    • Directory Context: Always ensure you are running commands from the root apps directory, not from within an individual service's folder.
    • DNS Configuration: If you are not using the cloudflare-ddns profile, you must manually create A records for each service subdomain in your DNS provider.
    • Service-Specific Config: Check the .env file for specific instructions required by certain services (e.g., adding Prowlarr/Jackett API keys or editing config.toml for Seanime).
    # Deploying specific profiles via CLI
    docker compose --profile stremio --profile seanime up -d
    
    # Managing logs for a specific profile
    docker compose --profile seanime logs
    
    # Restarting a specific profile
    docker compose --profile seanime restart
  3. Install and setup the Docker Compose VPS Template

    main

    Follow these steps to clone the repository and perform the initial configuration:

    1. Clone the repository: Navigate to /opt and clone the repo into a docker directory.
      cd /opt
      git clone https://github.com/Viren070/docker-compose-vps-template.git docker
      cd docker
    2. Configure Environment Variables: Open the .env file located in the apps folder. You can use nano or a remote editor like VS Code with the Remote - SSH extension.
      nano .env
    3. Start Core Services: After filling in the initial values in the root .env, start only the essential services (Authelia and Traefik) using the required profile:
      docker compose --profile required up -d
    cd /opt
    git clone https://github.com/Viren070/docker-compose-vps-template.git docker
    cd docker
    nano .env
    docker compose --profile required up -d
  4. Manage Radarr service profiles

    main

    Radarr services are organized into Docker Compose profiles. This allows you to selectively start specific instances rather than all of them at once.

    • radarr profile: Includes the standard radarr, radarr4k, and radarranime services.
    • all profile: Includes all services in the template.

    To start only the Radarr-related services, use the --profile flag with Docker Compose.

    docker compose --profile radarr up -d
  5. Sonarr service profiles and dependencies

    main

    Sonarr services are organized into Docker Compose profiles:

    • all: Includes all Sonarr services (sonarr, sonarr4k, and sonarranime).
    • sonarr: Includes only the sonarr4k service.

    Dependencies: All Sonarr services depend on the decypharr service. The Sonarr containers will only start once decypharr reaches a healthy state.

  6. Deploy AioStremio using Docker Compose

    main

    AioStremio is deployed as a service named aiostremio which depends on a Redis instance (aiostremio_redis) for caching. The service uses the viren070/aiostremio:latest image. To run this service, you must include the aiostremio or all profile in your docker-compose command. The service is configured to be accessible via Traefik with automatic TLS via Let's Encrypt and authentication via Authelia.

    docker compose --profile aiostremio up -d
  7. Enable hardware acceleration for Immich machine learning

    main

    To enable hardware-accelerated machine learning inference in the immich_machine-learning service, follow two steps:

    1. Update the Image Tag: Append the appropriate hardware suffix to the image tag. Supported suffixes are armnn, cuda, rocm, openvino, or rknn. Example: ${IMMICH_VERSION:-release}-cuda.

    2. Uncomment the Extends Block: Uncomment the extends section in compose.yaml and select the corresponding service from hwaccel.ml.yml.

    Available services for inference:

    • armnn
    • cuda
    • rocm
    • openvino
    • openvino-wsl (use for WSL2 where applicable)
    • rknn
    immich_machine-learning:
        image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}-cuda
        # ...
        extends:
          file: hwaccel.ml.yml
          service: cuda # set to one of [armnn, cuda, rocm, openvino, openvino-wsl, rknn]
  8. Integrate CrowdSec with Traefik

    main

    You can protect your services using CrowdSec. You have two options for applying the CrowdSec bouncer:

    1. Global Application: Apply the middleware to all routers on the websecure entrypoint by uncommenting the middleware line in the Traefik command.
    2. Specific Router Application: Apply it only to specific services by adding a label to that service's Docker Compose configuration.

    To use CrowdSec, you must also enable the experimental plugin in the Traefik command.

    # 1. Enable the plugin in Traefik command
    - '--experimental.plugins.bouncer.modulename=github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin'
    - '--experimental.plugins.bouncer.version=v1.3.0'
    
    # 2. Option A: Apply globally to all websecure routers
    - '--entryPoints.websecure.http.middlewares=crowdsec@docker'
    
    # 2. Option B: Apply to a specific service via labels
    # traefik.http.routers.myservice.middlewares=crowdsec@docker
  9. Deploy Blackhole service variants using Docker Compose profiles

    main

    The compose.yaml file defines three distinct service variants. You can control which ones are deployed using Docker Compose profiles.

    Available Services

    1. blackhole: The standard service.
    2. blackhole4k: Optimized for 4K media, requiring sonarr4k and radarr4k to be healthy.
    3. blackholeanime: Optimized for anime media, requiring sonarranime and radarranime to be healthy.

    Deployment Commands

    To start all services (including those in the all profile):

    docker compose --profile all up -d

    To start only the Blackhole-related services:

    docker compose --profile blackhole up -d
  10. Deploy the xrdb service using Docker Compose profiles

    main

    The xrdb service is associated with the xrdb and all profiles. To start this specific service, you must include the profile in your docker compose command.

    # To start only the xrdb service
    docker compose --profile xrdb up -d
    
    # To start all services including xrdb
    docker compose --profile all up -d
  11. Deploy the aiomanager service

    main

    The aiomanager service runs the AI Manager application. It is configured to use an .env file for environment variables and requires a ${DOCKER_DATA_DIR} variable to be defined for persistent storage. By default, it exposes port ${PORT:-1610}.

    To run this service specifically, use the aiomanager profile. It is also included in the all profile.

    services:
      aiomanager:
        image: ghcr.io/sonicx161/aiomanager:latest
        container_name: aiomanager
        restart: unless-stopped
        expose:
          - ${PORT:-1610}
        env_file:
          - .env
        volumes:
          - ${DOCKER_DATA_DIR}/aiomanager/data:/app/data
        profiles:
          - aiomanager
          - all