diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..4c843024 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# Stage 1: Build +FROM python:3.11 AS builder + +WORKDIR /app + +# Copy only dependency files first for better caching +COPY requirements.txt /app/ +RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -r requirements.txt + +# Stage 2: Final image +FROM python:3.11-slim + +WORKDIR /app + +# Copy installed dependencies from builder stage +COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages +COPY --from=builder /usr/local/bin /usr/local/bin + +# Copy application files +COPY ./app /app + +# Set environment variables +ENV PYTHONUNBUFFERED=1 + +# Expose API port +EXPOSE 8000 + +# Default command +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]