File size: 1,011 Bytes
319ba2b 6d53f81 32a42a9 e068f76 32a42a9 f7fda42 6d53f81 f738cde 319ba2b 4ae5b8c f7fda42 f738cde f7fda42 e068f76 319ba2b f738cde f7fda42 f738cde 319ba2b 6f2d058 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
FROM python:3.9-slim
# Set environment variables
ENV FLASK_APP=app.py
ENV FLASK_ENV=production
ENV PATH="/home/appuser/.local/bin:$PATH"
# Install system dependencies for OpenCV and other requirements
RUN apt-get update && apt-get install -y \
libgl1-mesa-glx \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
tesseract-ocr \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -m appuser && mkdir -p /app /app/instance && chown -R appuser:appuser /app
# Set the working directory
WORKDIR /app
# Copy requirements and install dependencies
COPY --chown=appuser:appuser requirements.txt .
RUN pip install --no-cache-dir "numpy<2.0.0" && \
pip install --no-cache-dir -r requirements.txt
# Copy the application code
COPY --chown=appuser:appuser . .
# Switch to non-root user
USER appuser
# Expose the port
EXPOSE 5000
# Run the application using gunicorn with config file
CMD ["gunicorn", "--config=./gunicorn.conf.py", "--workers=2", "app:create_app()"] |