FROM python:3.11-slim

# Prevent Python from writing .pyc files and buffer stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/cloud

WORKDIR /cloud

# Copy requirements from build context root or relative path
COPY cloud/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application source code
COPY cloud/ .
COPY shared/ ./shared/

# Create photo storage directory
RUN mkdir -p storage/dishPhotos

EXPOSE 5000

# Call gunicorn directly
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "2", "--threads", "4", "--timeout", "300", "app:app"]