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.
-
A VPS with Docker and Docker Compose installed
-
Ports 80 and 443 open
-
A domain or subdomains pointing to your VPS IP
- Free domains from DuckDNS or Afraid.org also work
-
(Optional but recommended) Cloudflare for DNS β lets you use the included Cloudflare DDNS to automatically manage records
curl -fsSL https://get.docker.com | shcd /opt
git clone https://github.com/pawan67/selfhost-infra-docker.git
cd selfhost-infra-dockerYou 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-dockerThis will allow you to edit files in the directory without needing to use sudo.
- Copy
.env.examplefiles into.envfor each app you want to run - Edit values with your domain, secrets, tokens, etc.
nano apps/audiobookshelf/.env# 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-dockerVS Code Benefits:
- Syntax highlighting for configuration files
- Easy file navigation
- Multiple files open in tabs
- Built-in terminal
- Extensions for Docker and YAML support
docker compose --profile required up -d-
Add them to the
COMPOSE_PROFILESvariable in the root.env -
Or run them on demand with:
docker compose --profile grafana --profile audiobookshelf up -d
-
Make sure you're in the repo root (
pwdshould show/opt/selfhost-infra-docker) -
Run all enabled profiles:
docker compose up -d
docker compose ps# All services
docker compose logs
# Specific service
docker compose logs traefik
# Follow logs in real-time
docker compose logs -f authelia# Restart all services
docker compose restart
# Restart specific service
docker compose restart traefik
# Restart with profile
docker compose --profile grafana restart# Stop all services
docker compose stop
# Stop specific service
docker compose stop audiobookshelf
# Stop and remove containers
docker compose down# Pull latest images
docker compose pull
# Restart with new images
docker compose up -d# Remove stopped containers, unused networks, and dangling images
docker system prune
# Remove unused volumes (be careful!)
docker volume prune- Enable the profile in your root
.envfile:COMPOSE_PROFILES=required,grafana,audiobookshelf,newservice
- Start the new service:
docker compose up -d
- Stop and remove the service:
docker compose stop servicename docker compose rm servicename
- Remove from
COMPOSE_PROFILESin.env
# 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# View resource usage
docker stats
# View disk usage
docker system dfCommand Line:
# Using nano
nano apps/service-name/.env
# Using vim
vim apps/service-name/.envVS 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
Each service has its own .env file in apps/{service-name}/. Common variables include:
DOMAIN- Your domain nameSUBDOMAIN- Service subdomainTIMEZONE- Your timezone (e.g.,America/New_York)PUIDandPGID- User/Group IDs (runidto get yours)
- Using Cloudflare DDNS is recommended check .env
- Some services need extra steps (like adding API keys or editing configs) β check their
README.mdinsideapps/{service} - Ports 80 and 443 must stay open
- Always run commands from the repository root directory (
/opt/selfhost-infra-docker) - Use
docker compose logs servicenameto troubleshoot issues - Keep your
.envfiles secure and never commit them to version control
- 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
