python debugging examples

This commit is contained in:
marcel-dempers 2019-09-30 20:39:46 +10:00
parent e66d185444
commit e19376f909
3 changed files with 29 additions and 13 deletions

16
.vscode/launch.json vendored
View File

@ -32,6 +32,20 @@
"args": [],
"trace" : "verbose",
"env" : {}
}
},
{
"name": "Python Attach",
"type": "python",
"request": "attach",
"pathMappings": [
{
"localRoot": "${workspaceFolder}/python/src/",
"remoteRoot": "/work"
}
],
"port": 5678,
"host": "127.0.0.1"
},
]
}

View File

@ -44,7 +44,7 @@ services:
image: aimvector/python:1.0.0
build:
context: ./python
target: prod
target: debug
#working_dir: /work #comment out for build.target:prod
#entrypoint: /bin/sh #comment out for build.target:prod
#stdin_open: true #comment out for build.target:prod
@ -53,3 +53,4 @@ services:
- ./python/src/:/work
ports:
- 5003:5000
- 5678:5678

View File

@ -1,4 +1,4 @@
FROM python:3.7.3-alpine3.9 as dev
FROM python:3.7.3-alpine3.9 as base
RUN mkdir /work/
WORKDIR /work/
@ -7,15 +7,16 @@ COPY ./src/requirements.txt /work/requirements.txt
RUN pip install -r requirements.txt
COPY ./src/ /work/
###########START NEW IMAGE###################
FROM python:3.7.3-alpine3.9 as prod
RUN mkdir /app/
WORKDIR /app/
COPY --from=dev /work/ /app/
RUN pip install -r requirements.txt
ENV FLASK_APP=server.py
###########START NEW IMAGE : DEBUGGER ###################
FROM base as debug
RUN pip install ptvsd
WORKDIR /work/
CMD python -m ptvsd --host 0.0.0.0 --port 5678 --wait --multiprocess -m flask run -h 0.0.0 -p 5000
###########START NEW IMAGE: PRODUCTION ###################
FROM base as prod
CMD flask run -h 0.0.0 -p 5000