Revised Docker image build process.
This commit is contained in:
41
package-lock.json
generated
41
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "jmespath-playground",
|
"name": "jmespath-playground",
|
||||||
"version": "1.3.1",
|
"version": "1.4.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "jmespath-playground",
|
"name": "jmespath-playground",
|
||||||
"version": "1.3.1",
|
"version": "1.4.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.14.0",
|
"@emotion/react": "^11.14.0",
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
"jmespath": "^0.16.0",
|
"jmespath": "^0.16.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
|
"semver": "^7.7.3",
|
||||||
"uuid": "^9.0.0"
|
"uuid": "^9.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -158,6 +159,16 @@
|
|||||||
"url": "https://opencollective.com/babel"
|
"url": "https://opencollective.com/babel"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@babel/core/node_modules/semver": {
|
||||||
|
"version": "6.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
||||||
|
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"bin": {
|
||||||
|
"semver": "bin/semver.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@babel/generator": {
|
"node_modules/@babel/generator": {
|
||||||
"version": "7.28.6",
|
"version": "7.28.6",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.28.6.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.28.6.tgz",
|
||||||
@@ -191,6 +202,16 @@
|
|||||||
"node": ">=6.9.0"
|
"node": ">=6.9.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@babel/helper-compilation-targets/node_modules/semver": {
|
||||||
|
"version": "6.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
||||||
|
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"bin": {
|
||||||
|
"semver": "bin/semver.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@babel/helper-globals": {
|
"node_modules/@babel/helper-globals": {
|
||||||
"version": "7.28.0",
|
"version": "7.28.0",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.28.0.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.28.0.tgz",
|
||||||
@@ -4122,9 +4143,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/lodash": {
|
"node_modules/lodash": {
|
||||||
"version": "4.17.21",
|
"version": "4.17.23",
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
|
||||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
"integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
@@ -4891,13 +4912,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/semver": {
|
"node_modules/semver": {
|
||||||
"version": "6.3.1",
|
"version": "7.7.3",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",
|
||||||
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
|
"integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",
|
||||||
"dev": true,
|
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"bin": {
|
"bin": {
|
||||||
"semver": "bin/semver.js"
|
"semver": "bin/semver.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/send": {
|
"node_modules/send": {
|
||||||
|
|||||||
@@ -5,13 +5,13 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
"prebuild": "node scripts/version-check.js",
|
"prebuild": "node scripts/version.mjs",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test": "vitest",
|
"test": "vitest",
|
||||||
"server": "node server.js --dev",
|
"server": "node server.js --dev",
|
||||||
"dev": "concurrently \"npm start\" \"node --watch server.js --dev\"",
|
"dev": "concurrently \"npm start\" \"node --watch server.js --dev\"",
|
||||||
"build-image": "node scripts/build-image.js"
|
"build-image": "vite build && node scripts/build-image.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=24.0.0"
|
"node": ">=24.0.0"
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
"jmespath": "^0.16.0",
|
"jmespath": "^0.16.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
|
"semver": "^7.7.3",
|
||||||
"uuid": "^9.0.0"
|
"uuid": "^9.0.0"
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
const { execSync } = require('child_process');
|
const { execSync } = require('child_process');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const { pathToFileURL } = require('url');
|
||||||
const { parseArgs } = require('util');
|
const { parseArgs } = require('util');
|
||||||
|
|
||||||
function execCommand(command, description) {
|
function execCommand(command, description) {
|
||||||
@@ -31,20 +33,27 @@ function getContainerTool() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVersion() {
|
async function generateVersionFile() {
|
||||||
try {
|
const versionModuleUrl = pathToFileURL(path.join(__dirname, 'version.mjs')).href;
|
||||||
// Try to get version from git tag
|
const { generateVersionFile: generate } = await import(versionModuleUrl);
|
||||||
const gitTag = execSync('git tag --points-at HEAD', { encoding: 'utf8' }).trim();
|
const versionFilePath = path.join(__dirname, '..', 'src', 'version.js');
|
||||||
if (gitTag) {
|
generate(versionFilePath);
|
||||||
return { version: gitTag.replace(/^v/, ''), isRelease: true };
|
return versionFilePath;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
// Git command failed, ignore
|
function readVersionFile(versionFilePath) {
|
||||||
|
const contents = fs.readFileSync(versionFilePath, 'utf8');
|
||||||
|
const versionMatch = contents.match(/export const VERSION = '([^']+)';/);
|
||||||
|
const releaseMatch = contents.match(/export const IS_RELEASE = (true|false);/);
|
||||||
|
|
||||||
|
if (!versionMatch || !releaseMatch) {
|
||||||
|
throw new Error(`Could not parse version file at ${versionFilePath}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Development build - use package.json version with -dev suffix
|
return {
|
||||||
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
version: versionMatch[1],
|
||||||
return { version: `${packageJson.version}-dev`, isRelease: false };
|
isRelease: releaseMatch[1] === 'true'
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHostArchitecture() {
|
function getHostArchitecture() {
|
||||||
@@ -77,7 +86,7 @@ Examples:
|
|||||||
build-image.js -h # Show help`);
|
build-image.js -h # Show help`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
async function main() {
|
||||||
const { values } = parseArgs({
|
const { values } = parseArgs({
|
||||||
options: {
|
options: {
|
||||||
help: {
|
help: {
|
||||||
@@ -105,7 +114,8 @@ function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const containerTool = getContainerTool();
|
const containerTool = getContainerTool();
|
||||||
const { version, isRelease } = getVersion();
|
const versionFilePath = await generateVersionFile();
|
||||||
|
const { version, isRelease } = readVersionFile(versionFilePath);
|
||||||
|
|
||||||
let architectures;
|
let architectures;
|
||||||
if (values['all-arch']) {
|
if (values['all-arch']) {
|
||||||
@@ -160,5 +170,8 @@ function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
main();
|
main().catch((error) => {
|
||||||
}
|
console.error(`Error: ${error.message}`);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const { execSync } = require('child_process');
|
|
||||||
|
|
||||||
// Read package.json for base version
|
|
||||||
const packagePath = './package.json';
|
|
||||||
const pkg = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
|
|
||||||
|
|
||||||
let version = pkg.version;
|
|
||||||
let isRelease = false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Check if current commit is tagged
|
|
||||||
const gitTag = execSync('git tag --points-at HEAD', { encoding: 'utf8' }).trim();
|
|
||||||
|
|
||||||
if (gitTag) {
|
|
||||||
// We're at a tagged commit - extract version from tag
|
|
||||||
const tagVersion = gitTag.replace(/^v/, ''); // Remove 'v' prefix if present
|
|
||||||
version = tagVersion;
|
|
||||||
console.log(`✅ Building release version ${version} (tagged: ${gitTag})`);
|
|
||||||
isRelease = true;
|
|
||||||
} else {
|
|
||||||
// We're not at a tagged commit - use unknown version
|
|
||||||
version = 'unknown';
|
|
||||||
console.log(`📦 Building development version with unknown version`);
|
|
||||||
isRelease = false;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
// Git command failed (maybe not in a git repo)
|
|
||||||
version = 'unknown';
|
|
||||||
console.log(`⚠️ Cannot determine git status, using unknown version`);
|
|
||||||
isRelease = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate version.js file
|
|
||||||
const versionFile = path.join('./src', 'version.js');
|
|
||||||
const versionContent = `// Auto-generated version file - do not edit manually
|
|
||||||
// Generated at: ${new Date().toISOString()}
|
|
||||||
|
|
||||||
export const VERSION = '${version}';
|
|
||||||
export const IS_RELEASE = ${isRelease};
|
|
||||||
export const BUILD_TIME = '${new Date().toISOString()}';
|
|
||||||
`;
|
|
||||||
|
|
||||||
fs.writeFileSync(versionFile, versionContent);
|
|
||||||
console.log(`📝 Generated ${versionFile} with version ${version}`);
|
|
||||||
@@ -63,3 +63,7 @@ export const BUILD_TIME = '${buildDate}';
|
|||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||||
|
generateVersionFile("src/version.js");
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user