Skip to content

Commit e19376f

Browse files
python debugging examples
1 parent e66d185 commit e19376f

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

.vscode/launch.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@
3232
"args": [],
3333
"trace" : "verbose",
3434
"env" : {}
35-
}
35+
},
36+
{
37+
"name": "Python Attach",
38+
"type": "python",
39+
"request": "attach",
40+
"pathMappings": [
41+
{
42+
"localRoot": "${workspaceFolder}/python/src/",
43+
"remoteRoot": "/work"
44+
}
45+
],
46+
"port": 5678,
47+
"host": "127.0.0.1"
48+
},
49+
3650
]
3751
}

docker-compose.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ services:
4444
image: aimvector/python:1.0.0
4545
build:
4646
context: ./python
47-
target: prod
47+
target: debug
4848
#working_dir: /work #comment out for build.target:prod
4949
#entrypoint: /bin/sh #comment out for build.target:prod
5050
#stdin_open: true #comment out for build.target:prod
@@ -53,3 +53,4 @@ services:
5353
- ./python/src/:/work
5454
ports:
5555
- 5003:5000
56+
- 5678:5678

python/dockerfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.7.3-alpine3.9 as dev
1+
FROM python:3.7.3-alpine3.9 as base
22

33
RUN mkdir /work/
44
WORKDIR /work/
@@ -7,15 +7,16 @@ COPY ./src/requirements.txt /work/requirements.txt
77
RUN pip install -r requirements.txt
88

99
COPY ./src/ /work/
10+
ENV FLASK_APP=server.py
1011

11-
###########START NEW IMAGE###################
12+
###########START NEW IMAGE : DEBUGGER ###################
13+
FROM base as debug
14+
RUN pip install ptvsd
1215

13-
FROM python:3.7.3-alpine3.9 as prod
16+
WORKDIR /work/
17+
CMD python -m ptvsd --host 0.0.0.0 --port 5678 --wait --multiprocess -m flask run -h 0.0.0 -p 5000
1418

15-
RUN mkdir /app/
16-
WORKDIR /app/
19+
###########START NEW IMAGE: PRODUCTION ###################
20+
FROM base as prod
1721

18-
COPY --from=dev /work/ /app/
19-
RUN pip install -r requirements.txt
20-
ENV FLASK_APP=server.py
2122
CMD flask run -h 0.0.0 -p 5000

0 commit comments

Comments
 (0)