From ddb45c943bfd6e5902970264d594117af7864571 Mon Sep 17 00:00:00 2001 From: "Ryan (hackercat)" Date: Sun, 23 May 2021 14:43:09 +0000 Subject: [PATCH] feat: add option for custom socket path (#698) --- act/runner/run_context.go | 6 +++++- act/runner/runner.go | 1 + cmd/input.go | 1 + cmd/root.go | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/act/runner/run_context.go b/act/runner/run_context.go index 5dbee29d..fb0d4410 100755 --- a/act/runner/run_context.go +++ b/act/runner/run_context.go @@ -67,8 +67,12 @@ func (rc *RunContext) jobContainerName() string { func (rc *RunContext) GetBindsAndMounts() ([]string, map[string]string) { name := rc.jobContainerName() + if rc.Config.ContainerDaemonSocket == "" { + rc.Config.ContainerDaemonSocket = "/var/run/docker.sock" + } + binds := []string{ - fmt.Sprintf("%s:%s", "/var/run/docker.sock", "/var/run/docker.sock"), + fmt.Sprintf("%s:%s", rc.Config.ContainerDaemonSocket, "/var/run/docker.sock"), } mounts := map[string]string{ diff --git a/act/runner/runner.go b/act/runner/runner.go index 11bbb678..9d8b6f9e 100644 --- a/act/runner/runner.go +++ b/act/runner/runner.go @@ -37,6 +37,7 @@ type Config struct { Privileged bool // use privileged mode UsernsMode string // user namespace to use ContainerArchitecture string // Desired OS/architecture platform for running containers + ContainerDaemonSocket string // Path to Docker daemon socket UseGitIgnore bool // controls if paths in .gitignore should not be copied into container, default true GitHubInstance string // GitHub instance to use, default "github.com" } diff --git a/cmd/input.go b/cmd/input.go index 17bff934..3a910149 100644 --- a/cmd/input.go +++ b/cmd/input.go @@ -28,6 +28,7 @@ type Input struct { privileged bool usernsMode string containerArchitecture string + containerDaemonSocket string noWorkflowRecurse bool useGitIgnore bool githubInstance string diff --git a/cmd/root.go b/cmd/root.go index c3ab1f36..05dbd72d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -61,6 +61,7 @@ func Execute(ctx context.Context, version string) { rootCmd.PersistentFlags().BoolVarP(&input.insecureSecrets, "insecure-secrets", "", false, "NOT RECOMMENDED! Doesn't hide secrets while printing logs.") rootCmd.PersistentFlags().StringVarP(&input.envfile, "env-file", "", ".env", "environment file to read and use as env in the containers") rootCmd.PersistentFlags().StringVarP(&input.containerArchitecture, "container-architecture", "", "", "Architecture which should be used to run containers, e.g.: linux/amd64. If not specified, will use host default architecture. Requires Docker server API Version 1.41+. Ignored on earlier Docker server platforms.") + rootCmd.PersistentFlags().StringVarP(&input.containerDaemonSocket, "container-daemon-socket", "", "/var/run/docker.sock", "Path to Docker daemon socket which will be mounted to containers") rootCmd.PersistentFlags().StringVarP(&input.githubInstance, "github-instance", "", "github.com", "GitHub instance to use. Don't use this if you are not using GitHub Enterprise Server.") rootCmd.SetArgs(args()) @@ -255,6 +256,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str Privileged: input.privileged, UsernsMode: input.usernsMode, ContainerArchitecture: input.containerArchitecture, + ContainerDaemonSocket: input.containerDaemonSocket, UseGitIgnore: input.useGitIgnore, GitHubInstance: input.githubInstance, }