Docker Compression Service Deployment: SmartSlim Server in Practice

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.

ComponentTechnologyFunctionPort
SmartSlim ContainerPython 3.9 + FastAPICompression service core8000 (internal)
Nginx ContainerNginx 1.25Reverse proxy/TLS80/443 (external)
Volume-dataDocker VolumeCompressed file storage-
Volume-logsDocker VolumeLog files-
Volume-configDocker VolumeConfig and license-

Before deployment, confirm the server meets minimum configuration requirements. The table below provides configuration recommendations for different workloads.

ScaleCPURAMDiskConcurrencyUse Case
Minimum2 cores4GB20GB4Testing/small team
Recommended4 cores8GB50GB8Medium enterprise
High-load8 cores16GB100GB16Large enterprise
Cluster4 cores x3 nodes8GB x3Shared storage24+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 ItemDescriptionExample
imageImage nameuglypear/smartslim-server:latest
restartRestart policyalways (production)
portsPort mapping8000:8000
volumesVolume mount./data:/app/data
environmentEnvironment variablesSMARTSLIM_LICENSE=xxx
healthcheckHealth checkcurl -f http://localhost:8000/health
depends_onDependenciesnginx
deploy.resourcesResource limitscpus:4, memory:8G

3. Environment Variable Configuration

SmartSlim Server configures runtime parameters via environment variables. The table below lists all configurable items.

Environment variablesRequiredDefaultDescription
SMARTSLIM_LICENSEYes-License key
SMARTSLIM_HOSTNo0.0.0.0Listen address
SMARTSLIM_PORTNo8000Listen port
SMARTSLIM_WORKERSNo4Worker processes
SMARTSLIM_MAX_FILE_SIZENo1073741824Single-file limit (1GB)
SMARTSLIM_SECURITY_LEVELNoMEDIUMSecurity level
SMARTSLIM_RATE_LIMITNo60Requests per minute limit
SMARTSLIM_LOG_LEVELNoINFOLog level
SMARTSLIM_TEMP_DIRNo/app/data/tmpTemp 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.

StepOperationCommandVerification
1. Build imageBuild SmartSlim imagedocker build -t smartslim-server .docker images to view image
2. Write configWrite docker-compose.ymlEdit yml filedocker-compose config to verify
3. Start serviceStart all containersdocker-compose up -ddocker-compose ps to check status
4. Verify healthCheck service availabilitycurl http://localhost:8000/healthReturns {"status":"ok"}
5. Configure NginxConfigure reverse proxyEdit nginx.confcurl https://domain/health
6. Deploy monitoringConfigure logging and monitoringConfigure log collectiondocker 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.

PracticeConfigurationCheck FrequencyTool
Health checkinterval:30s, timeout:10s, retries:3Real-timeDocker healthcheck
Log collectionjson-file driver, max-size:100m, max-file:5Real-timeDocker logging
Data backupDaily backup of data volume to independent storageDailycron + docker run
Security hardeningRun as non-root user, read-only filesystemAt deploymentDocker security
Resource limitscpus:4, memory:8G, alert threshold 80%Real-timeDocker stats
Image updateRegularly pull latest image for rolling updateMonthlydocker-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.

MetricNormal RangeAlert ThresholdView Command
CPU usage0%–60%>80%docker stats
Memory usage0%–70%>85%docker stats
Disk usage0%–70%>85%df -h
API response time0–2s>5scurl -w parameter
Compression queue length0–20>50API status endpoint
Error rate0%–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.

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.