From b0cd987edef5783694e6d06407975159167b3d92 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Thu, 10 Sep 2020 12:59:05 -0400 Subject: [PATCH] Custom args for docker-build and docker-run tasks (#2294) --- package.json | 8 ++++++++ package.nls.json | 2 ++ src/tasks/DockerBuildTaskDefinitionBase.ts | 1 + src/tasks/DockerBuildTaskProvider.ts | 1 + src/tasks/DockerRunTaskDefinitionBase.ts | 1 + src/tasks/DockerRunTaskProvider.ts | 1 + 6 files changed, 14 insertions(+) diff --git a/package.json b/package.json index 2177b5370f..a293bf4212 100644 --- a/package.json +++ b/package.json @@ -1074,6 +1074,10 @@ "pull": { "type": "boolean", "description": "%vscode-docker.tasks.docker-build.dockerBuild.pull%" + }, + "customOptions": { + "type": "string", + "description": "%vscode-docker.tasks.docker-build.dockerBuild.customOptions%" } } }, @@ -1263,6 +1267,10 @@ "type": "boolean", "description": "%vscode-docker.tasks.docker-run.dockerRun.remove%", "default": false + }, + "customOptions": { + "type": "string", + "description": "%vscode-docker.tasks.docker-run.dockerRun.customOptions%" } } }, diff --git a/package.nls.json b/package.nls.json index d7ba299c04..a7df80fe68 100644 --- a/package.nls.json +++ b/package.nls.json @@ -50,6 +50,7 @@ "vscode-docker.tasks.docker-build.dockerBuild.tag": "Tag applied to the Docker image used for debugging.", "vscode-docker.tasks.docker-build.dockerBuild.target": "Docker build target (stage) used for debugging.", "vscode-docker.tasks.docker-build.dockerBuild.pull": "Whether or not to pull new base images before building.", + "vscode-docker.tasks.docker-build.dockerBuild.customOptions": "Any other options to add to the `docker build` command.", "vscode-docker.tasks.docker-build.platform": "The target platform for the application.", "vscode-docker.tasks.docker-build.netCore.description": "Options for building .NET Core projects in Docker.", "vscode-docker.tasks.docker-build.netCore.appProject": "The .NET Core project (.csproj, .fsproj, etc.) to build.", @@ -80,6 +81,7 @@ "vscode-docker.tasks.docker-run.dockerRun.volumes.localPath": "Path on local machine that will be mapped. The folder will be created if it does not exist.", "vscode-docker.tasks.docker-run.dockerRun.volumes.containerPath": "Path where the volume will be mapped within the container. The folder will be created if it does not exist.", "vscode-docker.tasks.docker-run.dockerRun.volumes.permissions": "Permissions for the container for the mapped volume, `rw` for read-write or `ro` for read-only.", + "vscode-docker.tasks.docker-run.dockerRun.customOptions": "Any other options to add to the `docker run` command.", "vscode-docker.tasks.docker-run.platform": "The target platform for the application.", "vscode-docker.tasks.docker-run.netCore.description": "Options for running .NET Core projects in Docker.", "vscode-docker.tasks.docker-run.netCore.appProject": "The .NET Core project (.csproj, .fsproj, etc.) to build.", diff --git a/src/tasks/DockerBuildTaskDefinitionBase.ts b/src/tasks/DockerBuildTaskDefinitionBase.ts index 41882af980..0318c289e5 100644 --- a/src/tasks/DockerBuildTaskDefinitionBase.ts +++ b/src/tasks/DockerBuildTaskDefinitionBase.ts @@ -13,6 +13,7 @@ export interface DockerBuildOptions { tag?: string; target?: string; pull?: boolean; + customOptions?: string; } export interface DockerBuildTaskDefinitionBase extends TaskDefinitionBase { diff --git a/src/tasks/DockerBuildTaskProvider.ts b/src/tasks/DockerBuildTaskProvider.ts index 833e6da3e5..3c5907de34 100644 --- a/src/tasks/DockerBuildTaskProvider.ts +++ b/src/tasks/DockerBuildTaskProvider.ts @@ -97,6 +97,7 @@ export class DockerBuildTaskProvider extends DockerTaskProvider { .withKeyValueArgs('--label', getAggregateLabels(options.labels, defaultVsCodeLabels)) .withNamedArg('-t', options.tag) .withNamedArg('--target', options.target) + .withArg(options.customOptions) .withQuotedArg(options.context); } } diff --git a/src/tasks/DockerRunTaskDefinitionBase.ts b/src/tasks/DockerRunTaskDefinitionBase.ts index 01284f88b4..29baccc3a8 100644 --- a/src/tasks/DockerRunTaskDefinitionBase.ts +++ b/src/tasks/DockerRunTaskDefinitionBase.ts @@ -40,6 +40,7 @@ export interface DockerRunOptions { portsPublishAll?: boolean; volumes?: DockerContainerVolume[]; remove?: boolean; + customOptions?: string; } export interface DockerRunTaskDefinitionBase extends TaskDefinitionBase { diff --git a/src/tasks/DockerRunTaskProvider.ts b/src/tasks/DockerRunTaskProvider.ts index b32c4c374a..ba2ea9361f 100644 --- a/src/tasks/DockerRunTaskProvider.ts +++ b/src/tasks/DockerRunTaskProvider.ts @@ -95,6 +95,7 @@ export class DockerRunTaskProvider extends DockerTaskProvider { .withArrayArgs('--add-host', runOptions.extraHosts, extraHost => `${extraHost.hostname}:${extraHost.ip}`) .withNamedArg('--entrypoint', runOptions.entrypoint) .withFlagArg('--rm', runOptions.remove) + .withArg(runOptions.customOptions) .withQuotedArg(runOptions.image) .withArgs(runOptions.command); }