Skip to main content
Docker lets you run mySpellChecker without installing Python dependencies locally. The multi-stage Dockerfile provides optimized images for production API, development, and CLI-only use cases.

Quick Start

Using Docker Directly

Available Docker Images

The Dockerfile uses multi-stage builds to create optimized images for different use cases:

Building Specific Targets

Docker Compose Services

Production API (api)

  • Port: 8000
  • Health check: http://localhost:8000/health
  • Resource limits: 2 CPUs, 1GB memory
  • Restart policy: unless-stopped

Development Server (dev)

  • Port: 8000
  • Hot reload: Enabled (watches /app/src)
  • Log level: DEBUG
  • Profile: dev (requires --profile dev)

GPU-Enabled API (api-gpu)

For transformer-based POS tagging and AI features:
  • Requires: NVIDIA GPU with Docker GPU support
  • Resource limits: 4 CPUs, 4GB memory, 1 GPU
  • Environment: CUDA_VISIBLE_DEVICES=0

CLI Tool (cli)

Test Runner (test)

Runs pytest with coverage reporting.

Volume Mounts

Example: Using Custom Dictionary

Environment Variables

Custom Environment

Production Deployment

Basic Deployment

With Reverse Proxy (nginx)

Health Monitoring

The docker-compose configuration includes a health check that calls your API’s health endpoint. You must implement this endpoint in your API wrapper (e.g., FastAPI):

Building Dictionary in Docker

From Corpus File

Sample Dictionary

GPU Support

Prerequisites

  1. NVIDIA GPU with CUDA support
  2. NVIDIA Container Toolkit

Installation (Ubuntu)

Running with GPU

Troubleshooting

Container Won’t Start

Database Not Found

Permission Denied

GPU Not Detected

Memory Issues

Security Considerations

The Docker images follow security best practices:
  1. Non-root user: Containers run as appuser (UID 1000)
  2. Read-only mounts: Data volumes mounted as read-only where possible
  3. Minimal base image: Uses python:slim for smaller attack surface
  4. No secrets in image: Configuration via environment variables or mounted volumes
  5. Health checks: Automatic container health monitoring

Running with Read-Only Filesystem

See Also