Add a preference option to overwrite docker build path (#158)

This commit is contained in:
nyamakawa 2017-11-09 07:55:45 +09:00 коммит произвёл Chris Dias
Родитель 26fafb39a5
Коммит 1953372758
2 изменённых файлов: 13 добавлений и 1 удалений

Просмотреть файл

@ -51,6 +51,9 @@ async function resolveImageItem(folder: vscode.WorkspaceFolder, dockerFileUri?:
}
export async function buildImage(dockerFileUri?: vscode.Uri, ) {
const configOptions: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration('docker');
const defaultContextPath = configOptions.get('imageBuildContextPath', '');
let folder: vscode.WorkspaceFolder;
if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length === 1) {
folder = vscode.workspace.workspaceFolders[0];
@ -68,6 +71,10 @@ export async function buildImage(dockerFileUri?: vscode.Uri, ) {
}
const uri: Item = await resolveImageItem(folder, dockerFileUri);
let contextPath: string = uri.path;
if (defaultContextPath && defaultContextPath != '') {
contextPath = defaultContextPath;
}
if (!uri) return;
@ -97,7 +104,7 @@ export async function buildImage(dockerFileUri?: vscode.Uri, ) {
if (!value) return;
const terminal: vscode.Terminal = vscode.window.createTerminal('Docker');
terminal.sendText(`docker build --rm -f ${uri.file} -t ${value} ${uri.path}`);
terminal.sendText(`docker build --rm -f ${uri.file} -t ${value} ${contextPath}`);
terminal.show();
if (reporter) {

Просмотреть файл

@ -271,6 +271,11 @@
"default": 1000,
"description": "Explorer refresh interval, default is 1000ms."
},
"docker.imageBuildContextPath": {
"type": "string",
"default": "",
"description": "Build context PATH to pass to Docker build command."
},
"docker.languageserver.diagnostics.deprecatedMaintainer": {
"scope": "resource",
"type": "string",