No description
Find a file
2025-04-12 17:25:58 +02:00
config Server migration 2025-03-16 22:03:58 +01:00
.gitignore Initial commit 2025-03-16 22:02:17 +01:00
Dockerfile Latest version update 2025-04-12 17:25:58 +02:00
LICENSE Server migration 2025-03-16 22:03:58 +01:00
README.md Server migration 2025-03-16 22:03:58 +01:00

Nextcloud Docker Container

Docker

A production-ready Docker container setup for Nextcloud using Alpine Linux, Nginx, PHP-FPM, and PostgreSQL.

Features

  • 🐳 Dockerized Nextcloud instance with optimal configuration
  • 🏔 Alpine Linux base image for minimal footprint
  • 🚀 Nginx + PHP-FPM 8.2 performance stack
  • 🐘 PostgreSQL database integration
  • 🔄 Redis caching for improved performance
  • 🔒 Automatic SSL configuration support
  • 📦 Persistent storage for data and configurations
  • 📊 Built-in health monitoring and metrics

Getting Started

1. Clone Repository

git clone https://git.esculta.es/aesculta/nextcloud.git
cd nextcloud

2. Directory Structure

.
├── docker-compose.yml
├── Dockerfile
├── config/
│   ├── nginx/
│   ├── php/
│   └── redis/
├── entrypoint.sh
├── .env.example
└── README.md

3. Environment Setup

  1. Copy environment template:
    cp .env.example .env
    
  2. Edit .env file:
    # Database
    POSTGRES_USER=nextcloud
    POSTGRES_PASSWORD=strongpassword
    POSTGRES_DB=nextcloud
    
    # Nextcloud
    NEXTCLOUD_ADMIN_USER=admin
    NEXTCLOUD_ADMIN_PASSWORD=secureadminpass
    NEXTCLOUD_TRUSTED_DOMAINS=cloud.example.com
    
    # Redis
    REDIS_PASSWORD=redispass
    
    # Generate secrets with: openssl rand -base64 48
    NEXTCLOUD_SECRET=generate_strong_secret
    POSTGRES_SECRET=generate_strong_secret
    

4. Start Containers

docker-compose build --no-cache && docker-compose up -d

Configuration

Services Architecture

graph TD
    A[User] --> B[Nginx:80/443]
    B --> C[PHP-FPM:9000]
    C --> D[PostgreSQL:5432]
    C --> E[Redis:6379]
    F[pgAdmin] --> D

Port Mapping

Service Port Protocol Description
Nextcloud 8080 HTTP Web Interface
PostgreSQL 5432 TCP Database Access
pgAdmin 5050 HTTP DB Management

Maintenance

Backup Data

# Create backup archive
docker run --rm --volumes-from nextcloud-app -v $(pwd)/backups:/backup alpine \
    tar czf /backup/nextcloud-$(date +%Y-%m-%d).tar.gz /var/www/html

Update Nextcloud

  1. Pull latest images:
    docker-compose pull
    
  2. Recreate containers:
    docker-compose down && docker-compose up -d
    
  3. Run upgrade:
    docker exec -it nextcloud-app php occ upgrade
    

Security Best Practices

  1. Enable HTTPS: Modify nginx/ssl.conf with your SSL certificates
  2. Regular Updates:
    docker-compose pull && docker-compose build --no-cache
    
  3. Database Backups:
    docker exec postgres pg_dump -U nextcloud nextcloud > backup.sql
    
  4. Firewall Rules:
    ufw allow 80/tcp
    ufw allow 443/tcp
    ufw enable
    

Troubleshooting

Common Issues

Issue: File upload size limitations
Fix: Adjust PHP settings in config/php/php.ini:

upload_max_filesize = 16G
post_max_size = 16G

Issue: Database connection errors
Verify:

docker exec -it postgres psql -U nextcloud -d nextcloud

Issue: Slow performance
Optimize:

docker exec -it nextcloud-app php occ files:scan --all
docker exec -it nextcloud-app php occ maintenance:repair

License

GPL v3.0 - See LICENSE for details


Note

: For production deployments, consider adding:

  • Reverse proxy with HTTPS termination
  • Monitoring (Prometheus/Grafana)
  • Regular backup automation
  • Resource limits in docker-compose.yml