Skip to content

pawan67/selfhost-infra-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Selfhost Infra with Docker

This repository contains my personal Docker Compose setup for self-hosting applications on a VPS. It uses Traefik as a reverse proxy and Authelia for authentication.

The stack is modular β€” you can add or remove services as you like.

Screenshots

Glance Overview

Glance Overview


Prerequisites

  • A VPS with Docker and Docker Compose installed

  • Ports 80 and 443 open

  • A domain or subdomains pointing to your VPS IP

  • (Optional but recommended) Cloudflare for DNS β€” lets you use the included Cloudflare DDNS to automatically manage records


Setup

1. Install Docker

curl -fsSL https://get.docker.com | sh

2. Clone this repository

cd /opt
git clone https://github.com/pawan67/selfhost-infra-docker.git
cd selfhost-infra-docker

3. Set proper permissions

You can change the permissions of the /opt/selfhost-infra-docker directory to your user using the following command:

sudo chown $(id -u):$(id -g) -R /opt/selfhost-infra-docker

This will allow you to edit files in the directory without needing to use sudo.

4. Configure environment variables

  • Copy .env.example files into .env for each app you want to run
  • Edit values with your domain, secrets, tokens, etc.

Using nano (command line):

nano apps/audiobookshelf/.env

Using VS Code (recommended):

# Install VS Code if not already installed
curl -fsSL https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64 -o vscode.deb
sudo dpkg -i vscode.deb

# Open the project in VS Code
code /opt/selfhost-infra-docker

VS Code Benefits:

  • Syntax highlighting for configuration files
  • Easy file navigation
  • Multiple files open in tabs
  • Built-in terminal
  • Extensions for Docker and YAML support

5. Start the core services (Traefik + Authelia)

docker compose --profile required up -d

6. Enable more services

  • Add them to the COMPOSE_PROFILES variable in the root .env

  • Or run them on demand with:

    docker compose --profile grafana --profile audiobookshelf up -d

7. Check your setup

  • Make sure you're in the repo root (pwd should show /opt/selfhost-infra-docker)

  • Run all enabled profiles:

    docker compose up -d

🐳 Docker Management

Common Commands

View running containers

docker compose ps

View logs

# All services
docker compose logs

# Specific service
docker compose logs traefik

# Follow logs in real-time
docker compose logs -f authelia

Restart services

# Restart all services
docker compose restart

# Restart specific service
docker compose restart traefik

# Restart with profile
docker compose --profile grafana restart

Stop services

# Stop all services
docker compose stop

# Stop specific service
docker compose stop audiobookshelf

# Stop and remove containers
docker compose down

Update services

# Pull latest images
docker compose pull

# Restart with new images
docker compose up -d

Clean up

# Remove stopped containers, unused networks, and dangling images
docker system prune

# Remove unused volumes (be careful!)
docker volume prune

Service Management

Add a new service

  1. Enable the profile in your root .env file:
    COMPOSE_PROFILES=required,grafana,audiobookshelf,newservice
  2. Start the new service:
    docker compose up -d

Remove a service

  1. Stop and remove the service:
    docker compose stop servicename
    docker compose rm servicename
  2. Remove from COMPOSE_PROFILES in .env

Troubleshooting

Check service health

# View container status
docker compose ps

# Check specific service logs
docker compose logs servicename

# Enter container shell for debugging
docker compose exec servicename /bin/bash
# or
docker compose exec servicename /bin/sh

Resource usage

# View resource usage
docker stats

# View disk usage
docker system df

πŸ“ Configuration Tips

Editing Configuration Files

Command Line:

# Using nano
nano apps/service-name/.env

# Using vim
vim apps/service-name/.env

VS Code (Recommended):

  • Install the Docker extension for better Docker Compose support
  • Install the YAML extension for better syntax highlighting
  • Use Ctrl+Shift+P β†’ "Docker: Compose Up" for GUI management

Environment Variables

Each service has its own .env file in apps/{service-name}/. Common variables include:

  • DOMAIN - Your domain name
  • SUBDOMAIN - Service subdomain
  • TIMEZONE - Your timezone (e.g., America/New_York)
  • PUID and PGID - User/Group IDs (run id to get yours)

Notes

  • Using Cloudflare DDNS is recommended check .env
  • Some services need extra steps (like adding API keys or editing configs) β€” check their README.md inside apps/{service}
  • Ports 80 and 443 must stay open
  • Always run commands from the repository root directory (/opt/selfhost-infra-docker)
  • Use docker compose logs servicename to troubleshoot issues
  • Keep your .env files secure and never commit them to version control

πŸ†˜ Support

  • Check individual service documentation in apps/{service}/README.md
  • Review Docker Compose logs for error messages
  • Ensure DNS records are properly configured
  • Verify firewall settings allow ports 80 and 443

About

A flexible Docker Compose setup for hosting self-hosted applications with Traefik as the reverse proxy and Authelia for authentication.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors