Server Context
This guide documents the server environment for agents working on this system. Understanding this context is essential before making changes.
Docker Containers
Section titled “Docker Containers”| Service | Container | Image | Purpose |
|---|---|---|---|
| traefik | traefik | traefik:latest | Reverse proxy, SSL termination |
| docs | docs | docs-starlight | Documentation site (Starlight) |
| n8n | n8n | n8nio/n8n:latest | Workflow automation |
| postgres-main | postgres-main | postgres:15-alpine | PostgreSQL database |
| bucko-web-prod | bucko-web-prod | bucko-bucko-web | Static website (Astro) |
| adminer | adminer | adminer | Database admin UI |
| promtail | promtail | grafana/promtail:latest | Log shipping |
Key Paths
Section titled “Key Paths”| Path | Purpose |
|---|---|
/opt/docker/ | All Docker projects root |
/opt/docker/bucko/ | Bucko website (Astro) |
/opt/docker/docs/ | Documentation site (Starlight) |
/opt/docker/n8n/ | n8n workflow automation |
/opt/docker/postgres/ | PostgreSQL configuration |
/opt/docker/traefik/ | Traefik reverse proxy |
/home/samob/ | User home, backup storage |
Network Topology
Section titled “Network Topology” ┌─────────────────┐ │ Traefik │ │ (reverse proxy)│ │ :80, :443 │ └────────┬────────┘ │ ┌────────┴────────┐ │ proxy network │ │ (external) │ └────────┬────────┘ │ ┌────────────────────┼────────────────────┐ │ │ │ ▼ ▼ ▼ ┌───────────┐ ┌───────────┐ ┌───────────┐ │ docs │ │ n8n │ │bucko-web │ │ :4322 │ │ :5678 │ │ :4321 │ └───────────┘ └─────┬─────┘ └───────────┘ │ ▼ ┌───────────┐ │ postgres │ │ :5432 │ └───────────┘All web services connect to the proxy Docker network. Traefik routes traffic based on Host headers.
DNS & Domains
Section titled “DNS & Domains”| Domain | Service | Container |
|---|---|---|
bucko.smilepowered.org | Bucko website | bucko-web-prod |
n8n.smilepowered.org | n8n workflows | n8n |
docs.smilepowered.org | Documentation | docs |
adm.smilepowered.org | Traefik dashboard | traefik |
Credentials Locations
Section titled “Credentials Locations”| Service | Location | Notes |
|---|---|---|
| PostgreSQL | /opt/docker/postgres/compose.yaml | POSTGRES_PASSWORD |
| n8n database | /opt/docker/n8n/compose.yaml | DB_POSTGRESDB_PASSWORD |
| n8n encryption | /opt/docker/n8n/compose.yaml | N8N_ENCRYPTION_KEY - also in volume |
| Traefik | /opt/docker/traefik/compose.yaml | ACME email for Let’s Encrypt |
Traefik Labels Pattern
Section titled “Traefik Labels Pattern”To expose a service through Traefik, add these labels to compose.yaml:
labels: - "traefik.enable=true" - "traefik.http.routers.<name>.rule=Host(`<domain>`)" - "traefik.http.routers.<name>.entrypoints=websecure" - "traefik.http.routers.<name>.tls.certresolver=letsencrypt" - "traefik.http.services.<name>.loadbalancer.server.port=<internal_port>"Common Commands
Section titled “Common Commands”Container Management
Section titled “Container Management”# List all running containersdocker ps
# View container logsdocker logs <container_name>
# Follow logs in real-timedocker logs -f <container_name>
# Restart a servicecd /opt/docker/<service> && docker compose restart
# Rebuild and restartcd /opt/docker/<service> && docker compose build && docker compose up -dPostgreSQL
Section titled “PostgreSQL”# List databasesdocker exec postgres-main psql -U postgres -c "\l"
# Backup a databasedocker exec postgres-main pg_dump -U <user> <database> > backup.sql
# Restore a databasecat backup.sql | docker exec -i postgres-main psql -U <user> -d <database>Traefik
Section titled “Traefik”# Check Traefik logs for errorsdocker logs traefik | grep -i error
# Verify container labelsdocker inspect <container_name> --format '{{json .Config.Labels}}' | jq
# Check proxy networkdocker network inspect proxyBuild Workflow
Section titled “Build Workflow”For services that require building (docs, bucko):
cd /opt/docker/<service>./build.sh # Build static files using Docker node:22-alpinedocker compose build # Build container imagedocker compose up -d # Start containerContainer Updates
Section titled “Container Updates”Check if containers are outdated
Section titled “Check if containers are outdated”Compare running container image IDs with local latest images:
# Get running container image IDdocker inspect <container_name> --format '{{.Image}}'
# Pull latest imagedocker pull <image>:latest
# Compare with local imagesdocker images --format "table {{.Repository}}:{{.Tag}}\t{{.ID}}\t{{.CreatedAt}}" | grep <image>Update a container
Section titled “Update a container”-
Pull the latest image:
Terminal window docker pull <image>:latest -
Recreate the container:
Terminal window cd /opt/docker/<service>docker compose up -d -
Verify update:
Terminal window docker inspect <container_name> --format '{{.Image}}'docker images --format "{{.ID}}" <image>:latest
Both IDs should match after update.
Current container versions
Section titled “Current container versions”| Container | Image | Update Command |
|---|---|---|
| traefik | traefik:latest | cd /opt/docker/traefik && docker compose up -d |
| n8n | n8nio/n8n:latest | cd /opt/docker/n8n && docker compose up -d |
| postgres-main | postgres:15-alpine | cd /opt/docker/postgres && docker compose up -d |
| adminer | adminer | cd /opt/docker/adminer && docker compose up -d |
| promtail | grafana/promtail:latest | cd /opt/docker/promtail && docker compose up -d |
Backup Storage
Section titled “Backup Storage”| Location | Contents |
|---|---|
/home/samob/ | Local backup copies (persistent) |
/opt/docker/docs/public/downloads/ | Downloadable backups via docs site |
Troubleshooting
Section titled “Troubleshooting”Container won’t start
Section titled “Container won’t start”docker logs <container_name>Check for port conflicts, missing volumes, or configuration errors.
Traefik not routing to container
Section titled “Traefik not routing to container”- Verify container has correct labels
- Verify container is on
proxynetwork - Check Traefik logs:
docker logs traefik
docker inspect <container_name> | grep -A 20 Labelsdocker network inspect proxyPostgreSQL connection refused
Section titled “PostgreSQL connection refused”- Check postgres is running:
docker ps | grep postgres - Verify credentials in compose.yaml match
- Test connection:
docker exec postgres-main psql -U postgres -c "\l"
Permission denied in /opt/docker/
Section titled “Permission denied in /opt/docker/”Files created by Docker may be owned by root. Use Docker to modify:
docker run --rm -v /opt/docker/<service>:/app -w /app node:22-alpine sh -c "rm -rf node_modules"