Files
stiftung-management-system/deploy-production/setup-paperless.sh
Stiftung Development fa6d1b64df Add Paperless-ngx to production deployment
- Add Paperless-ngx service to Docker Compose configuration
- Configure nginx routing for /paperless/ path with large file support
- Add production environment variables for Paperless
- Create automated setup script for initial Paperless configuration
- Add comprehensive production setup documentation
- Configure Paperless with HTTPS and proper database setup
- Update Django app to use production Paperless instance
2025-09-09 22:00:32 +02:00

64 lines
2.6 KiB
Bash

#!/bin/bash
# Paperless-ngx Production Setup Script
# Run this script after deploying the updated Docker Compose configuration
set -e
echo "🔧 Setting up Paperless-ngx in production..."
# Check if we're in the right directory
if [ ! -f "docker-compose.yml" ]; then
echo "❌ Error: docker-compose.yml not found. Please run this script from /opt/stiftung"
exit 1
fi
# Generate a random secret key for Paperless
echo "🔑 Generating Paperless secret key..."
PAPERLESS_SECRET=$(python3 -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())")
echo "📝 Add this to your .env file:"
echo "PAPERLESS_SECRET_KEY=$PAPERLESS_SECRET"
echo ""
# Start containers
echo "🚀 Starting containers..."
docker-compose up -d
# Wait for database to be ready
echo "⏳ Waiting for database to be ready..."
sleep 30
# Create database for Paperless if it doesn't exist
echo "🗄️ Setting up Paperless database..."
docker-compose exec -T db psql -U ${POSTGRES_USER:-stiftung} -d ${POSTGRES_DB:-stiftung} -c "CREATE DATABASE paperless_prod;" || echo "Database may already exist"
docker-compose exec -T db psql -U ${POSTGRES_USER:-stiftung} -d ${POSTGRES_DB:-stiftung} -c "CREATE USER paperless_user WITH PASSWORD 'secure-paperless-password';" || echo "User may already exist"
docker-compose exec -T db psql -U ${POSTGRES_USER:-stiftung} -d ${POSTGRES_DB:-stiftung} -c "GRANT ALL PRIVILEGES ON DATABASE paperless_prod TO paperless_user;" || echo "Privileges may already be granted"
# Run Paperless migrations
echo "📊 Running Paperless migrations..."
docker-compose exec -T paperless python3 manage.py migrate
# Create Paperless superuser
echo "👤 Creating Paperless superuser..."
echo "Note: You'll need to set a strong password for the admin user"
docker-compose exec paperless python3 manage.py createsuperuser --username admin --email admin@vhtv-stiftung.de
# Get API token
echo "🔐 Getting API token for Django integration..."
echo "You can get your API token by:"
echo "1. Visiting https://vhtv-stiftung.de/paperless/admin/"
echo "2. Going to Authentication and Authorization > Tokens"
echo "3. Creating a new token for your admin user"
echo "4. Adding the token to your .env file as PAPERLESS_API_TOKEN"
echo ""
echo "✅ Paperless-ngx setup complete!"
echo ""
echo "📚 Next steps:"
echo "1. Update your .env file with the generated PAPERLESS_SECRET_KEY"
echo "2. Visit https://vhtv-stiftung.de/paperless/ to access Paperless"
echo "3. Create an API token in the Paperless admin interface"
echo "4. Update PAPERLESS_API_TOKEN in your .env file"
echo "5. Restart containers: docker-compose restart"