Skip to content

Commit 4aea4a1

Browse files
Sebbo92dchaykin
authored andcommitted
Creating a docker image
1 parent 2e4dbda commit 4aea4a1

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ ENV GOROOT=/usr/local/go
55
ENV GOPATH=${HOME}/go
66
ENV PATH=$PATH:${GOROOT}/bin
77

8-
EXPOSE 30123
9-
EXPOSE 8090
8+
RUN apk update && apk add --no-cache \
9+
git && \
10+
go get github.com/go-delve/delve/cmd/dlv
1011

1112
WORKDIR /go/src/github.com/setlog/debug-k8s
12-
13-
RUN apk update && apk add git && \
14-
go get github.com/go-delve/delve/cmd/dlv
13+
EXPOSE 30123 8090
1514

1615
ENTRYPOINT ["/go/bin/dlv", "debug", ".", "--listen=:30123", "--accept-multiclient", "--headless=true", "--api-version=2"]

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,47 +122,48 @@ kubectl label nodes local-debug-k8s-worker debug=true
122122

123123
### Creating a docker image
124124

125-
Our service has only one `/hello` endpoint and writes just a few logs. The interesting part is in the Dockerfile:
125+
Our service has only one endpoint `/hello` and writes just a few logs. Let's checkout the Dockerfile for delve:
126126

127127
```Dockerfile
128128
FROM golang:1.13-alpine
129129

130130
# compile gcc statically
131131
ENV CGO_ENABLED=0
132132
ENV GOROOT=/usr/local/go
133-
# this path will be mounted in deploy-service.yaml later
133+
# this path will be mounted in deploy-service.yaml
134134
ENV GOPATH=${HOME}/go
135135
ENV PATH=$PATH:${GOROOT}/bin
136136

137-
EXPOSE 30123 # for delve
138-
EXPOSE 8090 # for API calls
137+
# Install git and get the latest version of delve via go
138+
RUN apk update && apk add --no-cache \
139+
git && \
140+
go get github.com/go-delve/delve/cmd/dlv
139141

140142
# ATTENTION: you want to check, if the path to the project folder is the right one here
141143
WORKDIR /go/src/github.com/setlog/debug-k8s
142144

143-
# Install delve, our version is 1.4.1
144-
RUN apk update && apk add git && \
145-
go get github.com/go-delve/delve/cmd/dlv
145+
# 30123 for delve and 8090 for API calls
146+
EXPOSE 30123 8090
146147

147-
# let start delve at the entrypoint
148+
# let's start delve as the entrypoint
148149
ENTRYPOINT ["/go/bin/dlv", "debug", ".", "--listen=:30123", "--accept-multiclient", "--headless=true", "--api-version=2"]
149150
```
150151

151-
First, build the docker image locally:
152+
So, let's build build our docker image from our [Dockerfile](Dockerfile):
152153

153154
```sh
154-
docker build -t setlog/debug-k8s .
155+
docker build -t setlog/debug-k8s ./Dockerfile
155156
```
156157

157-
Load the docker image into the node _local-debug-k8s-worker_:
158+
After the build is done, we load the image `setlog/debug-k8s:latest` on the node _local-debug-k8s-worker_:
158159

159160
```sh
160161
kind load docker-image setlog/debug-k8s:latest --name=local-debug-k8s --nodes=local-debug-k8s-worker
161162
```
162163

163-
This message will be shown, and it is just saying that the image was not there:
164+
A message appears indicating that the docker image did not exist before:
164165

165-
```
166+
```sh
166167
Image: "setlog/debug-k8s:latest" with ID "sha256:944baa03d49698b9ca1f22e1ce87b801a20ce5aa52ccfc648a6c82cf8708a783" not present on node "local-debug-k8s-worker"
167168
```
168169

0 commit comments

Comments
 (0)