# Use a specific Python version as the base image FROM python:3.9 # Create a user with a specific UID and switch to that user RUN useradd -m -u 1000 user USER user # Set the PATH environment variable ENV PATH="/home/user/.local/bin:$PATH" # Set the working directory WORKDIR /app # Copy and install dependencies COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade pip setuptools \ && pip install --no-cache-dir --upgrade -r requirements.txt # Copy the rest of the application code COPY --chown=user . /app # Define the command to run the Flask application CMD ["flask", "run", "--host=0.0.0.0", "--port=7860"] # Optional: Expose the port (not required but good practice) EXPOSE 7860 # Add a HEALTHCHECK to monitor the server's status HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:7860/health || exit 1