mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-15 17:22:25 -05:00
sqlproj publish to container - october release improvements (#17289)
This commit is contained in:
@@ -111,11 +111,15 @@ export class DeployService {
|
||||
const dockerFilePath = path.join(mssqlFolderPath, constants.dockerFileName);
|
||||
const startFilePath = path.join(commandsFolderPath, constants.startCommandName);
|
||||
|
||||
this.logToOutput(constants.cleaningDockerImagesMessage);
|
||||
// Clean up existing docker image
|
||||
|
||||
await this.cleanDockerObjects(`docker ps -q -a --filter label=${imageLabel}`, ['docker stop', 'docker rm']);
|
||||
await this.cleanDockerObjects(`docker images -f label=${imageLabel} -q`, [`docker rmi -f `]);
|
||||
const containerIds = await this.getCurrentDockerContainer(imageLabel);
|
||||
if (containerIds && containerIds.length > 0) {
|
||||
const result = await vscode.window.showWarningMessage(constants.containerAlreadyExistForProject, constants.yesString, constants.noString);
|
||||
if (result === constants.yesString) {
|
||||
this.logToOutput(constants.cleaningDockerImagesMessage);
|
||||
await this.cleanDockerObjects(containerIds, ['docker stop', 'docker rm']);
|
||||
}
|
||||
}
|
||||
|
||||
this.logToOutput(constants.creatingDeploymentSettingsMessage);
|
||||
// Create commands
|
||||
@@ -363,17 +367,22 @@ RUN ["/bin/bash", "/opt/commands/start.sh"]
|
||||
await fse.writeFile(filePath, content);
|
||||
}
|
||||
|
||||
public async cleanDockerObjects(commandToGetObjects: string, commandsToClean: string[]): Promise<void> {
|
||||
const currentIds = await utils.executeCommand(commandToGetObjects, this._outputChannel);
|
||||
if (currentIds) {
|
||||
const ids = currentIds.split(/\r?\n/);
|
||||
for (let index = 0; index < ids.length; index++) {
|
||||
const id = ids[index];
|
||||
if (id) {
|
||||
for (let commandId = 0; commandId < commandsToClean.length; commandId++) {
|
||||
const command = commandsToClean[commandId];
|
||||
await utils.executeCommand(`${command} ${id}`, this._outputChannel);
|
||||
}
|
||||
private async getCurrentIds(commandToRun: string): Promise<string[]> {
|
||||
const currentIds = await utils.executeCommand(commandToRun, this._outputChannel);
|
||||
return currentIds ? currentIds.split(/\r?\n/) : [];
|
||||
}
|
||||
|
||||
public async getCurrentDockerContainer(imageLabel: string): Promise<string[]> {
|
||||
return await this.getCurrentIds(`docker ps -q -a --filter label=${imageLabel}`);
|
||||
}
|
||||
|
||||
public async cleanDockerObjects(ids: string[], commandsToClean: string[]): Promise<void> {
|
||||
for (let index = 0; index < ids.length; index++) {
|
||||
const id = ids[index];
|
||||
if (id) {
|
||||
for (let commandId = 0; commandId < commandsToClean.length; commandId++) {
|
||||
const command = commandsToClean[commandId];
|
||||
await utils.executeCommand(`${command} ${id}`, this._outputChannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user