Skip to content

Commit

Permalink
python debugging examples
Browse files Browse the repository at this point in the history
  • Loading branch information
marcel-dempers committed Sep 30, 2019
1 parent e66d185 commit e19376f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
16 changes: 15 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},

]
}
3 changes: 2 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -53,3 +53,4 @@ services:
- ./python/src/:/work
ports:
- 5003:5000
- 5678:5678
17 changes: 9 additions & 8 deletions python/dockerfile
Original file line number Diff line number Diff line change
@@ -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/
Expand All @@ -7,15 +7,16 @@ COPY ./src/requirements.txt /work/requirements.txt
RUN pip install -r requirements.txt

COPY ./src/ /work/
ENV FLASK_APP=server.py

###########START NEW IMAGE###################
###########START NEW IMAGE : DEBUGGER ###################
FROM base as debug
RUN pip install ptvsd

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

RUN mkdir /app/
WORKDIR /app/
###########START NEW IMAGE: PRODUCTION ###################
FROM base as prod

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

0 comments on commit e19376f

Please sign in to comment.