Skip to content

Commit 0890ccf

Browse files
jrandellchrmarti
authored andcommitted
Stop races docker-compose.devcontainer.containerFeatures file #801
This commit adds a UUID to the filename for `docker-compose.devcontainer.containerFeatures`. The current filename uses a timestamp to avoid collisions, which causes different invocations of the CLI to overwrite each others files.
1 parent e019ea1 commit 0890ccf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/spec-node/dockerCompose.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { Mount, parseMount } from '../spec-configuration/containerFeaturesConfig
1919
import path from 'path';
2020
import { getDevcontainerMetadata, getImageBuildInfoFromDockerfile, getImageBuildInfoFromImage, getImageMetadataFromContainer, ImageBuildInfo, lifecycleCommandOriginMapFromMetadata, mergeConfiguration, MergedDevContainerConfig } from './imageMetadata';
2121
import { ensureDockerfileHasFinalStageName } from './dockerfileUtils';
22+
import { randomUUID } from 'crypto';
2223

2324
const projectLabel = 'com.docker.compose.project';
2425
const serviceLabel = 'com.docker.compose.service';
@@ -483,7 +484,7 @@ async function writeFeaturesComposeOverrideFile(
483484
if (overrideFileHasContents) {
484485
output.write(`Docker Compose override file for creating container:\n${composeOverrideContent}`);
485486

486-
const fileName = `${overrideFilePrefix}-${Date.now()}.yml`;
487+
const fileName = `${overrideFilePrefix}-${Date.now()}-${randomUUID()}.yml`;
487488
const composeFolder = buildCLIHost.path.join(overrideFilePath, 'docker-compose');
488489
const composeOverrideFile = buildCLIHost.path.join(composeFolder, fileName);
489490
output.write(`Writing ${fileName} to ${composeFolder}`);

0 commit comments

Comments
 (0)