Business-card-OCR / Dockerfile
Umama-at-Bluchip's picture
Update Dockerfile
70c2cef verified
# Use official Python image
FROM python:3.9
# Unbuffered output
ENV PYTHONUNBUFFERED=1
# Install necessary system dependencies
RUN apt-get update && apt-get install -y \
tesseract-ocr \
tesseract-ocr-eng \
libtesseract-dev \
libleptonica-dev \
pkg-config \
poppler-utils \
&& rm -rf /var/lib/apt/lists/*
# Set the working directory in the container
WORKDIR /code
# Copy requirements.txt to the container
COPY ./requirements.txt /code/requirements.txt
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
ENV PATH="/usr/local/bin:${PATH}"
# Create a non-root user
RUN useradd -m -u 1000 user
USER user
# Set the home and path environment for the new user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Change to app directory under the new user
WORKDIR $HOME/app
# Copy app code to the container and set ownership to the user
COPY --chown=user . $HOME/app
# Command to run the Flask app via Gunicorn on port 7860
CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"]