Skip to content

Commit 799098b

Browse files
author
Ryan (hackercat)
authored
feat: add option for custom socket path (#698)
1 parent 764263c commit 799098b

File tree

5 files changed

+39
-29
lines changed

5 files changed

+39
-29
lines changed

README.md

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -131,34 +131,36 @@ It will save that information to `~/.actrc`, please refer to [Configuration](#co
131131
# Flags
132132

133133
```none
134-
-a, --actor string user that triggered the event (default "nektos/act")
135-
-b, --bind bind working directory to container, rather than copy
136-
--container-architecture string 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.
137-
--defaultbranch string the name of the main branch
138-
--detect-event Use first event type from workflow as event that triggered the workflow
139-
-C, --directory string working directory (default ".")
140-
-n, --dryrun dryrun mode
141-
--env stringArray env to make available to actions with optional value (e.g. --env myenv=foo or -s myenv)
142-
--env-file string environment file to read and use as env in the containers (default ".env")
143-
-e, --eventpath string path to event JSON file
144-
--github-instance string GitHub instance to use. Don't use this if you are not using GitHub Enterprise Server. (default "github.com")
145-
-g, --graph draw workflows
146-
-h, --help help for act
147-
--insecure-secrets NOT RECOMMENDED! Doesn't hide secrets while printing logs.
148-
-j, --job string run job
149-
-l, --list list workflows
150-
-P, --platform stringArray custom image to use per platform (e.g. -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04)
151-
--privileged use privileged mode
152-
-p, --pull pull docker image(s) even if already present
153-
-q, --quiet disable logging of output from steps
154-
-r, --reuse reuse action containers to maintain state
155-
-s, --secret stringArray secret to make available to actions with optional value (e.g. -s mysecret=foo or -s mysecret)
156-
--secret-file string file with list of secrets to read from (e.g. --secret-file .secrets) (default ".secrets")
157-
--use-gitignore Controls whether paths specified in .gitignore should be copied into container (default true)
158-
--userns string user namespace to use
159-
-v, --verbose verbose output
160-
-w, --watch watch the contents of the local repo and run when files change
161-
-W, --workflows string path to workflow file(s) (default "./.github/workflows/")
134+
-a, --actor string user that triggered the event (default "nektos/act")
135+
-b, --bind bind working directory to container, rather than copy
136+
--container-architecture string 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.
137+
--container-daemon-socket string Path to Docker daemon socket which will be mounted to containers (default "/var/run/docker.sock")
138+
--defaultbranch string the name of the main branch
139+
--detect-event Use first event type from workflow as event that triggered the workflow
140+
-C, --directory string working directory (default ".")
141+
-n, --dryrun dryrun mode
142+
--env stringArray env to make available to actions with optional value (e.g. --e myenv=foo or -s myenv)
143+
--env-file string environment file to read and use as env in the containers (default ".env")
144+
-e, --eventpath string path to event JSON file
145+
--github-instance string GitHub instance to use. Don't use this if you are not using GitHub Enterprise Server. (default "github.com")
146+
-g, --graph draw workflows
147+
-h, --help help for act
148+
--insecure-secrets NOT RECOMMENDED! Doesn't hide secrets while printing logs.
149+
-j, --job string run job
150+
-l, --list list workflows
151+
--no-recurse Flag to disable running workflows from subdirectories of specified path in '--workflows'/'-W' flag
152+
-P, --platform stringArray custom image to use per platform (e.g. -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04)
153+
--privileged use privileged mode
154+
-p, --pull pull docker image(s) even if already present
155+
-q, --quiet disable logging of output from steps
156+
-r, --reuse reuse action containers to maintain state
157+
-s, --secret stringArray secret to make available to actions with optional value (e.g. -s mysecret=foo or -s mysecret)
158+
--secret-file string file with list of secrets to read from (e.g. --secret-file .secrets) (default ".secrets")
159+
--use-gitignore Controls whether paths specified in .gitignore should be copied into container (default true)
160+
--userns string user namespace to use
161+
-v, --verbose verbose output
162+
-w, --watch watch the contents of the local repo and run when files change
163+
-W, --workflows string path to workflow file(s) (default "./.github/workflows/")
162164
```
163165

164166
In case you want to pass a value for `${{ github.token }}`, you should pass `GITHUB_TOKEN` as secret: `act -s GITHUB_TOKEN=[insert token or leave blank for secure input]`.

cmd/input.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type Input struct {
2828
privileged bool
2929
usernsMode string
3030
containerArchitecture string
31+
containerDaemonSocket string
3132
noWorkflowRecurse bool
3233
useGitIgnore bool
3334
githubInstance string

cmd/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func Execute(ctx context.Context, version string) {
6161
rootCmd.PersistentFlags().BoolVarP(&input.insecureSecrets, "insecure-secrets", "", false, "NOT RECOMMENDED! Doesn't hide secrets while printing logs.")
6262
rootCmd.PersistentFlags().StringVarP(&input.envfile, "env-file", "", ".env", "environment file to read and use as env in the containers")
6363
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.")
64+
rootCmd.PersistentFlags().StringVarP(&input.containerDaemonSocket, "container-daemon-socket", "", "/var/run/docker.sock", "Path to Docker daemon socket which will be mounted to containers")
6465
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.")
6566
rootCmd.SetArgs(args())
6667

@@ -255,6 +256,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
255256
Privileged: input.privileged,
256257
UsernsMode: input.usernsMode,
257258
ContainerArchitecture: input.containerArchitecture,
259+
ContainerDaemonSocket: input.containerDaemonSocket,
258260
UseGitIgnore: input.useGitIgnore,
259261
GitHubInstance: input.githubInstance,
260262
}

pkg/runner/run_context.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ func (rc *RunContext) jobContainerName() string {
6767
func (rc *RunContext) GetBindsAndMounts() ([]string, map[string]string) {
6868
name := rc.jobContainerName()
6969

70+
if rc.Config.ContainerDaemonSocket == "" {
71+
rc.Config.ContainerDaemonSocket = "/var/run/docker.sock"
72+
}
73+
7074
binds := []string{
71-
fmt.Sprintf("%s:%s", "/var/run/docker.sock", "/var/run/docker.sock"),
75+
fmt.Sprintf("%s:%s", rc.Config.ContainerDaemonSocket, "/var/run/docker.sock"),
7276
}
7377

7478
mounts := map[string]string{

pkg/runner/runner.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type Config struct {
3737
Privileged bool // use privileged mode
3838
UsernsMode string // user namespace to use
3939
ContainerArchitecture string // Desired OS/architecture platform for running containers
40+
ContainerDaemonSocket string // Path to Docker daemon socket
4041
UseGitIgnore bool // controls if paths in .gitignore should not be copied into container, default true
4142
GitHubInstance string // GitHub instance to use, default "github.com"
4243
}

0 commit comments

Comments
 (0)