Vestiq / README-docker-compose.md
Hashii1729's picture
Refactor Docker setup: remove Ollama integration, update FastAPI service, enhance health checks, and improve README documentation
2e94196

Fashion Analyzer - Docker Compose Setup

This project provides a secure, containerized fashion analysis application using Hugging Face Transformers and FastAPI with Docker Compose.

πŸ—οΈ Architecture

The application consists of a single service:

  1. FastAPI Service: Provides the web API and user interface with integrated Hugging Face transformers models for fashion analysis

πŸ”’ Security Features

  • βœ… Pinned Python version (3.11-slim) - Secure base image
  • βœ… Non-root user execution - Enhanced container security
  • βœ… Security updates - Latest package updates applied
  • βœ… Health checks - Service monitoring and restart policies
  • βœ… Minimal dependencies - Reduced attack surface

πŸš€ Quick Start

Prerequisites

  • Docker Engine 20.10+
  • Docker Compose 2.0+

1. Start the Application

# Start all services
docker-compose up -d

# View logs
docker-compose logs -f

# Check service status
docker-compose ps

2. Access the Application

3. Stop the Application

# Stop all services
docker-compose down

# Stop and remove volumes (removes logs)
docker-compose down -v

πŸ“ Project Structure

AI/
β”œβ”€β”€ docker-compose.yml      # Main orchestration file
β”œβ”€β”€ Dockerfile.fastapi      # FastAPI service Dockerfile
β”œβ”€β”€ .env                    # Environment variables
β”œβ”€β”€ .dockerignore          # Docker build exclusions
β”œβ”€β”€ fast.py                # FastAPI application
β”œβ”€β”€ requirements.txt       # Python dependencies
└── logs/                  # Application logs (created at runtime)

βš™οΈ Configuration

Environment Variables (.env)

FASTAPI_PORT=7860
ENVIRONMENT=development
LOG_LEVEL=info

Custom Configuration

To modify ports or other settings:

  1. Edit .env file
  2. Restart services: docker-compose up -d

πŸ”§ Development

Building Images

# Build only FastAPI service
docker-compose build fastapi

# Build with no cache
docker-compose build --no-cache

Viewing Logs

# All services
docker-compose logs -f

# Specific service
docker-compose logs -f fastapi

Debugging

# Execute commands in running containers
docker-compose exec fastapi bash

# Check service health
docker-compose exec fastapi curl http://localhost:7860/health

πŸ“Š Monitoring

Health Checks

The FastAPI service includes health checks:

  • FastAPI: Checks application health and model availability

πŸ› οΈ Troubleshooting

Common Issues

  1. Port conflicts: Change ports in .env file
  2. Model loading fails: Check internet connection and available memory
  3. Application startup slow: Transformers models need time to download and load

Reset Everything

# Stop and remove everything
docker-compose down -v --remove-orphans

# Remove images
docker-compose down --rmi all

# Start fresh
docker-compose up -d

πŸ“ˆ Scaling

To run multiple FastAPI instances:

# Scale FastAPI service
docker-compose up -d --scale fastapi=3

Note: You'll need a load balancer for multiple instances.

πŸ” Security Considerations

  • Services run as non-root users
  • Network isolation between services
  • No sensitive data in environment variables
  • Regular security updates applied
  • Pinned dependency versions

πŸ“ API Usage

Upload and Analyze Image

curl -X POST "http://localhost:7860/analyze-image" \
     -H "accept: application/json" \
     -H "Content-Type: multipart/form-data" \
     -F "[email protected]"

Health Check

curl http://localhost:7860/health

🀝 Contributing

  1. Make changes to the code
  2. Test with docker-compose up --build
  3. Submit pull request

πŸ“„ License

This project is licensed under the MIT License.