Add Docker support and improve PDF conversion

Features:
- Dockerfile for containerized deployment
- Docker Compose configuration with health checks
- Automated database initialization via entrypoint script
- Quick start script for easy Docker deployment
- Comprehensive Docker deployment documentation (DOCKER.md)
- Complete README with installation and usage instructions
- .dockerignore for optimized image builds

Improvements:
- PDF conversion now preserves orientation (portrait/landscape)
- PDF rendering at 300 DPI for sharp quality
- Maintains aspect ratio during conversion
- Compact media library view with image thumbnails
- Better media preview with scrollable gallery

Docker Features:
- Multi-stage build for smaller images
- Non-root user for security
- Health checks for container monitoring
- Volume mounts for persistent data
- Production-ready Gunicorn configuration
- Support for Redis caching (optional)
This commit is contained in:
DigiServer Developer
2025-11-17 21:05:49 +02:00
parent 2e3e181bb2
commit 2db0033bc0
9 changed files with 827 additions and 42 deletions

44
docker-entrypoint.sh Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/bash
set -e
echo "Starting DigiServer v2..."
# Create necessary directories
mkdir -p /app/instance
mkdir -p /app/app/static/uploads
# Initialize database if it doesn't exist
if [ ! -f /app/instance/digiserver.db ]; then
echo "Initializing database..."
python -c "
from app.app import create_app
from app.extensions import db, bcrypt
from app.models import User
app = create_app()
with app.app_context():
db.create_all()
# Create admin user
admin = User.query.filter_by(username='admin').first()
if not admin:
hashed = bcrypt.generate_password_hash('admin123').decode('utf-8')
admin = User(username='admin', password=hashed, role='admin')
db.session.add(admin)
db.session.commit()
print('✅ Admin user created (admin/admin123)')
else:
print('✅ Admin user already exists')
"
echo "Database initialized!"
fi
# Start the application
echo "Starting Gunicorn..."
exec gunicorn \
--bind 0.0.0.0:5000 \
--workers 4 \
--timeout 120 \
--access-logfile - \
--error-logfile - \
"app.app:create_app()"