So it looks like this is very difficult, if not impossible atm, to do with gunicorn. So what I did was
- Create a
degub_app.py
file in my project with :
from myapp.api import create_app
if __name__=="__main__":
app = create_app()
app.run('0.0.0.0', 8000, debug=False)
- I created a debug container which runs nothing on start it just waiting idle like this in my
docker-compose
file:
api-debug:
image: "myapp:latest"
restart: on-failure:3
environment:
volumes:
- ./:/usr/src/app
depends_on:
- rabbitmq
- redis
- mongo
tty: true
stdin_open: true
command: tail -F anything
ports:
- 8000:8000
- Then using
VSCode
with the Remote Container
pluggin i attached to that container. This starts a new VSCode window and shows you the files inside the container.
Note Since the VSCode is now connected to the container I had to re-install the Python extension (you can look this up but it is easy just go to pluggins and re-install to container)
- I created a
launch.json
inside the container to run the degub_app.py
that I mentioned above like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug API",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}my_path/debug_api.py",
"console": "integratedTerminal",
"justMyCode": false
}
]
}