Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/Runner.Worker/Container/DockerCommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ public async Task<string> DockerCreate(IExecutionContext context, ContainerInfo
{
// Named Docker volume / host bind mount
volumeArg = $"-v \"{volume.SourceVolumePath.Replace("\"", "\\\"")}\":\"{volume.TargetVolumePath.Replace("\"", "\\\"")}\"";
#if OS_WINDOWS
if (!Directory.Exists(volume.SourceVolumePath))
{
Directory.CreateDirectory(volume.SourceVolumePath);
}
#endif
}
if (volume.ReadOnly)
{
Expand Down Expand Up @@ -333,9 +339,9 @@ public async Task<int> DockerExec(IExecutionContext context, string containerId,
}
};

if (!Constants.Runner.Platform.Equals(Constants.OSPlatform.Linux))
if (!(Constants.Runner.Platform.Equals(Constants.OSPlatform.Linux) || (Constants.Runner.Platform.Equals(Constants.OSPlatform.Windows) && Constants.Runner.PlatformArchitecture.Equals(Constants.Architecture.X64))))
{
throw new NotSupportedException("Container operations are only supported on Linux runners");
throw new NotSupportedException("Container operations are only supported on Linux or 64 bit Windows server runners");
}
return await processInvoker.ExecuteAsync(
workingDirectory: HostContext.GetDirectory(WellKnownDirectory.Work),
Expand Down Expand Up @@ -395,9 +401,9 @@ public Task<int> DockerLogin(IExecutionContext context, string configFileDirecto
processInvoker.ErrorDataReceived += stderrDataReceived;


if (!Constants.Runner.Platform.Equals(Constants.OSPlatform.Linux))
if (!(Constants.Runner.Platform.Equals(Constants.OSPlatform.Linux) || (Constants.Runner.Platform.Equals(Constants.OSPlatform.Windows) && Constants.Runner.PlatformArchitecture.Equals(Constants.Architecture.X64))))
{
throw new NotSupportedException("Container operations are only supported on Linux runners");
throw new NotSupportedException("Container operations are only supported on Linux or 64 bit Windows server runners");
}
return await processInvoker.ExecuteAsync(
workingDirectory: context.GetGitHubContext("workspace"),
Expand Down Expand Up @@ -426,9 +432,9 @@ public Task<int> DockerLogin(IExecutionContext context, string configFileDirecto
context.Output(message.Data);
};

if (!Constants.Runner.Platform.Equals(Constants.OSPlatform.Linux))
if (!(Constants.Runner.Platform.Equals(Constants.OSPlatform.Linux) || (Constants.Runner.Platform.Equals(Constants.OSPlatform.Windows) && Constants.Runner.PlatformArchitecture.Equals(Constants.Architecture.X64))))
{
throw new NotSupportedException("Container operations are only supported on Linux runners");
throw new NotSupportedException("Container operations are only supported on Linux or 64 bit Windows server runners");
}
return await processInvoker.ExecuteAsync(
workingDirectory: workingDirectory ?? context.GetGitHubContext("workspace"),
Expand Down
19 changes: 17 additions & 2 deletions src/Runner.Worker/ContainerOperationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public override void Initialize(IHostContext hostContext)
public async Task StartContainersAsync(IExecutionContext executionContext, object data)
{
Trace.Entering();
if (!Constants.Runner.Platform.Equals(Constants.OSPlatform.Linux))
if (!(Constants.Runner.Platform.Equals(Constants.OSPlatform.Linux) || (Constants.Runner.Platform.Equals(Constants.OSPlatform.Windows) && Constants.Runner.PlatformArchitecture.Equals(Constants.Architecture.X64))))
{
throw new NotSupportedException("Container operations are only supported on Linux runners");
throw new NotSupportedException("Container operations are only supported on Linux or 64 bit Windows server runners");
}
ArgUtil.NotNull(executionContext, nameof(executionContext));
List<ContainerInfo> containers = data as List<ContainerInfo>;
Expand Down Expand Up @@ -256,18 +256,33 @@ private async Task StartContainerAsync(IExecutionContext executionContext, Conta

var tempHomeDirectory = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Temp), "_github_home");
Directory.CreateDirectory(tempHomeDirectory);
#if OS_WINDOWS
container.MountVolumes.Add(new MountVolume(tempHomeDirectory, "C:\\ghhome"));
container.AddPathTranslateMapping(tempHomeDirectory, "C:\\ghhome");
#else
container.MountVolumes.Add(new MountVolume(tempHomeDirectory, "/github/home"));
container.AddPathTranslateMapping(tempHomeDirectory, "/github/home");
#endif
container.ContainerEnvironmentVariables["HOME"] = container.TranslateToContainerPath(tempHomeDirectory);

var tempWorkflowDirectory = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Temp), "_github_workflow");
Directory.CreateDirectory(tempWorkflowDirectory);
#if OS_WINDOWS
container.MountVolumes.Add(new MountVolume(tempWorkflowDirectory, "C:\\ghworkflow"));
container.AddPathTranslateMapping(tempWorkflowDirectory, "C:\\ghworkflow");
#else
container.MountVolumes.Add(new MountVolume(tempWorkflowDirectory, "/github/workflow"));
container.AddPathTranslateMapping(tempWorkflowDirectory, "/github/workflow");
#endif

container.ContainerWorkDirectory = container.TranslateToContainerPath(workingDirectory);
#if OS_WINDOWS
//container.ContainerEntryPoint = "ping";
container.ContainerEntryPointArgs = "\"ping\" \"-t\" \"localhost\"";
#else
container.ContainerEntryPoint = "tail";
container.ContainerEntryPointArgs = "\"-f\" \"/dev/null\"";
#endif
}

container.ContainerId = await _dockerManager.DockerCreate(executionContext, container);
Expand Down