BLUF: SmartSlim Server's Docker deployment has four steps — build image, write docker-compose.yml, start service, verify health check. Image size is approximately 450MB, minimum configuration is 2 cores and 4GB RAM, and health check passes within 5 seconds of startup. Production environments require volume persistence, Nginx reverse proxy, log collection, and scheduled backups. This article provides a complete docker-compose.yml configuration, environment variable table, and detailed deployment steps. Below, we start with the deployment architecture and proceed step by step to a production-grade deployment.
If you need to know how to call the compression API after Docker deployment, we recommend readingCompression API Guide: RESTful Interface Documentation。
1. Docker Deployment Architecture
SmartSlim Server's Docker deployment uses a single-container architecture, running the FastAPI application internally, with volumes for file and config persistence, and port mapping for external service access. Production environments add an Nginx reverse proxy layer for TLS termination and load balancing.
| Component | Technology | Function | Port |
|---|---|---|---|
| SmartSlim Container | Python 3.9 + FastAPI | Compression service core | 8000 (internal) |
| Nginx Container | Nginx 1.25 | Reverse proxy/TLS | 80/443 (external) |
| Volume-data | Docker Volume | Compressed file storage | - |
| Volume-logs | Docker Volume | Log files | - |
| Volume-config | Docker Volume | Config and license | - |
Before deployment, confirm the server meets minimum configuration requirements. The table below provides configuration recommendations for different workloads.
| Scale | CPU | RAM | Disk | Concurrency | Use Case |
|---|---|---|---|---|---|
| Minimum | 2 cores | 4GB | 20GB | 4 | Testing/small team |
| Recommended | 4 cores | 8GB | 50GB | 8 | Medium enterprise |
| High-load | 8 cores | 16GB | 100GB | 16 | Large enterprise |
| Cluster | 4 cores x3 nodes | 8GB x3 | Shared storage | 24+ | High-availability production |
2. docker-compose.yml Configuration Reference
Below is the core docker-compose.yml configuration for production, including SmartSlim service, Nginx reverse proxy, volumes, and network configuration.
| Config Item | Description | Example |
|---|---|---|
| image | Image name | uglypear/smartslim-server:latest |
| restart | Restart policy | always (production) |
| ports | Port mapping | 8000:8000 |
| volumes | Volume mount | ./data:/app/data |
| environment | Environment variables | SMARTSLIM_LICENSE=xxx |
| healthcheck | Health check | curl -f http://localhost:8000/health |
| depends_on | Dependencies | nginx |
| deploy.resources | Resource limits | cpus:4, memory:8G |
3. Environment Variable Configuration
SmartSlim Server configures runtime parameters via environment variables. The table below lists all configurable items.
| Environment variables | Required | Default | Description |
|---|---|---|---|
| SMARTSLIM_LICENSE | Yes | - | License key |
| SMARTSLIM_HOST | No | 0.0.0.0 | Listen address |
| SMARTSLIM_PORT | No | 8000 | Listen port |
| SMARTSLIM_WORKERS | No | 4 | Worker processes |
| SMARTSLIM_MAX_FILE_SIZE | No | 1073741824 | Single-file limit (1GB) |
| SMARTSLIM_SECURITY_LEVEL | No | MEDIUM | Security level |
| SMARTSLIM_RATE_LIMIT | No | 60 | Requests per minute limit |
| SMARTSLIM_LOG_LEVEL | No | INFO | Log level |
| SMARTSLIM_TEMP_DIR | No | /app/data/tmp | Temp file directory |
4. Deployment Steps
Docker deployment has four phases: build, start, verify, monitor. The table below provides operations and verification methods for each step.
| Step | Operation | Command | Verification |
|---|---|---|---|
| 1. Build image | Build SmartSlim image | docker build -t smartslim-server . | docker images to view image |
| 2. Write config | Write docker-compose.yml | Edit yml file | docker-compose config to verify |
| 3. Start service | Start all containers | docker-compose up -d | docker-compose ps to check status |
| 4. Verify health | Check service availability | curl http://localhost:8000/health | Returns {"status":"ok"} |
| 5. Configure Nginx | Configure reverse proxy | Edit nginx.conf | curl https://domain/health |
| 6. Deploy monitoring | Configure logging and monitoring | Configure log collection | docker logs to view logs |
5. Production Best Practices
Production deployment requires attention to four areas: health checks, log collection, data backup, and security hardening. The table below provides best practice recommendations.
| Practice | Configuration | Check Frequency | Tool |
|---|---|---|---|
| Health check | interval:30s, timeout:10s, retries:3 | Real-time | Docker healthcheck |
| Log collection | json-file driver, max-size:100m, max-file:5 | Real-time | Docker logging |
| Data backup | Daily backup of data volume to independent storage | Daily | cron + docker run |
| Security hardening | Run as non-root user, read-only filesystem | At deployment | Docker security |
| Resource limits | cpus:4, memory:8G, alert threshold 80% | Real-time | Docker stats |
| Image update | Regularly pull latest image for rolling update | Monthly | docker-compose pull |
A complete health check configuration example: set interval to 30s (check every 30 seconds), timeout to 10s (timeout determines failure), retries to 3 (3 consecutive failures marks unhealthy), and start_period to 10s (start checking 10s after startup). This way, container anomalies are detected within 90 seconds and automatically restarted.
| Metric | Normal Range | Alert Threshold | View Command |
|---|---|---|---|
| CPU usage | 0%–60% | >80% | docker stats |
| Memory usage | 0%–70% | >85% | docker stats |
| Disk usage | 0%–70% | >85% | df -h |
| API response time | 0–2s | >5s | curl -w parameter |
| Compression queue length | 0–20 | >50 | API status endpoint |
| Error rate | 0%–0.1% | >1% | Log statistics |
If you need to understand the underlying design of compression task queues, seeCompression Task Queue Design. If you prefer local SDK integration over server deployment, seeCompression SDK Integration Guide。
6. FAQ
Q1: What configuration is needed for Docker deployment of compression services?
SmartSlim Server Docker deployment minimum configuration: 2-core CPU, 4GB RAM, 20GB disk space; recommended configuration: 4-core CPU, 8GB RAM, 50GB disk. The OS requires Docker 20.10+ and Docker Compose 2.0+. Supports x86_64 and ARM64 architectures, with an image size of approximately 450MB. For production, reserve additional disk space for temporary compression files.
Q2: How to update and upgrade Docker-deployed compression services?
The update process has three steps: 1. docker-compose pull to fetch the latest image; 2. docker-compose up -d to restart containers (volume data is preserved); 3. Check the health check endpoint to confirm the service is normal. Back up data volumes before updating (docker run --volumes-from backup). Rolling updates can achieve zero downtime in Kubernetes environments. Version compatibility is good; review the changelog before major version upgrades.
Q3: How to implement data persistence for Docker compression services?
Data persistence is achieved through Docker volumes. Three directories need to be mounted: /app/data (compressed file storage), /app/logs (log files), and /app/config (config files and license keys). Declare host-to-container mappings using the volumes field in docker-compose.yml. Deleting containers does not delete volumes, so data is safe. For production, mount volumes to independent disks or NAS for easier backup and scaling.
Q4: Does Docker compression service support high-availability deployment?
SmartSlim Server edition supports single-machine Docker deployment, while the Cloud edition supports Docker Compose multi-service and Kubernetes high-availability deployment. In Kubernetes, HPA (Horizontal Pod Autoscaler) enables elastic scaling of 3-10 replicas, combined with shared storage (MinIO) and shared database (MySQL) for statelessness. Single-machine can achieve simple HA via Nginx load balancing + multiple instances, but the Cloud K8s solution is recommended for production.
Summary
SmartSlim Server's Docker deployment in four steps: build image, write docker-compose.yml, start service, verify health check. Image is 450MB, minimum 2 cores 4GB to run, health check passes in 5 seconds. Nine environment variables cover core parameters including license, concurrency, security, and rate limiting. Six production best practices: 30s health check interval, 100MB log rotation, daily data backup, non-root security hardening, 4-core 8GB resource limits, and monthly image updates.
Remember three points: first, mount three volume directories (data/logs/config) — deleting containers won't lose data; second, configure health check with interval:30s + retries:3 to detect anomalies within 90 seconds and auto-restart; third, add Nginx reverse proxy for TLS termination in production — don't expose port 8000 directly. After deployment, combine with the compression API and task queue to build a complete compression service.
Related Articles
Need to Compress Files? Try SmartSlim
Built on a self-developed Rust compression engine, supporting 10 categories and 40+ formats including PDF, images, video, Office, and OFD, with local compression that keeps your data on-premises.