feat(tsdocker): add Dockerfile filtering, optional skip-build flow, and fallback Docker config credential loading
This commit is contained in:
@@ -1,5 +1,13 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-02-07 - 1.17.0 - feat(tsdocker)
|
||||||
|
add Dockerfile filtering, optional skip-build flow, and fallback Docker config credential loading
|
||||||
|
|
||||||
|
- Add TsDockerManager.filterDockerfiles(patterns) to filter discovered Dockerfiles by glob-style patterns and warn when no matches are found
|
||||||
|
- Allow skipping image build with --no-build (argvArg.build === false): discover Dockerfiles and apply filters without performing build
|
||||||
|
- Fallback to load Docker registry credentials from ~/.docker/config.json via RegistryCopy.getDockerConfigCredentials when env vars do not provide credentials
|
||||||
|
- Import RegistryCopy and add info/warn logs when credentials are loaded or missing
|
||||||
|
|
||||||
## 2026-02-07 - 1.16.0 - feat(core)
|
## 2026-02-07 - 1.16.0 - feat(core)
|
||||||
Introduce per-invocation TsDockerSession and session-aware local registry and build orchestration; stream and parse buildx output for improved logging and visibility; detect Docker topology and add CI-safe cleanup; update README with multi-arch, parallel-build, caching, and local registry usage and new CLI flags.
|
Introduce per-invocation TsDockerSession and session-aware local registry and build orchestration; stream and parse buildx output for improved logging and visibility; detect Docker topology and add CI-safe cleanup; update README with multi-arch, parallel-build, caching, and local registry usage and new CLI flags.
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@git.zone/tsdocker',
|
name: '@git.zone/tsdocker',
|
||||||
version: '1.16.0',
|
version: '1.17.0',
|
||||||
description: 'develop npm modules cross platform with docker'
|
description: 'develop npm modules cross platform with docker'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { RegistryStorage } from './classes.registrystorage.js';
|
|||||||
import { TsDockerCache } from './classes.tsdockercache.js';
|
import { TsDockerCache } from './classes.tsdockercache.js';
|
||||||
import { DockerContext } from './classes.dockercontext.js';
|
import { DockerContext } from './classes.dockercontext.js';
|
||||||
import { TsDockerSession } from './classes.tsdockersession.js';
|
import { TsDockerSession } from './classes.tsdockersession.js';
|
||||||
|
import { RegistryCopy } from './classes.registrycopy.js';
|
||||||
import type { ITsDockerConfig, IBuildCommandOptions } from './interfaces/index.js';
|
import type { ITsDockerConfig, IBuildCommandOptions } from './interfaces/index.js';
|
||||||
|
|
||||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||||
@@ -76,6 +77,22 @@ export class TsDockerManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback: check ~/.docker/config.json if env vars didn't provide credentials
|
||||||
|
if (!this.registryStorage.getRegistryByUrl(registryUrl)) {
|
||||||
|
const dockerConfigCreds = RegistryCopy.getDockerConfigCredentials(registryUrl);
|
||||||
|
if (dockerConfigCreds) {
|
||||||
|
const registry = new DockerRegistry({
|
||||||
|
registryUrl,
|
||||||
|
username: dockerConfigCreds.username,
|
||||||
|
password: dockerConfigCreds.password,
|
||||||
|
});
|
||||||
|
this.registryStorage.addRegistry(registry);
|
||||||
|
logger.log('info', `Loaded credentials for ${registryUrl} from ~/.docker/config.json`);
|
||||||
|
} else {
|
||||||
|
logger.log('warn', `No credentials found for ${registryUrl} (checked env vars and ~/.docker/config.json)`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,6 +127,27 @@ export class TsDockerManager {
|
|||||||
return this.dockerfiles;
|
return this.dockerfiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters discovered Dockerfiles by name patterns (glob-style).
|
||||||
|
* Mutates this.dockerfiles in place.
|
||||||
|
*/
|
||||||
|
public filterDockerfiles(patterns: string[]): void {
|
||||||
|
const matched = this.dockerfiles.filter((df) => {
|
||||||
|
const basename = plugins.path.basename(df.filePath);
|
||||||
|
return patterns.some((pattern) => {
|
||||||
|
if (pattern.includes('*') || pattern.includes('?')) {
|
||||||
|
const regexStr = '^' + pattern.replace(/\*/g, '.*').replace(/\?/g, '.') + '$';
|
||||||
|
return new RegExp(regexStr).test(basename);
|
||||||
|
}
|
||||||
|
return basename === pattern;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if (matched.length === 0) {
|
||||||
|
logger.log('warn', `No Dockerfiles matched patterns: ${patterns.join(', ')}`);
|
||||||
|
}
|
||||||
|
this.dockerfiles = matched;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds discovered Dockerfiles in dependency order.
|
* Builds discovered Dockerfiles in dependency order.
|
||||||
* When options.patterns is provided, only matching Dockerfiles (and their dependencies) are built.
|
* When options.patterns is provided, only matching Dockerfiles (and their dependencies) are built.
|
||||||
|
|||||||
@@ -110,8 +110,15 @@ export let run = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build images first (if not already built)
|
// Build images first, unless --no-build is set
|
||||||
|
if (argvArg.build === false) {
|
||||||
|
await manager.discoverDockerfiles();
|
||||||
|
if (buildOptions.patterns?.length) {
|
||||||
|
manager.filterDockerfiles(buildOptions.patterns);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
await manager.build(buildOptions);
|
await manager.build(buildOptions);
|
||||||
|
}
|
||||||
|
|
||||||
// Get registry from --registry flag
|
// Get registry from --registry flag
|
||||||
const registryArg = argvArg.registry as string | undefined;
|
const registryArg = argvArg.registry as string | undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user