nextcloud/README.md
2025-03-16 22:03:58 +01:00

164 lines
No EOL
3.7 KiB
Markdown

# Nextcloud Docker Container
![Docker](https://img.shields.io/badge/Podman-✓-blue?logo=podman)
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
```bash
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:
```bash
cp .env.example .env
```
2. Edit `.env` file:
```ini
# 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
```bash
docker-compose build --no-cache && docker-compose up -d
```
## Configuration
### Services Architecture
```mermaid
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
```bash
# 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:
```bash
docker-compose pull
```
2. Recreate containers:
```bash
docker-compose down && docker-compose up -d
```
3. Run upgrade:
```bash
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**:
```bash
docker-compose pull && docker-compose build --no-cache
```
3. **Database Backups**:
```bash
docker exec postgres pg_dump -U nextcloud nextcloud > backup.sql
```
4. **Firewall Rules**:
```bash
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`:
```ini
upload_max_filesize = 16G
post_max_size = 16G
```
**Issue**: Database connection errors
**Verify**:
```bash
docker exec -it postgres psql -U nextcloud -d nextcloud
```
**Issue**: Slow performance
**Optimize**:
```bash
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](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