/home-lab

My home server infrastructure

Primary LanguageJavaScript

Home Server

This is my main server repository for home use. It currently hosts several services that make my life more fun and easier.

Personal Media

  • PhotoPrism - AI-Powered Photos App for the Decentralized Web. It utilizes the latest technologies to automatically tag and find pictures.
  • NextCloud - A personal cloud for storing files.
  • Plex - A media server for watching movies and music.
  • Tautulli - A monitoring tool for Plex Media Server.

Torrents

  • Overseerr - A request management and media discovery tool built to work with your existing Plex ecosystem.
  • QBittorrent - A torrent client for downloading movies and music directly through the [iQbit Web UI].
  • Jackett - A proxy for searching multiple torrents at once.
  • Radarr - A torrent management tool for movies.
  • Sonarr - A torrent management tool for TV shows.
  • Lidarr - A torrent management tool for music.

VPN

  • WireGuard Proxy - WireGuard VPN client and Socks5 proxy for local use.
  • WireGuard Server - WireGuard VPN server for home IP
  • Windscribe - VPN client + local proxy for any components (Blocked by Roskomnadzor).
  • XrayCore - Xray is a tool for proxying and tunneling data, bypassing restrictions. I use it as a relay in my home lab setup (WireGuard -> XrayCore [home lab] -> Xray server [external server]).

Other Applications

  • Traefik Proxy - Used as a reverse proxy for service routing, HTTPS connection, and certificate issuance.
  • Duplicati - Used for file-cloud backups.
  • Ksmi-Site - My personal site.
  • AdGuard Home - Network-wide software for blocking ads and tracking.
  • Homer - A simple static homepage for easy access to services, configured through a simple YAML file.
  • Netdata - Server monitoring.

Infrastructure Management

  • Start all: make start

  • Stop all: make stop

  • Restart all: make restart

  • Upgrade all: make upgrade

  • Update secondary sources: make sources.update

  • Download secondary sources: make sources.get

  • Print all component names: make help.names

  • Print current config: make help.config

  • Print template config: make help.config.template

  • Stop component by name: make component.stop component=<name>

  • Start component by name: make component.start component=<name>

  • Upgrade component by name: make component.upgrade component=<name>

Installation

This is a basic installation guide for the infrastructure. The components must be configured according to their respective documentation in the links provided.

  1. Clone the repository:
$ git clone https://github.com/krlls/homeServer/
  1. Create the environment file: Copy ./config/temp.env as ./config/.env and replace the service data with your own:
$ cp ./config/temp.env ./config/.env
$ nano ./config/.env
  1. Domain Connection: Bind the domain to the server's IP and add A records for the selected subdomains of the components. Alternatively, you can use a local DNS.

  2. Run the installation: After verifying the data in the ./config/.env file, launch the installation:

$ make install
  1. Configure components: Visit the addresses for each service and follow the suggested steps according to their respective documentation.

Overview

Next, I will provide some general information about the infrastructure and how things work.

Adding a Component

In the context of this infrastructure, a component refers to one or more services defined in a ./components/<component_name>.yaml file. For example, the nextcloud component contains nextcloud_app, nextcloud_db, nexcloud_cron, and redis.

  1. Component Creation: Create a ./components/<component_name>.yaml file with the service description for the component. This file should follow the docker-compose.yaml format of version 3.7 or higher.

  2. Component Registration: In ./config/components.json, register the new component by adding the following lines:

{
  "components": [
    ....
    {
      "name": "<component_name>",
      "file": "<component_name>.yaml"
    }
  ]
}
  1. Add Component Data: Create the directory ./data/<component_name> and mount all necessary volumes to organize container data for future use.

  2. Add Traefik Configuration: The file data/traefik/servicesConfig.yaml contains the configuration for correctly routing traffic to services. To add a new service, you need to create a router and a service for it. For example:

http:
  routers:
    ...
    <SERVICE_NAME>:  # custom router name
      rule: "Host(`{{env "<SERVICE_URL>"}}`)"  # replace
      service: <SERVICE_NAME>  # replace
      entryPoints:
        - "websecure"
      tls:
        certresolver:
          - "mydnschallenge"

Create the service by adding the following to services:

http:
  services:
    ...
    <SERVICE_NAME>:  # replace
      loadBalancer:
        servers:
          - url: "http://<ALIAS>:<PORT>"  # replace with container name and port

In the above example, the environment variable SERVICE_URL must be defined in the Traefik section of the docker-compose file and used here, e.g., TORRENT_TRAEFIK_HOST.

  1. Add .env File: Place all important data (that should not be in the git index) in the ./config/.env file.

  2. Start the Component: Afterward, restart the entire infrastructure or just the specific component:

$ make restart
# or
$ make component.start component=<component_name>

Additional Notes

With this approach, the infrastructure can be easily scaled by removing or adding new components. Since important data for each component is stored in the data/<component_name> directory, setting up backups becomes quick and straightforward.

For more flexible and convenient management of the infrastructure, I have written several utility scripts in JavaScript that cover all the basic interaction cases with components. The commands to run them are described in the Makefile and can be found in the management section above.

Within this

framework, the author prefers using images with the latest tag to update components quickly. However, it is important to note that this approach may cause potential failures in a production or commercial environment. It is recommended to use more controlled and stable versioning practices.

I hope this clarifies the installation and usage process of your home server infrastructure. If you have any further questions, feel free to ask!