Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7131c16f80 | |||
| 02688861f4 | |||
| 3a8b301b3e | |||
| c09bef33c3 |
15
changelog.md
15
changelog.md
@@ -1,5 +1,20 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-02-06 - 1.7.0 - feat(cli)
|
||||||
|
add CLI version display using commitinfo
|
||||||
|
|
||||||
|
- Imported commitinfo from './00_commitinfo_data.js' and called tsdockerCli.addVersion(commitinfo.version) to surface package/commit version in the Smartcli instance
|
||||||
|
- Change made in ts/tsdocker.cli.ts — small user-facing CLI enhancement; no breaking changes
|
||||||
|
|
||||||
|
## 2026-02-06 - 1.6.0 - feat(docker)
|
||||||
|
add support for no-cache builds and tag built images for local dependency resolution
|
||||||
|
|
||||||
|
- Introduce IBuildCommandOptions.noCache to control --no-cache behavior
|
||||||
|
- Propagate noCache from CLI (via cache flag) through TsDockerManager to Dockerfile.build
|
||||||
|
- Append --no-cache to docker build/buildx commands when noCache is true
|
||||||
|
- After building an image, tag it with full base image references used by dependent Dockerfiles so their FROM lines resolve to the locally-built image
|
||||||
|
- Log tagging actions and execute docker tag via smartshellInstance
|
||||||
|
|
||||||
## 2026-02-06 - 1.5.0 - feat(build)
|
## 2026-02-06 - 1.5.0 - feat(build)
|
||||||
add support for selective builds, platform override and build timeout
|
add support for selective builds, platform override and build timeout
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@git.zone/tsdocker",
|
"name": "@git.zone/tsdocker",
|
||||||
"version": "1.5.0",
|
"version": "1.7.0",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "develop npm modules cross platform with docker",
|
"description": "develop npm modules cross platform with docker",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@git.zone/tsdocker',
|
name: '@git.zone/tsdocker',
|
||||||
version: '1.5.0',
|
version: '1.7.0',
|
||||||
description: 'develop npm modules cross platform with docker'
|
description: 'develop npm modules cross platform with docker'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,10 +138,23 @@ export class Dockerfile {
|
|||||||
*/
|
*/
|
||||||
public static async buildDockerfiles(
|
public static async buildDockerfiles(
|
||||||
sortedArrayArg: Dockerfile[],
|
sortedArrayArg: Dockerfile[],
|
||||||
options?: { platform?: string; timeout?: number },
|
options?: { platform?: string; timeout?: number; noCache?: boolean },
|
||||||
): Promise<Dockerfile[]> {
|
): Promise<Dockerfile[]> {
|
||||||
for (const dockerfileArg of sortedArrayArg) {
|
for (const dockerfileArg of sortedArrayArg) {
|
||||||
await dockerfileArg.build(options);
|
await dockerfileArg.build(options);
|
||||||
|
|
||||||
|
// Tag the built image with the full base image references used by dependent Dockerfiles,
|
||||||
|
// so their FROM lines resolve to the locally-built image instead of pulling from a registry.
|
||||||
|
const dependentBaseImages = new Set<string>();
|
||||||
|
for (const other of sortedArrayArg) {
|
||||||
|
if (other.localBaseDockerfile === dockerfileArg && other.baseImage !== dockerfileArg.buildTag) {
|
||||||
|
dependentBaseImages.add(other.baseImage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const fullTag of dependentBaseImages) {
|
||||||
|
logger.log('info', `Tagging ${dockerfileArg.buildTag} as ${fullTag} for local dependency resolution`);
|
||||||
|
await smartshellInstance.exec(`docker tag ${dockerfileArg.buildTag} ${fullTag}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return sortedArrayArg;
|
return sortedArrayArg;
|
||||||
}
|
}
|
||||||
@@ -365,22 +378,23 @@ export class Dockerfile {
|
|||||||
/**
|
/**
|
||||||
* Builds the Dockerfile
|
* Builds the Dockerfile
|
||||||
*/
|
*/
|
||||||
public async build(options?: { platform?: string; timeout?: number }): Promise<void> {
|
public async build(options?: { platform?: string; timeout?: number; noCache?: boolean }): Promise<void> {
|
||||||
logger.log('info', 'now building Dockerfile for ' + this.cleanTag);
|
logger.log('info', 'now building Dockerfile for ' + this.cleanTag);
|
||||||
const buildArgsString = await Dockerfile.getDockerBuildArgs(this.managerRef);
|
const buildArgsString = await Dockerfile.getDockerBuildArgs(this.managerRef);
|
||||||
const config = this.managerRef.config;
|
const config = this.managerRef.config;
|
||||||
const platformOverride = options?.platform;
|
const platformOverride = options?.platform;
|
||||||
const timeout = options?.timeout;
|
const timeout = options?.timeout;
|
||||||
|
const noCacheFlag = options?.noCache ? ' --no-cache' : '';
|
||||||
|
|
||||||
let buildCommand: string;
|
let buildCommand: string;
|
||||||
|
|
||||||
if (platformOverride) {
|
if (platformOverride) {
|
||||||
// Single platform override via buildx
|
// Single platform override via buildx
|
||||||
buildCommand = `docker buildx build --platform ${platformOverride} --load -t ${this.buildTag} -f ${this.filePath} ${buildArgsString} .`;
|
buildCommand = `docker buildx build --platform ${platformOverride}${noCacheFlag} --load -t ${this.buildTag} -f ${this.filePath} ${buildArgsString} .`;
|
||||||
} else if (config.platforms && config.platforms.length > 1) {
|
} else if (config.platforms && config.platforms.length > 1) {
|
||||||
// Multi-platform build using buildx
|
// Multi-platform build using buildx
|
||||||
const platformString = config.platforms.join(',');
|
const platformString = config.platforms.join(',');
|
||||||
buildCommand = `docker buildx build --platform ${platformString} -t ${this.buildTag} -f ${this.filePath} ${buildArgsString} .`;
|
buildCommand = `docker buildx build --platform ${platformString}${noCacheFlag} -t ${this.buildTag} -f ${this.filePath} ${buildArgsString} .`;
|
||||||
|
|
||||||
if (config.push) {
|
if (config.push) {
|
||||||
buildCommand += ' --push';
|
buildCommand += ' --push';
|
||||||
@@ -390,7 +404,7 @@ export class Dockerfile {
|
|||||||
} else {
|
} else {
|
||||||
// Standard build
|
// Standard build
|
||||||
const versionLabel = this.managerRef.projectInfo?.npm?.version || 'unknown';
|
const versionLabel = this.managerRef.projectInfo?.npm?.version || 'unknown';
|
||||||
buildCommand = `docker build --label="version=${versionLabel}" -t ${this.buildTag} -f ${this.filePath} ${buildArgsString} .`;
|
buildCommand = `docker build --label="version=${versionLabel}"${noCacheFlag} -t ${this.buildTag} -f ${this.filePath} ${buildArgsString} .`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ export class TsDockerManager {
|
|||||||
await Dockerfile.buildDockerfiles(toBuild, {
|
await Dockerfile.buildDockerfiles(toBuild, {
|
||||||
platform: options?.platform,
|
platform: options?.platform,
|
||||||
timeout: options?.timeout,
|
timeout: options?.timeout,
|
||||||
|
noCache: options?.noCache,
|
||||||
});
|
});
|
||||||
logger.log('success', 'All Dockerfiles built successfully');
|
logger.log('success', 'All Dockerfiles built successfully');
|
||||||
|
|
||||||
|
|||||||
@@ -76,4 +76,5 @@ export interface IBuildCommandOptions {
|
|||||||
patterns?: string[]; // Dockerfile name patterns (e.g., ['Dockerfile_base', 'Dockerfile_*'])
|
patterns?: string[]; // Dockerfile name patterns (e.g., ['Dockerfile_base', 'Dockerfile_*'])
|
||||||
platform?: string; // Single platform override (e.g., 'linux/arm64')
|
platform?: string; // Single platform override (e.g., 'linux/arm64')
|
||||||
timeout?: number; // Build timeout in seconds
|
timeout?: number; // Build timeout in seconds
|
||||||
|
noCache?: boolean; // Force rebuild without Docker layer cache (--no-cache)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ import * as DockerModule from './tsdocker.docker.js';
|
|||||||
import { logger, ora } from './tsdocker.logging.js';
|
import { logger, ora } from './tsdocker.logging.js';
|
||||||
import { TsDockerManager } from './classes.tsdockermanager.js';
|
import { TsDockerManager } from './classes.tsdockermanager.js';
|
||||||
import type { IBuildCommandOptions } from './interfaces/index.js';
|
import type { IBuildCommandOptions } from './interfaces/index.js';
|
||||||
|
import { commitinfo } from './00_commitinfo_data.js';
|
||||||
|
|
||||||
const tsdockerCli = new plugins.smartcli.Smartcli();
|
const tsdockerCli = new plugins.smartcli.Smartcli();
|
||||||
|
tsdockerCli.addVersion(commitinfo.version);
|
||||||
|
|
||||||
export let run = () => {
|
export let run = () => {
|
||||||
// Default command: run tests in container (legacy behavior)
|
// Default command: run tests in container (legacy behavior)
|
||||||
@@ -44,6 +46,9 @@ export let run = () => {
|
|||||||
if (argvArg.timeout) {
|
if (argvArg.timeout) {
|
||||||
buildOptions.timeout = Number(argvArg.timeout);
|
buildOptions.timeout = Number(argvArg.timeout);
|
||||||
}
|
}
|
||||||
|
if (argvArg.cache === false) {
|
||||||
|
buildOptions.noCache = true;
|
||||||
|
}
|
||||||
|
|
||||||
await manager.build(buildOptions);
|
await manager.build(buildOptions);
|
||||||
logger.log('success', 'Build completed successfully');
|
logger.log('success', 'Build completed successfully');
|
||||||
@@ -78,6 +83,9 @@ export let run = () => {
|
|||||||
if (argvArg.timeout) {
|
if (argvArg.timeout) {
|
||||||
buildOptions.timeout = Number(argvArg.timeout);
|
buildOptions.timeout = Number(argvArg.timeout);
|
||||||
}
|
}
|
||||||
|
if (argvArg.cache === false) {
|
||||||
|
buildOptions.noCache = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Build images first (if not already built)
|
// Build images first (if not already built)
|
||||||
await manager.build(buildOptions);
|
await manager.build(buildOptions);
|
||||||
@@ -130,7 +138,11 @@ export let run = () => {
|
|||||||
await manager.prepare();
|
await manager.prepare();
|
||||||
|
|
||||||
// Build images first
|
// Build images first
|
||||||
await manager.build();
|
const buildOptions: IBuildCommandOptions = {};
|
||||||
|
if (argvArg.cache === false) {
|
||||||
|
buildOptions.noCache = true;
|
||||||
|
}
|
||||||
|
await manager.build(buildOptions);
|
||||||
|
|
||||||
// Run tests
|
// Run tests
|
||||||
await manager.test();
|
await manager.test();
|
||||||
|
|||||||
Reference in New Issue
Block a user