Overhaul: real metrics, Git integration UI, open-source hygiene, root cleanup

Backend:
- GET /services/:id/metrics with real Docker container stats
- DELETE /git/providers/:id and GET repo branches endpoint

Frontend:
- Service detail shows real telemetry or honest empty states
- Live status distinguishes idle/polling/reconnecting
- Git providers section in Settings; repo+branch pickers in Add Service
- Real logo, compact Projects header, canvas fitView fix
- index.css deduplicated (1725 -> 1384 lines)
- Fixed smoke tests, lint errors, ToastProvider/context unification

Repo hygiene:
- Added LICENSE (MIT), CONTRIBUTING.md, SECURITY.md; rewrote README
- Untracked .env.prod and data/letsencrypt secrets; fixed .gitignore
- Removed legacy root src/internal/cmd and stale configs/docs/artifacts
- Moved guides and design references under docs/

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Tomas DvorakandDevin committed 2026-09-15 18:59:40 +02:00
1 parent 355a97bab4
commit 9f3b196032
499 files changed
+4471 -94235

No files matched your search

+234
View File
@@ -0,0 +1,234 @@
# 🎮 Docker Template Manager - In-App Deployment System
## 🚀 **Fully Integrated App-Based Deployment**
I've created a **complete in-app deployment system** that runs entirely within your web application - no terminal needed!
### 📱 **What You Get**
#### **🎮 Visual Template Manager**
- **Grid view** of all 20 Docker templates
- **One-click deployment** with visual feedback
- **Real-time progress** tracking
- **Live deployment logs**
- **Status indicators** (idle, deploying, running, stopped)
- **Access URLs** with clickable links
#### **📊 Dashboard Features**
- **Template cards** with icons and descriptions
- **Difficulty badges** (Easy, Medium, Hard)
- **Category filtering** (Analytics, Media, Storage, etc.)
- **Deployment statistics** (total, deployed, running)
- **Success rate** tracking
#### **🎯 Interactive Controls**
- **Deploy button** - One-click deployment
- **Stop button** - Stop running services
- **Remove button** - Clean up deployments
- **Deploy All** - Deploy all easy templates
- **Filter tabs** - View by category or status
### 🖥️ **How It Works in Your App**
#### **1. Visual Template Selection**
```typescript
// Users see this in the app:
📊 Glance Dashboard [Deploy]
📈 Umami Analytics [Deploy]
📝 Memos [Deploy]
🔍 MeiliSearch [Deploy]
🎬 Plex [Deploy]
🎥 Jellyfin [Deploy]
☁️ Nextcloud [Deploy]
```
#### **2. One-Click Deployment**
- **Click "Deploy"** → Automatic deployment starts
- **Progress bar** shows deployment progress
- **Live logs** show what's happening
- **Status changes** from idle → deploying → running
- **Access URLs** appear when complete
#### **3. Management Interface**
- **View details** of any template
- **Monitor deployment** in real-time
- **Stop/start** services as needed
- **Access URLs** with clickable links
- **View logs** for troubleshooting
### 🎨 **User Experience**
#### **📱 Mobile-Friendly**
- **Responsive design** works on all devices
- **Touch-friendly** buttons and controls
- **Scrollable** template grid
- **Collapsible** details panel
#### **🌐 Browser Integration**
- **Click URLs** to open services in new tabs
- **Real-time updates** without page refresh
- **Smooth animations** and transitions
- **Status indicators** with icons
#### **📊 Visual Feedback**
```typescript
// Status indicators users see:
🟢 Running (green checkmark)
🔵 Deploying (blue pulsing circle)
🔴 Error (red alert)
⚪ Stopped (gray square)
⭕ Idle (gray circle)
```
### 🔧 **Technical Implementation**
#### **React Component Structure**
```typescript
src/components/
├── DockerTemplateManagerApp.tsx # Main component
├── DockerTemplateManager.tsx # Full component (20 templates)
└── AppDocker.tsx # App wrapper
```
#### **State Management**
```typescript
// Real-time state:
- templates: Template[] // All template data
- selectedTemplate: Template // Currently selected
- deploymentLogs: Logs[] // Deployment logs
- activeTab: string // Filter tab
```
#### **Deployment Simulation**
```typescript
// Automatic deployment steps:
1. Check dependencies
2. Create deployment directory
3. Extract docker-compose.yml
4. Create environment variables
5. Generate secrets
6. Pull Docker images
7. Start services
8. Show access URLs
```
### 🎯 **How to Use It**
#### **1. Add to Your App**
```typescript
// In your main App.tsx
import DockerTemplateManager from './components/DockerTemplateManagerApp';
function App() {
return (
<div className="min-h-screen bg-gray-50">
<DockerTemplateManager />
</div>
);
}
```
#### **2. Start the Development Server**
```bash
npm start
# or
yarn start
```
#### **3. Open in Browser**
```
http://localhost:3000
```
#### **4. Deploy Templates**
- **Browse** the template grid
- **Click** any template to see details
- **Click "Deploy"** to start deployment
- **Watch** the progress in real-time
- **Access** your service via the provided URLs
### 📊 **Template Categories**
#### **🟢 Easy Templates** (1-2 min)
- 📊 Glance Dashboard
- 📈 Umami Analytics
- 📝 Memos
- 🔍 MeiliSearch
- 📊 Uptime Kuma
#### **🟡 Medium Templates** (3-5 min)
- 🎬 Plex
- 🎥 Jellyfin
- 🛡️ Vaultwarden
- 🌐 Traefik
- 🚪 Pi-hole
- 📁 Cloudreve
- 🐙 Gitea
- 🔄 n8n
- 📊 Grafana
#### **🔴 Hard Templates** (5-10 min)
- ☁️ Nextcloud
- 🏠 Home Assistant
- 🦣 Mastodon
- 📸 Immich
- 🗄️ Supabase
- 🔧 Appwrite
### 🚀 **Features**
#### **🎮 Interactive Elements**
- **Template cards** with hover effects
- **Progress bars** for deployment status
- **Status badges** with colors
- **Clickable URLs** that open in new tabs
- **Filter tabs** for easy navigation
#### **📱 Responsive Design**
- **Mobile layout** adapts to screen size
- **Touch-friendly** buttons and controls
- **Scrollable** areas for long content
- **Sticky** details panel on desktop
#### **🔔 Real-Time Updates**
- **Live progress** during deployment
- **Status changes** update immediately
- **Logs appear** in real-time
- **URLs show** when deployment completes
### 🎯 **Next Steps**
#### **1. Test the App**
```bash
npm start
# Open http://localhost:3000
# Try deploying Glance (easiest)
```
#### **2. Customize Templates**
- **Add your own** templates
- **Modify existing** ones
- **Change colors** and styling
- **Add new features**
#### **3. Connect to Real Docker**
- **Replace simulation** with real API calls
- **Connect to Docker daemon**
- **Handle real errors**
- **Add authentication**
### 🎉 **Ready to Use!**
**The in-app deployment system is now complete and ready to use!**
**You now have:**
- ✅ **Visual template browser** in your app
- ✅ **One-click deployment** with no terminal
- ✅ **Real-time progress** tracking
- ✅ **Live deployment logs**
- ✅ **Clickable access URLs**
- ✅ **Mobile-friendly** interface
- ✅ **Category filtering** and search
- ✅ **Status management** (start/stop/remove)
**All 20 Docker templates are now available through your web application!** 🚀
+288
View File
@@ -0,0 +1,288 @@
# Autoscaling with Cloudflare Tunnel
## Overview
This document explains how autoscaling works when using Cloudflare Tunnel with the Containr application.
## Architecture
```
Internet → Cloudflare Edge → Cloudflare Tunnel → Traefik → Backend Services
```
## Autoscaling Considerations
### 1. Cloudflare Tunnel Limitations
**Cloudflare Tunnel itself does NOT provide autoscaling.** It's a secure tunneling service that:
- Creates a persistent connection between your infrastructure and Cloudflare's edge
- Routes traffic through Cloudflare's global network
- Provides DDoS protection and CDN features
### 2. Where Autoscaling Happens
Autoscaling must be implemented at different layers:
#### A. Container Level (Docker Swarm/Kubernetes)
```yaml
# Example with Docker Swarm
backend:
image: containr-backend
deploy:
replicas: 3
update_config:
parallelism: 1
delay: 10s
restart_policy:
condition: on-failure
```
#### B. Application Level (Load Balancing)
Traefik automatically load balances between multiple backend instances:
```yaml
# Multiple backend containers
backend-1:
# ... backend config
labels:
- "traefik.http.services.backend.loadbalancer.server.port=8080"
backend-2:
# ... backend config
labels:
- "traefik.http.services.backend.loadbalancer.server.port=8080"
```
#### C. Cloud Level (Cloudflare Load Balancer - Paid Feature)
For true autoscaling, you'd need:
- Multiple deployments in different regions
- Cloudflare Load Balancer ($$$/month)
- Health checks and failover
## Implementation Options
### Option 1: Docker Swarm (Recommended for Single Host)
```bash
# Initialize Docker Swarm
docker swarm init
# Deploy with autoscaling
docker stack deploy -c docker-compose.yml containr
```
### Option 2: Kubernetes
```yaml
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend
spec:
replicas: 3
selector:
matchLabels:
app: backend
template:
metadata:
labels:
app: backend
spec:
containers:
- name: backend
image: containr-backend
ports:
- containerPort: 8080
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: backend-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: backend
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
```
### Option 3: Manual Scaling with Scripts
```bash
#!/bin/bash
# scale-backend.sh
scale_up() {
local current=$(docker ps --filter "name=containr-backend" --format "table {{.Names}}" | wc -l)
local target=$((current + 1))
echo "Scaling backend to $target instances..."
for i in $(seq 1 $target); do
docker run -d \
--name containr-backend-$i \
--network containr_containr-network \
-e DATABASE_URL="..." \
-e REDIS_URL="..." \
containr-backend
done
}
scale_down() {
local current=$(docker ps --filter "name=containr-backend" --format "table {{.Names}}" | wc -l)
local target=$((current - 1))
if [ $target -lt 1 ]; then
echo "Cannot scale below 1 instance"
exit 1
fi
echo "Scaling backend to $target instances..."
docker stop containr-backend-$target
docker rm containr-backend-$target
}
case "$1" in
up) scale_up ;;
down) scale_down ;;
*) echo "Usage: $0 [up|down]" ;;
esac
```
## Monitoring and Metrics
### Health Checks
All services include health checks:
```yaml
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
```
### Metrics Collection
Traefik provides Prometheus metrics:
```yaml
# In docker-compose.yml
command:
- "--metrics.prometheus=true"
- "--metrics.prometheus.addentrypointslabels=true"
- "--metrics.prometheus.addserviceslabels=true"
```
### Scaling Triggers
Monitor these metrics for scaling decisions:
- CPU usage (> 70%)
- Memory usage (> 80%)
- Response time (> 500ms)
- Error rate (> 5%)
- Queue depth (if using message queues)
## Production Recommendations
### 1. Use Docker Swarm or Kubernetes
- Better orchestration
- Built-in load balancing
- Health management
- Rolling updates
### 2. Implement Horizontal Pod Autoscaler (HPA)
- Automatic scaling based on metrics
- Min/max replica limits
- Configurable thresholds
### 3. Use Cloudflare Load Balancer (if budget allows)
- Geographic distribution
- Advanced health checks
- Traffic steering
- DDoS protection
### 4. Monitoring and Alerting
- Prometheus + Grafana
- Alertmanager
- Log aggregation (ELK stack)
## Example: Complete Autoscaling Setup
```yaml
# docker-compose.autoscale.yml
version: '3.8'
services:
traefik:
image: traefik:v3.2
command:
- "--api.dashboard=true"
- "--providers.docker=true"
- "--providers.docker.swarmMode=true"
- "--metrics.prometheus=true"
deploy:
replicas: 1
placement:
constraints:
- node.role == manager
backend:
image: containr-backend
deploy:
replicas: 3
update_config:
parallelism: 1
delay: 10s
restart_policy:
condition: on-failure
labels:
- "traefik.http.services.backend.loadbalancer.server.port=8080"
- "traefik.http.routers.backend.rule=Host(`api.${DOMAIN}`)"
- "traefik.enable=true"
prometheus:
image: prom/prometheus
deploy:
replicas: 1
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
grafana:
image: grafana/grafana
deploy:
replicas: 1
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
```
## Summary
1. **Cloudflare Tunnel ≠ Autoscaling** - It's for secure connectivity
2. **Autoscaling happens at container/orchestration level**
3. **Traefik provides load balancing between instances**
4. **Use Docker Swarm or Kubernetes for production autoscaling**
5. **Monitor metrics and implement HPA for automatic scaling**
6. **Consider Cloudflare Load Balancer for multi-region setups**
## Quick Start Commands
```bash
# Start with autoscaling (Docker Swarm)
docker swarm init
docker stack deploy -c docker-compose.autoscale.yml containr
# Scale manually
docker service scale containr_backend=5
# Check status
docker service ls
docker service ps containr_backend
# View logs
docker service logs containr_backend
```
+259
View File
@@ -0,0 +1,259 @@
# 🚀 Zero-Interaction Docker Deployment System
## 🎯 **Fully Automatic Deployment**
I've created a **completely automated deployment system** that requires **ZERO user interaction**. Just run one command and it does everything!
## ⚡ **One-Click Deployment**
### **Option 1: Quick Start (Recommended)**
```bash
# Run the quick deploy script
./scripts/quick-deploy.sh
```
**What happens:**
1. 🎯 **Shows you 6 deployment options**
2. 🚀 **Deploys your choice automatically**
3. 🔧 **Handles everything** (secrets, directories, ports)
4. 🌐 **Shows access URLs** when done
### **Option 2: Direct Command**
```bash
# Deploy any template instantly
./scripts/auto-deploy.sh umami
./scripts/auto-deploy.sh plex
./scripts/auto-deploy.sh nextcloud
```
### **Option 3: Deploy Everything**
```bash
# Deploy all 20 templates at once
./scripts/auto-deploy.sh --all
```
## 🔄 **What Happens Automatically**
### **🔍 Dependency Check**
```bash
✅ Checks if Docker is installed
✅ Installs Docker if missing
✅ Checks if Docker Compose is installed
✅ Installs Docker Compose if missing
```
### **📁 Directory Creation**
```bash
✅ Creates deployment directory
✅ Creates required subdirectories
✅ Sets proper permissions
✅ Handles existing deployments
```
### **🔧 Configuration Setup**
```bash
✅ Extracts docker-compose.yml from template
✅ Creates .env file with all variables
✅ Auto-generates secrets and passwords
✅ Fixes port conflicts automatically
✅ Optimizes volume paths
```
### **🐳 Docker Deployment**
```bash
✅ Pulls all required images
✅ Starts all services
✅ Waits for services to be ready
✅ Checks service health
✅ Shows deployment status
```
### **🌐 Access Information**
```bash
✅ Shows all access URLs
✅ Provides management commands
✅ Shows deployment directory
✅ Opens browser automatically (optional)
```
## 🎮 **Try It Now**
### **Easiest Way:**
```bash
./scripts/quick-deploy.sh
```
You'll see:
```
🚀 One-Click Docker Deployment
============================
🎯 Choose your deployment:
1. 🌐 Deploy Glance Dashboard (Recommended - Simple & Fast)
2. 📊 Deploy Umami Analytics (Web Analytics)
3. 📝 Deploy Memos (Note-taking)
4. 🔍 Deploy MeiliSearch (Search Engine)
5. 📈 Deploy Uptime Kuma (Monitoring)
6. 🚀 Deploy ALL Templates (Advanced)
Enter your choice (1-6): 1
🌐 Deploying Glance Dashboard...
```
### **Direct Way:**
```bash
# Deploy any template instantly
./scripts/auto-deploy.sh glance
```
## 📊 **Example Output**
Here's what you'll see during deployment:
```
🚀 Auto-Deploying glance
========================================
🔄 Checking dependencies...
✅ Docker is installed
✅ Docker Compose is installed
🔄 Auto-deploying glance...
✅ Created deployment directory: /path/to/deployments/glance
🔄 Extracting docker-compose.yml...
✅ docker-compose.yml extracted and optimized
🔄 Creating .env file...
✅ .env file created (no variables required)
🔄 Auto-deploying glance...
🔄 Pulling Docker images...
✅ Images pulled
🔄 Starting services...
✅ Services started successfully
🎉 Deployment Complete!
========================================
✅ Access URLs:
🌐 http://localhost:8080 (port: 8080)
✅ Management Commands:
📋 View logs: docker-compose logs -f
🛑 Stop services: docker-compose down
🔄 Restart: docker-compose restart
📊 Status: docker-compose ps
🗑️ Cleanup: docker-compose down -v
✅ Deployment directory: /path/to/deployments/glance
🎉 glance deployed successfully!
```
## 🔧 **Advanced Options**
### **Custom Configuration**
```bash
# Deploy without auto-generating secrets
./scripts/auto-deploy.sh --no-secrets umami
# Deploy without creating directories
./scripts/auto-deploy.sh --no-dirs plex
# Deploy without auto-starting services
./scripts/auto-deploy.sh --no-start nextcloud
# Deploy and auto-open browser
./scripts/auto-deploy.sh --open-browser glance
```
### **Batch Deployment**
```bash
# Deploy multiple templates
for template in umami glance memos; do
./scripts/auto-deploy.sh "$template"
done
# Deploy all templates
./scripts/auto-deploy.sh --all
```
## 🛡️ **Safety Features**
### **Automatic Conflict Resolution**
```bash
✅ Detects port conflicts
✅ Auto-assigns available ports
✅ Handles existing deployments
✅ Cleans up previous installations
```
### **Security**
```bash
✅ Generates strong random secrets
✅ Uses secure default passwords
✅ Isolates deployments in separate directories
✅ Logs all actions for audit trail
```
### **Error Handling**
```bash
✅ Validates template existence
✅ Checks service health
✅ Provides detailed error messages
✅ Offers rollback commands
```
## 📁 **Directory Structure**
```
your-project/
├── scripts/
│ ├── auto-deploy.sh # 🚀 Main auto-deployment script
│ └── quick-deploy.sh # ⚡ Quick start script
├── templates/
│ ├── umami.md
│ ├── plex.md
│ └── ...
└── deployments/ # 📁 Auto-created
├── glance/ # 📁 Template deployment
│ ├── docker-compose.yml
│ ├── .env
│ ├── data/
│ └── logs/
├── umami/
└── plex/
```
## 🎯 **Template Difficulty Levels**
| **Easy** (Auto-Deploy) | **Medium** (Auto-Deploy) | **Hard** (Auto-Deploy) |
|------------------------|-------------------------|----------------------|
| 🌐 Glance | 📊 Umami | 🗄️ Supabase |
| 📝 Memos | 📈 Uptime Kuma | 🏠 Home Assistant |
| 🔍 MeiliSearch | 🛡️ Vaultwarden | 📊 Grafana |
| 🚪 Pi-hole | 📁 Cloudreve | 🐙 Gitea |
| | 🌐 Traefik | 🦣 Mastodon |
| | 🎬 Jellyfin | ☁️ Nextcloud |
| | 📚 Plex | 🎬 Immich |
| | 🔄 n8n | |
## 🚀 **Ready to Use?**
**Yes! The system is fully automatic. Just run:**
```bash
# Quick start (easiest)
./scripts/quick-deploy.sh
# Or direct deployment
./scripts/auto-deploy.sh glance
```
**That's it!** 🎉
The system will:
- ✅ **Install Docker** if needed
- ✅ **Deploy your chosen service**
- ✅ **Generate all secrets**
- ✅ **Handle all configuration**
- ✅ **Show you the access URL**
- ✅ **Provide management commands**
**Zero user interaction required!** 🚀
+124
View File
@@ -0,0 +1,124 @@
# Cloudflare Tunnel Setup
This guide explains how to set up Cloudflare tunnel for Containr, allowing you to expose your services without configuring a domain.
## Prerequisites
1. A Cloudflare account
2. A domain (any domain, even a free one)
## Setup Steps
### 1. Create a Cloudflare Tunnel
1. Log in to your [Cloudflare Dashboard](https://dash.cloudflare.com/)
2. Go to **Zero Trust** → **Networks** → **Tunnels**
3. Click **Create tunnel**
4. Choose **Cloudflared** and click **Next**
5. Give your tunnel a name (e.g., "containr-tunnel")
6. Click **Save tunnel**
### 2. Get Your Tunnel Token
After creating the tunnel, Cloudflare will show you a command like:
```bash
cloudflared tunnel run <tunnel-id>
```
Copy the token from the `.cloudflared/config.yml` file or use the token provided by Cloudflare.
### 3. Configure Containr
1. Copy `.env.example` to `.env` if you haven't already:
```bash
cp .env.example .env
```
2. Edit `.env` and add your Cloudflare tunnel token:
```env
CLOUDFLARED_TOKEN=your_copied_tunnel_token_here
```
### 4. Start Services with Cloudflare Tunnel
```bash
# Start all services including cloudflared
make cloudflared-up
# Or start manually
docker-compose --profile cloudflared up -d
```
### 5. Configure Tunnel Routes
In your Cloudflare dashboard:
1. Go to your tunnel settings
2. Add the following public hostnames:
- `your-domain.com` → `http://traefik:80` (for frontend)
- `api.your-domain.com` → `http://traefik:80` (for backend)
- `traefik.your-domain.com` → `http://traefik:80` (for dashboard)
### 6. Access Your Services
Once configured, you can access:
- Frontend: `https://your-domain.com`
- API: `https://api.your-domain.com`
- Traefik Dashboard: `https://traefik.your-domain.com`
## Management Commands
```bash
# Start with Cloudflare tunnel
make cloudflared-up
# Stop Cloudflare tunnel
make cloudflared-down
# View logs
docker-compose logs -f cloudflared
# Check status
docker-compose ps
```
## Benefits
- **No domain configuration required** in `.env`
- **Automatic SSL** through Cloudflare
- **DDoS protection** and security features
- **Easy setup** - just need a tunnel token
- **Works anywhere** - no port forwarding needed
## Troubleshooting
### Tunnel Not Connecting
- Verify your `CLOUDFLARED_TOKEN` is correct
- Check cloudflared logs: `docker-compose logs cloudflared`
- Ensure your tunnel is active in Cloudflare dashboard
### Services Not Accessible
- Verify you've configured the public hostnames in Cloudflare
- Check that all services are running: `docker-compose ps`
- Ensure the tunnel routes point to `http://traefik:80`
### Token Issues
- Regenerate your tunnel token in Cloudflare dashboard
- Make sure there are no extra spaces or newlines in the token
## Alternative: Domain Mode
If you prefer traditional domain setup instead of Cloudflare tunnel:
1. Configure your domain in `.env`:
```env
DOMAIN=yourdomain.com
[email protected]
```
2. Use regular commands:
```bash
make prod
```
This will use Let's Encrypt certificates instead of Cloudflare tunnel.
+231
View File
@@ -0,0 +1,231 @@
# Docker Setup with Traefik
This guide will help you set up Containr with Docker, Traefik reverse proxy, and automatic SSL certificates.
## Prerequisites
- Docker and Docker Compose installed
- A domain name pointing to your server's IP address
- Port 80 and 443 open on your firewall
## Quick Start
1. **Clone and prepare the environment:**
```bash
git clone <your-repo>
cd containr
cp .env.example .env
```
2. **Configure your environment:**
Edit `.env` file with your settings:
```bash
nano .env
```
Required changes:
- `DOMAIN=yourdomain.com` - Your actual domain
- `ACME_EMAIL=admin@yourdomain.com` - Email for SSL certificates
- `POSTGRES_PASSWORD` - Set a secure password
- `REDIS_PASSWORD` - Set a secure password
- `JWT_SECRET` - Generate a secure random string
- `TRAEFIK_AUTH` - Generate basic auth for dashboard
3. **Generate Traefik authentication:**
```bash
# Install apache2-utils if needed
sudo apt-get install apache2-utils
# Generate username:password hash
htpasswd -nb admin yourpassword
# Update TRAEFIK_AUTH in .env with the output
```
4. **Create necessary directories:**
```bash
mkdir -p data/letsencrypt
chmod 600 data/letsencrypt/acme.json
```
5. **Start the services:**
```bash
docker-compose up -d
```
## Services and URLs
After deployment, your services will be available at:
- **Frontend**: `https://yourdomain.com`
- **Backend API**: `https://api.yourdomain.com`
- **Traefik Dashboard**: `https://traefik.yourdomain.com`
## Architecture
```
Internet → Traefik (Port 80/443)
├── Frontend (React/Nginx)
├── Backend (Go API)
├── PostgreSQL (Database)
└── Redis (Cache)
```
## Configuration Files
### Docker Compose
- `docker-compose.yml` - Main orchestration file
- Defines all services, networks, and volumes
- Configures Traefik with automatic SSL
### Traefik Configuration
- `traefik.yml` - Static configuration
- `traefik-dynamic.yml` - Dynamic routing rules
- Automatic HTTP to HTTPS redirection
- Security headers and rate limiting
### Dockerfiles
- `Dockerfile.backend` - Go backend with multi-stage build
- `Dockerfile.frontend` - React frontend with Nginx
- Both use non-root users for security
## Security Features
- **Automatic SSL** via Let's Encrypt
- **HTTP to HTTPS** redirection
- **Security headers** (HSTS, XSS protection, etc.)
- **Rate limiting** on API endpoints
- **Basic authentication** on Traefik dashboard
- **Non-root containers** for all services
- **Health checks** for all services
## Monitoring and Logs
### Traefik Dashboard
Access at `https://traefik.yourdomain.com` with your configured credentials.
### Logs
```bash
# View all logs
docker-compose logs -f
# View specific service logs
docker-compose logs -f traefik
docker-compose logs -f backend
docker-compose logs -f frontend
```
### Health Checks
All services include health checks:
```bash
# Check service status
docker-compose ps
```
## Maintenance
### Updates
```bash
# Pull latest images
docker-compose pull
# Recreate services with new images
docker-compose up -d --force-recreate
```
### Backups
```bash
# Backup PostgreSQL
docker-compose exec postgres pg_dump -U containr_user containr > backup.sql
# Backup Redis
docker-compose exec redis redis-cli --rdb /data/dump.rdb
```
### SSL Certificates
Let's Encrypt certificates are automatically renewed. Manual renewal:
```bash
docker-compose exec traefik traefik api check-letsencrypt
```
## Development Mode
For local development without SSL:
```bash
# Create development override
cat > docker-compose.override.yml << EOF
version: '3.8'
services:
traefik:
command:
- "--api.dashboard=true"
- "--providers.docker=true"
- "--entrypoints.web.address=:80"
- "--log.level=DEBUG"
ports:
- "80:80"
- "8080:8080"
labels:
- "traefik.http.routers.traefik.rule=Host(`localhost`)"
- "traefik.http.routers.traefik.entrypoints=web"
- "traefik.http.routers.traefik.service=api@internal"
EOF
# Start with override
docker-compose up -d
```
## Troubleshooting
### Common Issues
1. **SSL Certificate Issues**
```bash
# Check acme.json permissions
ls -la data/letsencrypt/acme.json
# Reset certificates
rm data/letsencrypt/acme.json
docker-compose restart traefik
```
2. **Port Conflicts**
```bash
# Check what's using ports
sudo netstat -tlnp | grep :80
sudo netstat -tlnp | grep :443
```
3. **Database Connection**
```bash
# Test database connection
docker-compose exec backend ping postgres
```
4. **Permission Issues**
```bash
# Fix volume permissions
sudo chown -R 1001:1001 data/
```
### Performance Tuning
1. **Nginx Caching** - Already configured in `nginx.conf`
2. **Redis Caching** - Configure in your application
3. **Database Pooling** - Adjust connection limits in Go app
## Production Tips
1. **Monitoring** - Set up Prometheus/Grafana
2. **Alerting** - Configure alerts for service failures
3. **Backup Strategy** - Automated database backups
4. **Load Testing** - Test before production deployment
5. **Security Audit** - Regular security scans
## Support
For issues:
1. Check logs: `docker-compose logs`
2. Verify configuration: `docker-compose config`
3. Check service status: `docker-compose ps`
4. Review Traefik dashboard for routing issues
+131
View File
@@ -0,0 +1,131 @@
# Containr Backend Setup
## Quick Start
### Prerequisites
- Go 1.21+
- PostgreSQL 12+
- Redis (optional)
### Environment Variables
Create a `.env` file or set these environment variables:
```bash
# Database
DATABASE_URL=postgres://containr:password@localhost:5432/containr?sslmode=disable
REDIS_URL=redis://localhost:6379
# Server
PORT=8080
ENVIRONMENT=development
# Security
JWT_SECRET=your-secret-key-change-in-production
# Frontend (for CORS)
FRONTEND_URL=http://localhost:3000
```
### Database Setup
1. Create PostgreSQL database:
```sql
CREATE DATABASE containr;
CREATE USER containr WITH PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE containr TO containr;
```
2. Run migrations (handled automatically on server start)
### Running the Server
```bash
# Build
go build -o bin/server cmd/server/main.go
# Run
./bin/server
```
The server will start on `http://localhost:8080`
### API Endpoints
#### Health Check
- `GET /health` - Server health status
#### Authentication
- `POST /api/v1/auth/login` - User login
- `POST /api/v1/auth/register` - User registration
#### User Profile
- `GET /api/v1/user/profile` - Get user profile (requires auth)
- `PUT /api/v1/user/profile` - Update user profile (requires auth)
#### Projects
- `GET /api/v1/projects` - List user projects (requires auth)
- `POST /api/v1/projects` - Create project (requires auth)
- `GET /api/v1/projects/:id` - Get project details (requires auth)
- `PUT /api/v1/projects/:id` - Update project (requires auth)
- `DELETE /api/v1/projects/:id` - Delete project (requires auth)
### Authentication
Include JWT token in Authorization header:
```
Authorization: Bearer <your-jwt-token>
```
### Example Usage
1. Register a user:
```bash
curl -X POST http://localhost:8080/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "password123",
"name": "Test User"
}'
```
2. Login:
```bash
curl -X POST http://localhost:8080/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "password123"
}'
```
3. Create a project (using token from login):
```bash
curl -X POST http://localhost:8080/api/v1/projects \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{
"name": "My Project",
"description": "A test project"
}'
```
## Development
### Project Structure
```
cmd/server/ - Main application entry point
internal/
├── api/ - HTTP handlers and routes
├── config/ - Configuration management
├── database/ - Database connections and migrations
└── middleware/ - HTTP middleware
migrations/ - SQL migration files
```
### Adding New Endpoints
1. Create handler functions in `internal/api/`
2. Add routes in `internal/api/routes.go`
3. Update database schema if needed in `migrations/`
+266
View File
@@ -0,0 +1,266 @@
# Docker Template Auto-Setup Guide
## 🚀 How It Works
The templates are **configuration files** that define how to run each service with Docker Compose. They don't auto-execute - you need to use the setup script to deploy them.
## 📋 Quick Start
### 1. Interactive Mode (Recommended)
```bash
# Run the setup script interactively
./scripts/setup-template.sh
```
### 2. Direct Template Selection
```bash
# Setup a specific template
./scripts/setup-template.sh umami
# List all available templates
./scripts/setup-template.sh --list
# Setup only (don't deploy)
./scripts/setup-template.sh --setup umami
# Deploy existing setup
./scripts/setup-template.sh --deploy umami
```
## 🔄 What the Script Does
### Step 1: Dependency Check
- ✅ Verifies Docker is installed
- ✅ Verifies Docker Compose is installed
- ✅ Checks template directory exists
### Step 2: Template Selection
- 📋 Shows available templates with descriptions
- 🎯 Lets you choose interactively or via command line
### Step 3: Project Setup
- 📁 Creates deployment directory (`template-name-deployment/`)
- 📄 Extracts `docker-compose.yml` from template
- 🔧 Creates `.env` file template with required variables
- ⚠️ Shows setup requirements and warnings
### Step 4: Deployment (Optional)
- 🐳 Pulls Docker images
- 🚀 Starts services with `docker-compose up -d`
- 📊 Shows service status and access URLs
- 📝 Provides useful commands
## 📁 Directory Structure After Setup
```
your-project/
├── scripts/
│ └── setup-template.sh # Auto-setup script
├── templates/
│ ├── umami.md # Template documentation
│ ├── plex.md
│ ├── immich.md
│ └── ...
└── umami-deployment/ # Created by setup script
├── docker-compose.yml # Extracted from template
├── .env # Environment variables
└── README.md # Setup instructions
```
## 🎯 Interactive Walkthrough Example
### Running Umami Setup:
```bash
$ ./scripts/setup-template.sh
========================================
Checking Dependencies
========================================
✅ Docker is installed
Docker version: 24.0.6
✅ Docker Compose is installed
Docker Compose version: 2.21.0
✅ All dependencies are met
========================================
Select Template
========================================
1) umami - Umami Analytics - Privacy-focused web analytics
2) plex - Plex Media Server - Media streaming and organization
3) immich - Immich - Photo and video backup solution
...
Select a template (1-20): 1
✅ Selected template: umami
========================================
Setting up umami
========================================
✅ Created project directory: /path/to/umami-deployment
✅ docker-compose.yml extracted
⚠️ This template requires environment variables:
- `DATABASE_URL`: PostgreSQL connection string
- `APP_SECRET`: Random string for application secrets
✅ Created .env template file
⚠️ Please edit umami-deployment/.env with your values before starting
Do you want to deploy the template now? (y/N): y
========================================
Deploying umami
========================================
✅ Pulling Docker images...
✅ Starting services...
✅ Deployment completed!
========================================
Access Information
========================================
✅ Service access URLs:
• http://localhost:3000 (container port: 3000)
Useful commands:
• View logs: docker-compose logs -f
• Stop services: docker-compose down
• Restart services: docker-compose restart
• Update services: docker-compose pull && docker-compose up -d
```
## 🔧 Manual Setup (Without Script)
If you prefer manual setup:
1. **Choose a template** from `/templates/`
2. **Copy the docker-compose.yml** section
3. **Create a project directory**
4. **Set up environment variables**
5. **Run `docker-compose up -d`**
Example for Umami:
```bash
mkdir umami-deployment
cd umami-deployment
# Copy docker-compose.yml from templates/umami.md
# Create .env file with required variables
docker-compose up -d
```
## 🎛️ Available Templates
| Template | Description | Difficulty |
|----------|-------------|------------|
| **umami** | Web Analytics | Easy |
| **plex** | Media Server | Medium |
| **immich** | Photo Backup | Medium |
| **n8n** | Workflow Automation | Medium |
| **supabase** | Backend Service | Hard |
| **home-assistant** | Smart Home | Medium |
| **uptime-kuma** | Monitoring | Easy |
| **grafana** | Metrics Dashboard | Medium |
| **traefik** | Reverse Proxy | Medium |
| **memos** | Note-taking | Easy |
| **meilisearch** | Search Engine | Easy |
| **vaultwarden** | Password Manager | Medium |
| **pihole** | DNS Blocker | Medium |
| **appwrite** | Backend Platform | Hard |
| **gitea** | Git Hosting | Medium |
| **mastodon** | Social Network | Hard |
| **jellyfin** | Media Server | Medium |
| **nextcloud** | Cloud Storage | Hard |
| **glance** | Dashboard | Easy |
| **cloudreve** | File Manager | Medium |
## 🛠️ Advanced Usage
### Custom Deployment Directory
```bash
# Set custom deployment directory
export DEPLOY_DIR="/opt/my-services"
./scripts/setup-template.sh umami
```
### Batch Setup
```bash
# Setup multiple templates
for template in umami plex nextcloud; do
./scripts/setup-template.sh --setup "$template"
done
```
### Production Deployment
```bash
# Setup with production considerations
./scripts/setup-template.sh --setup umami
cd umami-deployment
# Edit .env with production values
# Configure reverse proxy
# Set up SSL certificates
# Run deployment
./scripts/setup-template.sh --deploy umami
```
## 🔍 Troubleshooting
### Common Issues
1. **Docker not installed**
```bash
# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
```
2. **Permission denied**
```bash
# Add user to docker group
sudo usermod -aG docker $USER
# Log out and back in
```
3. **Port conflicts**
```bash
# Check what's using ports
netstat -tulpn | grep :3000
# Modify docker-compose.yml to use different ports
```
4. **Environment variables not set**
```bash
# Edit .env file
nano umami-deployment/.env
# Replace change_me values
```
### Getting Help
Each template includes:
- ✅ **Complete setup instructions**
- ✅ **Environment variable explanations**
- ✅ **Troubleshooting section**
- ✅ **Backup strategies**
- ✅ **Performance optimization**
## 🎯 Next Steps
1. **Try the interactive setup**:
```bash
./scripts/setup-template.sh
```
2. **Start with an easy template** (umami, glance, memos)
3. **Read the template documentation** before deployment
4. **Check the troubleshooting section** if you encounter issues
5. **Join the community** for each service for additional support
## 📞 Support
For issues with:
- **Setup script**: Create an issue in this repository
- **Specific service**: Check the service's official documentation
- **Docker issues**: Refer to Docker documentation
Each template includes links to official documentation and community support channels.