Skip to content

Commit 16ce8dd

Browse files
authored
Support linux/arm64 and linux/amd64 (#64)
* Use `docker buildx` to build for linux/arm64 and linux/amd64 * Update Travis to use bionic and use newer docker * Update dotnet builder image to dotnet/runtime:6.0 for linux/arm64 (no difference in * Add test for Go 1.16
1 parent f005fa3 commit 16ce8dd

20 files changed

+361
-80
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
sudo: false
2+
dist: bionic
3+
lang: bash
24
services:
35
- docker
46

7+
before_install:
8+
- sh hack/enable-docker-buildkit.sh
9+
- docker info
10+
511
install:
612
- mkdir -p $HOME/bin
713
- curl -Lo $HOME/bin/skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64

go/Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
FROM golang:1.15 as delve
1+
ARG GOVERSION=1.16
2+
FROM --platform=$BUILDPLATFORM golang:${GOVERSION} as delve
3+
ARG BUILDPLATFORM
4+
ARG TARGETOS
5+
ARG TARGETARCH
26

37
ARG DELVE_VERSION=1.6.0
48

@@ -15,11 +19,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1519
&& patch -p0 -d delve-source < delve-only-same-user.patch
1620

1721
# Produce an as-static-as-possible dlv binary to work on musl and glibc
18-
RUN cd delve-source && CGO_ENABLED=0 go build -o /go/dlv -ldflags '-s -w -extldflags "-static"' ./cmd/dlv/
22+
RUN cd delve-source && CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /go/dlv -ldflags '-s -w -extldflags "-static"' ./cmd/dlv/
1923

2024
# Now populate the duct-tape image with the language runtime debugging support files
2125
# The debian image is about 95MB bigger
22-
FROM busybox
26+
FROM --platform=$BUILDPLATFORM busybox
2327
# The install script copies all files in /duct-tape to /dbg
2428
COPY install.sh /
2529
CMD ["/bin/sh", "/install.sh"]

hack/enable-docker-buildkit.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/sh
2+
# https://www.docker.com/blog/multi-arch-build-what-about-travis/
3+
4+
echo ">> enabling experimental mode"
5+
if [ -f /etc/docker/daemon.json ]; then
6+
echo "/etc/docker/daemon.json was:"
7+
sed 's/^/> /' /etc/docker/daemon.json
8+
echo "/etc/docker/daemon.json now:"
9+
jq '.+{"experimental":true}' /etc/docker/daemon.json | sudo tee /etc/docker/daemon.json
10+
else
11+
sudo mkdir -vp /etc/docker
12+
echo "/etc/docker/daemon.json now:"
13+
echo '{"experimental":true}' | sudo tee /etc/docker/daemon.json
14+
fi
15+
16+
if [ -f $HOME/.docker/config.json ]; then
17+
echo "$HOME/.docker/config.json was:"
18+
sed 's/^/> /' $HOME/.docker/config.json
19+
echo "$HOME/.docker/config.json now:"
20+
jq '.+{"experimental":"enabled"}' /etc/docker/daemon.json | tee $HOME/.docker/config.json
21+
else
22+
mkdir -vp $HOME/.docker
23+
echo "$HOME/.docker/config.json now:"
24+
echo '{"experimental":"enabled"}' | tee $HOME/.docker/config.json
25+
fi
26+
27+
echo ">> updating docker engine"
28+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
29+
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
30+
sudo apt-get update
31+
sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
32+
33+
echo ">> installing docker-buildx"
34+
mkdir -vp $HOME/.docker/cli-plugins/
35+
curl --silent -L "https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-amd64" > $HOME/.docker/cli-plugins/docker-buildx
36+
chmod a+x $HOME/.docker/cli-plugins/docker-buildx

integration/goapp/Dockerfile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
ARG GOVERSION=1.14
2-
FROM golang:${GOVERSION} as builder
1+
ARG GOVERSION
2+
FROM --platform=$BUILDPLATFORM golang:$GOVERSION as builder
3+
ARG BUILDPLATFORM
4+
ARG TARGETOS
5+
ARG TARGETARCH
6+
37
COPY main.go .
4-
RUN go build -gcflags="all=-N -l" -o /app main.go
8+
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -gcflags="all=-N -l" -o /app main.go
59

6-
FROM gcr.io/distroless/base
10+
FROM --platform=$BUILDPLATFORM gcr.io/distroless/base
711
CMD ["./app"]
812
ENV GOTRACEBACK=single
913
COPY --from=builder /app .

integration/goapp/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"log"
66
"net/http"
7+
"runtime"
78
)
89

910
func main() {
@@ -14,5 +15,5 @@ func main() {
1415
}
1516

1617
func hello(w http.ResponseWriter, r *http.Request) {
17-
fmt.Fprintf(w, "Hello, World!")
18+
fmt.Fprintf(w, "Hello from %s/%s!\n", runtime.GOOS, runtime.GOARCH)
1819
}

integration/k8s-rbac.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Simple RBAC required to enable use of `kubectl port-forward`
2-
# from within a contaier.
2+
# from within a container.
33
apiVersion: rbac.authorization.k8s.io/v1beta1
44
kind: ClusterRoleBinding
55
metadata:

integration/k8s-test-go113.yaml

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
# This test approximates `skaffold debug` for a go app.
12
apiVersion: v1
23
kind: Pod
34
metadata:
45
name: go113pod
6+
labels:
7+
app: hello
8+
protocol: dlv
9+
runtime: go113
510
spec:
611
containers:
712
- name: go113app
@@ -13,7 +18,8 @@ spec:
1318
- --headless
1419
- --continue
1520
- --accept-multiclient
16-
- --listen=localhost:56286
21+
# listen on 0.0.0.0 as it is exposed as a service
22+
- --listen=0.0.0.0:56286
1723
- --api-version=2
1824
- ./app
1925
ports:
@@ -38,6 +44,24 @@ spec:
3844
- emptyDir: {}
3945
name: go-debugging-support
4046

47+
---
48+
apiVersion: v1
49+
kind: Service
50+
metadata:
51+
name: hello-dlv-go113
52+
spec:
53+
ports:
54+
- name: http
55+
port: 8080
56+
protocol: TCP
57+
- name: dlv
58+
port: 56286
59+
protocol: TCP
60+
selector:
61+
app: hello
62+
protocol: dlv
63+
runtime: go113
64+
4165
---
4266
apiVersion: batch/v1
4367
kind: Job
@@ -52,27 +76,16 @@ spec:
5276
template:
5377
spec:
5478
restartPolicy: Never
55-
volumes:
56-
- name: kubectl
57-
emptyDir: {}
5879
initContainers:
59-
- name: copy-kubectl
60-
image: bitnami/kubectl
61-
command: [sh, -c, 'cp -p /opt/bitnami/kubectl/bin/kubectl /kubectl/kubectl']
62-
volumeMounts:
63-
- mountPath: /kubectl
64-
name: kubectl
80+
- name: wait-for-go113pod
81+
image: kubectl
82+
command: [sh, -c, "while ! curl -s hello-dlv-go113:8080 2>/dev/null; do echo waiting for app; sleep 1; done"]
6583
containers:
6684
- name: dlv-to-go113
6785
image: skaffold-debug-go
68-
command: [sh, -c, 'sleep 5;
69-
/kubectl/kubectl port-forward pod/go113pod 56286:56286 &
70-
sleep 2;
86+
command: [sh, -c, '
7187
(echo bt; echo exit -c) > init.txt;
7288
set -x;
73-
/duct-tape/go/bin/dlv connect --init init.txt localhost:56286']
74-
volumeMounts:
75-
- mountPath: /kubectl
76-
name: kubectl
89+
/duct-tape/go/bin/dlv connect --init init.txt hello-dlv-go113:56286']
7790

7891

integration/k8s-test-go114.yaml

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
# This test approximates `skaffold debug` for a go app.
12
apiVersion: v1
23
kind: Pod
34
metadata:
45
name: go114pod
6+
labels:
7+
app: hello
8+
protocol: dlv
9+
runtime: go114
510
spec:
611
containers:
712
- name: go114app
@@ -13,7 +18,8 @@ spec:
1318
- --headless
1419
- --continue
1520
- --accept-multiclient
16-
- --listen=localhost:56286
21+
# listen on 0.0.0.0 as it is exposed as a service
22+
- --listen=0.0.0.0:56286
1723
- --api-version=2
1824
- ./app
1925
ports:
@@ -38,6 +44,24 @@ spec:
3844
- emptyDir: {}
3945
name: go-debugging-support
4046

47+
---
48+
apiVersion: v1
49+
kind: Service
50+
metadata:
51+
name: hello-dlv-go114
52+
spec:
53+
ports:
54+
- name: http
55+
port: 8080
56+
protocol: TCP
57+
- name: dlv
58+
port: 56286
59+
protocol: TCP
60+
selector:
61+
app: hello
62+
protocol: dlv
63+
runtime: go114
64+
4165
---
4266
apiVersion: batch/v1
4367
kind: Job
@@ -52,27 +76,16 @@ spec:
5276
template:
5377
spec:
5478
restartPolicy: Never
55-
volumes:
56-
- name: kubectl
57-
emptyDir: {}
5879
initContainers:
59-
- name: copy-kubectl
60-
image: bitnami/kubectl
61-
command: [sh, -c, 'cp -p /opt/bitnami/kubectl/bin/kubectl /kubectl/kubectl']
62-
volumeMounts:
63-
- mountPath: /kubectl
64-
name: kubectl
80+
- name: wait-for-go114pod
81+
image: kubectl
82+
command: [sh, -c, "while ! curl -s hello-dlv-go114:8080 2>/dev/null; do echo waiting for app; sleep 1; done"]
6583
containers:
6684
- name: dlv-to-go114
6785
image: skaffold-debug-go
68-
command: [sh, -c, 'sleep 5;
69-
/kubectl/kubectl port-forward pod/go114pod 56286:56286 &
70-
sleep 2;
86+
command: [sh, -c, '
7187
(echo bt; echo exit -c) > init.txt;
7288
set -x;
73-
/duct-tape/go/bin/dlv connect --init init.txt localhost:56286']
74-
volumeMounts:
75-
- mountPath: /kubectl
76-
name: kubectl
89+
/duct-tape/go/bin/dlv connect --init init.txt hello-dlv-go114:56286']
7790

7891

integration/k8s-test-go115.yaml

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
# This test approximates `skaffold debug` for a go app.
12
apiVersion: v1
23
kind: Pod
34
metadata:
45
name: go115pod
6+
labels:
7+
app: hello
8+
protocol: dlv
9+
runtime: go115
510
spec:
611
containers:
712
- name: go115app
@@ -13,7 +18,8 @@ spec:
1318
- --headless
1419
- --continue
1520
- --accept-multiclient
16-
- --listen=localhost:56286
21+
# listen on 0.0.0.0 as it is exposed as a service
22+
- --listen=0.0.0.0:56286
1723
- --api-version=2
1824
- ./app
1925
ports:
@@ -38,6 +44,24 @@ spec:
3844
- emptyDir: {}
3945
name: go-debugging-support
4046

47+
---
48+
apiVersion: v1
49+
kind: Service
50+
metadata:
51+
name: hello-dlv-go115
52+
spec:
53+
ports:
54+
- name: http
55+
port: 8080
56+
protocol: TCP
57+
- name: dlv
58+
port: 56286
59+
protocol: TCP
60+
selector:
61+
app: hello
62+
protocol: dlv
63+
runtime: go115
64+
4165
---
4266
apiVersion: batch/v1
4367
kind: Job
@@ -52,27 +76,16 @@ spec:
5276
template:
5377
spec:
5478
restartPolicy: Never
55-
volumes:
56-
- name: kubectl
57-
emptyDir: {}
5879
initContainers:
59-
- name: copy-kubectl
60-
image: bitnami/kubectl
61-
command: [sh, -c, 'cp -p /opt/bitnami/kubectl/bin/kubectl /kubectl/kubectl']
62-
volumeMounts:
63-
- mountPath: /kubectl
64-
name: kubectl
80+
- name: wait-for-go115pod
81+
image: kubectl
82+
command: [sh, -c, "while ! curl -s hello-dlv-go115:8080 2>/dev/null; do echo waiting for app; sleep 1; done"]
6583
containers:
6684
- name: dlv-to-go115
6785
image: skaffold-debug-go
68-
command: [sh, -c, 'sleep 5;
69-
/kubectl/kubectl port-forward pod/go115pod 56286:56286 &
70-
sleep 2;
86+
command: [sh, -c, '
7187
(echo bt; echo exit -c) > init.txt;
7288
set -x;
73-
/duct-tape/go/bin/dlv connect --init init.txt localhost:56286']
74-
volumeMounts:
75-
- mountPath: /kubectl
76-
name: kubectl
89+
/duct-tape/go/bin/dlv connect --init init.txt hello-dlv-go115:56286']
7790

7891

0 commit comments

Comments
 (0)