Debug flask docker container with breakpoints

  Kiến thức lập trình

I am building my flask application on ubuntu image,

below is snippet of my dockerfile

FROM ubuntu:24.04

# Install required packages and Python
RUN apt-get update && 
    apt-get install -y python3 python3-pip python3-venv default-libmysqlclient-dev build-essential pkg-config curl && 
    rm -rf /var/lib/apt/lists/*

# Prevents Python from writing pyc files.
ENV PYTHONDONTWRITEBYTECODE=1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

RUN --mount=type=cache,target=/root/.cache/pip 
   --mount=type=bind,source=requirements.txt,target=requirements.txt 
    . ./venv/bin/activate && 
    python3 -m pip install --upgrade pip && 
    pip3 install -r requirements.txt && 
    pip3 install debugpy

COPY . .

# Expose the port that the application listens on.
EXPOSE 5000

# Run the application.
CMD ["./venv/bin/python", "app.py"]

the issue is I want to debug using breakpoints on my APIs, but I am not able to do that, I have tried with multiple methods available on internet, those does not seems to work, please help in solving above issue

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT