26 lines
679 B
Docker
26 lines
679 B
Docker
# Use Python 3.10 slim image
|
|
FROM python:3.10-slim
|
|
|
|
WORKDIR /app
|
|
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# Copy requirements first for better caching
|
|
COPY requirements.txt .
|
|
|
|
# Install Python packages with timeout
|
|
RUN pip install --no-cache-dir -r requirements.txt \
|
|
--timeout=100 || pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code - MUST include microservice.py
|
|
COPY microservice.py .
|
|
|
|
ENV FLASK_ENV=production
|
|
ENV FLASK_APP=microservice.py
|
|
ENV FLASK_RUN_HOST=0.0.0.0
|
|
ENV FLASK_RUN_PORT=5001
|
|
|
|
EXPOSE 5001
|
|
|
|
# Use python -m to run the module directly
|
|
CMD ["python", "-m", "gunicorn", "--bind", "0.0.0.0:5001", "--workers", "2", "--timeout", "120", "microservice:app"] |