From a79d81989f66d9669400d859bd7c7a0d1a8dc60d Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 27 Mar 2024 10:17:48 +0000 Subject: [PATCH] Pass 'sleep' as container command rather than entrypoint (#86) The current code overrides the container's entrypoint with `sleep`. Unfortunately, that prevents initialization scripts, such as to initialize Docker-in-Docker, from running. The change simply moves the `sleep` to the command, rather than entrypoint, directive. For most containers of this sort, the entrypoint script performs initialization, and then ends with `$@` to execute whatever command is passed. If the container has no entrypoint, the command is executed directly. As a result, this should be a transparent change for most use cases, while allowing the container's entrypoint to be used when present. Reviewed-on: https://gitea.com/gitea/act/pulls/86 Reviewed-by: Jason Song Co-authored-by: Thomas E Lackey Co-committed-by: Thomas E Lackey --- pkg/runner/run_context.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go index f3e3ff7..307b35c 100644 --- a/pkg/runner/run_context.go +++ b/pkg/runner/run_context.go @@ -410,8 +410,8 @@ func (rc *RunContext) startJobContainer() common.Executor { jobContainerNetwork = networkName rc.JobContainer = container.NewContainer(&container.NewContainerInput{ - Cmd: nil, - Entrypoint: []string{"/bin/sleep", fmt.Sprint(rc.Config.ContainerMaxLifetime.Round(time.Second).Seconds())}, + Cmd: []string{"/bin/sleep", fmt.Sprint(rc.Config.ContainerMaxLifetime.Round(time.Second).Seconds())}, + Entrypoint: nil, WorkingDir: ext.ToContainerPath(rc.Config.Workdir), Image: image, Username: username,