# Use an official Python runtime as a parent image | |
FROM python:3.8-slim | |
# Set the working directory to /app | |
WORKDIR /app | |
# Copy only the requirements file | |
COPY requirements.txt . | |
# Install dependencies | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy the rest of the code into /app | |
COPY . . | |
# Change working directory to /app/src where app.py is located | |
WORKDIR /app/src | |
# Set environment variables | |
ENV FLASK_APP=app.py | |
ENV FLASK_RUN_HOST=0.0.0.0 | |
# Expose port 5000 | |
EXPOSE 5000 | |
# Run the Flask app | |
CMD ["flask", "run"] |