Skip to content

Commit 4598715

Browse files
committed
Improve code
1 parent 00fdecb commit 4598715

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/checktypes/code.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,17 @@ func (c Code) Build(debug bool, logger log.Logger) (string, error) {
6060
return "", err
6161
}
6262
dockerfile := "Dockerfile"
63+
64+
// In case of debug, we need to add the delve debugger to the image.
65+
// We create a new Dockerfile with the necessary changes.
66+
// The original Dockerfile is kept in the dir but excluded from the Tar file.
67+
// The new Dockerfile is removed after the image is built.
6368
if debug {
6469
b, err := os.ReadFile(path.Join(dir, "Dockerfile"))
6570
if err != nil {
6671
return "", err
6772
}
68-
dockerfile = "Dockerfile.local"
73+
dockerfile = "Dockerfile.debug"
6974
add := fmt.Sprintf(`
7075
RUN apk add --no-cache go
7176
RUN go install github.com/go-delve/delve/cmd/dlv@latest
@@ -82,7 +87,7 @@ func (c Code) Build(debug bool, logger log.Logger) (string, error) {
8287
defer func() {
8388
if dockerfile != "Dockerfile" {
8489
if err := os.Remove(path.Join(dir, dockerfile)); err != nil {
85-
logger.Errorf("error removing Dockerfile.vulcan-local: %v", err)
90+
logger.Errorf("error removing %s: %v", dockerfile, err)
8691
}
8792
}
8893
}()

0 commit comments

Comments
 (0)