Skip to content

Commit

Permalink
Use direct entrypoint instead of tmp script mount (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertjndw authored Dec 5, 2023
1 parent 71a1784 commit 114c6f6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 39 deletions.
16 changes: 1 addition & 15 deletions HadesScheduler/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package docker
import (
"context"
"fmt"
"os"
"time"

"github.com/Mtze/HadesCI/shared/payload"
Expand Down Expand Up @@ -107,21 +106,8 @@ func executeStep(ctx context.Context, client *client.Client, step payload.Step,

// Create the bash script if there is one
if step.Script != "" {
scriptPath, err := writeBashScriptToFile(step.Script)
if err != nil {
log.WithError(err).Error("Failed to write bash script to a temporary file")
return err
}
defer os.Remove(scriptPath)

host_config.Mounts = append(host_config.Mounts, mount.Mount{
Type: mount.TypeBind,
Source: scriptPath,
Target: "/tmp/script.sh",
})

// Overwrite the default entrypoint
container_config.Entrypoint = []string{"/bin/bash", "/tmp/script.sh"}
container_config.Entrypoint = []string{"/bin/bash", "-c", step.Script}
}

resp, err := client.ContainerCreate(ctx, &container_config, &host_config, nil, nil, "")
Expand Down
24 changes: 0 additions & 24 deletions HadesScheduler/docker/utils.go

This file was deleted.

0 comments on commit 114c6f6

Please sign in to comment.