Skip to content

Commit 583c7b8

Browse files
authored
Add support for ptvsd, a debug adapter for Python (#21)
* Use pip to install ptvsd * Add structure tests
1 parent a79323f commit 583c7b8

8 files changed

Lines changed: 43 additions & 45 deletions

File tree

skaffold-duct-tape/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ are packaged into an image container suitable for use as an
88
`initContainer` on a pod.
99

1010
Currently supported:
11-
* None!
11+
* Go: provides [Delve](https://github.com/go-delve/delve)
12+
* Python: provides [`ptvsd`](https://github.com/Microsoft/ptvsd),
13+
a debug adapter that can be used for VS Code and more
1214

13-
In Progress:
14-
15-
* Go: provides Delve
1615

1716
## Development
1817

skaffold-duct-tape/duct-tape/Dockerfile

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@ RUN curl --location --output delve-1.2.0.tar.gz https://github.com/go-delve/delv
33
&& tar xzf delve-1.2.0.tar.gz
44
RUN cd delve-1.2.0/cmd/dlv && go install
55

6-
#
7-
#FROM python:2.7 as python27
8-
#RUN curl --location --output ptsvd.zip https://github.com/Microsoft/ptvsd/archive/v4.2.4.zip \
9-
# && unzip ptsvd.zip \
10-
# && cd ptsvd-4.2.4 \
11-
# &&
6+
FROM python:2.7 as python27
7+
RUN PYTHONUSERBASE=/ptvsd pip install --user ptvsd
128

9+
FROM python:3.7 as python37
10+
RUN PYTHONUSERBASE=/ptvsd pip install --user ptvsd
11+
12+
# Now populate the duct-tape image with the language runtime debugging support files
1313
# The debian image is about 95MB bigger
14-
FROM gcr.io/distroless/base:debug
15-
SHELL ["/busybox/sh","-c"]
16-
WORKDIR /duct-tape
17-
COPY --from=delve /go/bin/dlv .
14+
FROM busybox
15+
# The install script copies all files in /duct-tape to /dbg
1816
COPY install.sh /
19-
ENTRYPOINT ["/busybox/sh", "/install.sh"]
17+
CMD ["/bin/sh", "/install.sh"]
18+
WORKDIR /duct-tape
19+
COPY --from=delve /go/bin/dlv go/bin/
20+
COPY --from=python27 /ptvsd/ python/
21+
COPY --from=python37 /ptvsd/ python/
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#!/bin/sh
2-
32
set -e
4-
echo "This is the duct-tape installation script!"
53

64
if [ ! -d /dbg ]; then
7-
echo "Debugging installation requires a volume mount at /dbg" 1>&2
5+
echo "Error: installation requires a volume mount at /dbg" 1>&2
86
exit 1
97
fi
108

11-
# Install Delve for Go
12-
cp -p /duct-tape/dlv /dbg
9+
echo "Installing runtime debugging support files in /dbg"
10+
tar cf - -C /duct-tape . | tar xf - -C /dbg
11+
echo "Installation complete"

skaffold-duct-tape/k8s-pod.yaml.orig

Lines changed: 0 additions & 14 deletions
This file was deleted.

skaffold-duct-tape/skaffold.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ build:
44
artifacts:
55
- image: gcr.io/gcp-dev-tools/duct-tape
66
context: duct-tape
7+
8+
# simple image that lists the contents of / and /dbg
9+
- image: test-image
10+
context: test/test-image
11+
test:
12+
- image: gcr.io/gcp-dev-tools/duct-tape
13+
structureTests:
14+
- ./test/duct-tape-structure-tests.yaml
715
deploy:
816
kubectl:
917
manifests:
10-
- k8s-*
18+
- test/k8s-test-installation.yaml
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
schemaVersion: 2.0.0
2+
3+
fileExistenceTests:
4+
- name: 'dlv'
5+
path: '/duct-tape/go/bin/dlv'
6+
shouldExist: true
7+
- name: 'ptvsd for python 2.7'
8+
path: '/duct-tape/python/lib/python2.7/site-packages/ptvsd/__init__.py'
9+
- name: 'ptvsd for python 3.7'
10+
path: '/duct-tape/python/lib/python3.7/site-packages/ptvsd/__init__.py'

skaffold-duct-tape/k8s-pod.yaml renamed to skaffold-duct-tape/test/k8s-test-installation.yaml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,8 @@ spec:
1212
- name: dbg
1313
mountPath: "/dbg"
1414
containers:
15-
- name: helloworld1
16-
image: busybox
17-
command: ['sh', '-c', 'echo "The app is running"; ls / /dbg; sleep 3600']
18-
volumeMounts:
19-
- name: dbg
20-
mountPath: "/dbg"
21-
readOnly: true
22-
- name: helloworld2
23-
image: busybox
24-
command: ['sh', '-c', 'echo "The app is running"; ls / /dbg; sleep 3600']
15+
- name: test-image
16+
image: test-image
2517
volumeMounts:
2618
- name: dbg
2719
mountPath: "/dbg"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM busybox
2+
CMD echo ">> root: /"; ls /; echo ">> /dbg"; ls /dbg; echo ">> sleeping for 10s"; sleep 10

0 commit comments

Comments
 (0)