docker-compose resource definitions for web servers

This commit is contained in:
2025-12-28 22:48:01 +01:00
parent 80b58a9f3e
commit 7b42f2e3bd
5 changed files with 221 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
version: '3'
services:
traefik:
image: "traefik:latest"
container_name: traefik
restart: unless-stopped
# PORTS
ports:
# HTTP entrypoint
# Exposed on all external addresses (0.0.0.0:80)
- "80:80"
# Traefik API & Dashboard
# Accessible on http://<host>:8080
- "8080:8080"
# COMMAND (STATIC CONFIGURATION)
command:
# Enable Traefik API & Dashboard
- "--api.dashboard=true"
- "--api.insecure=true"
# Log settings
- "--log.level=INFO"
- "--accesslog=true"
# EntryPoints
- "--entrypoints.web.address=:80"
- "--entrypoints.traefik.address=:8080"
# Docker provider
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
# Optional: file provider for dynamic config
- "--providers.file.directory=/etc/traefik/dynamic"
- "--providers.file.watch=true"
# Global settings
- "--global.checknewversion=true"
- "--global.sendanonymoususage=false"
# VOLUMES
volumes:
# Docker socket (required for Docker provider)
- /var/run/docker.sock:/var/run/docker.sock:ro
# Dynamic configuration directory (middlewares, routers, TLS, etc.)
- ./dynamic:/etc/traefik/dynamic:ro
# Logs (optional)
- ./logs:/logs
# NETWORKS
networks:
- traefik
# LABELS (OPTIONAL SELF-ROUTING)
labels:
# Enable Traefik for this container
- "traefik.enable=true"
# Router for dashboard (via Traefik itself)
- "traefik.http.routers.traefik.rule=Host(`traefik.localhost`)"
- "traefik.http.routers.traefik.entrypoints=web"
- "traefik.http.routers.traefik.service=api@internal"
# NETWORK DEFINITIONS
networks:
traefik:
name: traefik
driver: bridge

View File

@@ -0,0 +1,62 @@
#!/usr/bin/env bash
set -euo pipefail
########################################
# CONFIG
########################################
COMPOSE_FILE_NAME="docker-compose.yml"
########################################
# ARGUMENT CHECK
########################################
if [[ $# -ne 1 ]]; then
echo "Usage: $0 {up|down}"
exit 1
fi
ACTION="$1"
if [[ "$ACTION" != "up" && "$ACTION" != "down" ]]; then
echo "Invalid action: $ACTION"
echo "Allowed actions: up, down"
exit 1
fi
########################################
# SAVE STARTING DIRECTORY
########################################
START_DIR="$(pwd)"
########################################
# FIND COMPOSE FILES
########################################
mapfile -t COMPOSE_DIRS < <(
find . -type f -name "$COMPOSE_FILE_NAME" -print0 \
| xargs -0 -n1 dirname | sort
)
########################################
# LOOP THROUGH DIRECTORIES
########################################
for DIR in "${COMPOSE_DIRS[@]}"; do
echo "----------------------------------------"
echo "Processing: $DIR"
echo "Action: docker-compose $ACTION"
echo "----------------------------------------"
cd "$DIR"
if [[ "$ACTION" == "up" ]]; then
docker-compose up -d
else
docker-compose down
fi
cd "$START_DIR"
done
echo "========================================"
echo "Completed docker-compose $ACTION for all stacks"
echo "========================================"

View File

@@ -0,0 +1,28 @@
version: '3'
services:
k9e:
image: kevinmidboe/k9e.no:latest
container_name: k9e
restart: unless-stopped
# NETWORK
networks:
- traefik
# TRAEFIK LABELS
labels:
# Enable Traefik for this container
- "traefik.enable=true"
# Router definition
- "traefik.http.routers.k9e.rule=Host(`k9e.no`)"
- "traefik.http.routers.k9e.entrypoints=web"
# Service definition
- "traefik.http.services.k9e.loadbalancer.server.port=80"
# NETWORK DEFINITIONS
networks:
traefik:
external: true

View File

@@ -0,0 +1,28 @@
version: '3'
services:
planetposen-original:
image: kevinmidboe/planetposen-original:latest
container_name: planetposen
restart: unless-stopped
# NETWORK
networks:
- traefik
# TRAEFIK LABELS
labels:
# Enable Traefik for this container
- "traefik.enable=true"
# Router definition
- "traefik.http.routers.planetposen-original.rule=Host(`planetposen.no`)"
- "traefik.http.routers.planetposen-original.entrypoints=web"
# Service definition
- "traefik.http.services.planetposen-original.loadbalancer.server.port=80"
# NETWORK DEFINITIONS
networks:
traefik:
external: true

View File

@@ -0,0 +1,29 @@
version: '3'
services:
whoami:
image: traefik/whoami
container_name: whoami
restart: unless-stopped
# NETWORK
networks:
- traefik
# TRAEFIK LABELS
labels:
# Enable Traefik for this container
- "traefik.enable=true"
# Router definition
- "traefik.http.routers.whoami.rule=Host(`whoami.example.com`)"
- "traefik.http.routers.whoami.entrypoints=web"
# Service definition
- "traefik.http.services.whoami.loadbalancer.server.port=80"
# NETWORK DEFINITIONS
networks:
traefik:
external: true