This guide explains how to deploy Retouchly using Docker.
- Docker installed on your system
- Docker Compose (usually comes with Docker Desktop)
Copy the production environment file and fill in your values:
cp .env.production .env.production.localEdit .env.production.local with your actual production values:
# Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key
# OpenAI API Key for AI Assistant
OPENAI_API_KEY=sk-your_openai_key
# Replicate API Token for AI Models
REPLICATE_API_TOKEN=r8_your_replicate_token
# Iyzico Payment Configuration (for production)
IYZICO_API_KEY=your_iyzico_key
IYZICO_API_SECRET=your_iyzico_secret
IYZICO_BASE_URL=https://api.iyzipay.com# Build and start the application
npm run docker:compose:up
# View logs
npm run docker:compose:logs
# Stop the application
npm run docker:compose:down# Build the Docker image
npm run docker:build
# Run the container
npm run docker:run# Build the image
docker build -t retouchly .
# Build with specific tag
docker build -t retouchly:v1.0.0 .# Run with environment file
docker run -p 3000:3000 --env-file .env.production.local retouchly
# Run with individual environment variables
docker run -p 3000:3000 \
-e NEXT_PUBLIC_SUPABASE_URL=your_url \
-e NEXT_PUBLIC_SUPABASE_ANON_KEY=your_key \
-e OPENAI_API_KEY=your_openai_key \
retouchly# Start services in background
docker-compose up -d
# Start services with logs
docker-compose up
# Stop services
docker-compose down
# View logs
docker-compose logs -f retouchly
# Rebuild and restart
docker-compose up --build -dThe application includes a health check endpoint:
curl http://localhost:3000/api/healthResponse:
{
"status": "ok",
"timestamp": "2024-01-01T00:00:00.000Z",
"uptime": 123.456,
"environment": "production",
"version": "1.0.0"
}Ensure all required environment variables are set:
NEXT_PUBLIC_SUPABASE_URL: Your Supabase project URLNEXT_PUBLIC_SUPABASE_ANON_KEY: Your Supabase anonymous keyOPENAI_API_KEY: Your OpenAI API key for AI assistantREPLICATE_API_TOKEN: Your Replicate API token for AI modelsIYZICO_API_KEY: Your Iyzico API key (for payments)IYZICO_API_SECRET: Your Iyzico API secretIYZICO_BASE_URL: Iyzico API base URL
- Use secrets management for sensitive environment variables
- Enable HTTPS in production
- Configure proper firewall rules
- Use a reverse proxy (nginx, Traefik) for SSL termination
- Monitor application logs and metrics
For production scaling, consider:
- Using Docker Swarm or Kubernetes
- Adding a load balancer
- Implementing Redis for session storage
- Using a CDN for static assets
- Database connection pooling
-
Build fails with dependency errors
# Clear Docker cache and rebuild docker system prune -a docker build --no-cache -t retouchly .
-
Application won't start
# Check logs docker logs <container_id> # Check environment variables docker exec -it <container_id> env
-
Health check fails
# Test health endpoint curl -f http://localhost:3000/api/health # Check application logs docker-compose logs retouchly
- Multi-stage builds: Already implemented in Dockerfile
- Layer caching: Dependencies are cached separately
- Standalone output: Next.js standalone mode for smaller images
- Alpine Linux: Using alpine base image for smaller size
# View resource usage
docker stats
# View specific container stats
docker stats retouchlyThe application exposes metrics at:
- Health:
/api/health - Logs: Available through Docker logs
Supabase handles database backups automatically, but you can also:
- Export data through Supabase dashboard
- Use Supabase CLI for automated backups
- Implement custom backup scripts
If using local file storage, ensure to:
- Mount volumes for persistent data
- Implement regular backup procedures
- Test recovery procedures
# Pull latest code
git pull origin main
# Rebuild and restart
docker-compose up --build -d
# Check health
curl http://localhost:3000/api/health# Update base image
docker pull node:18-alpine
# Rebuild with latest dependencies
docker build --no-cache -t retouchly .