@docupace/pipeline 1.0.81-alpha.9 → 1.0.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/src/merge/cli-merge-all.js +2 -15
- package/src/merge/cli-merge.js +3 -82
- package/src/micro/cli.js +51 -0
- package/src/micro/ms-deploy.js +451 -0
- package/src/micro/ms-publish.js +186 -0
- package/src/next/cli.js +1 -10
- package/terraform/import.sh +111 -0
- package/terraform/plan.sh +17 -4
- package/src/micro/deploy-microservice.js +0 -153
- package/src/micro/publish-ms.js +0 -188
package/src/micro/publish-ms.js
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { $ } from '../next/logger.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Publish Docker images for microservices with flexible naming
|
|
5
|
-
* @param {string} gitSha - Git commit SHA
|
|
6
|
-
* @param {Object} options - Configuration options
|
|
7
|
-
* @param {string} options.imageName - Docker image name (e.g., 'swp')
|
|
8
|
-
* @param {string} options.registryUrl - JFrog registry URL
|
|
9
|
-
* @param {string} options.repoName - Repository name in JFrog
|
|
10
|
-
* @param {string} options.username - JFrog username
|
|
11
|
-
* @param {string} options.password - JFrog password
|
|
12
|
-
* @param {string} options.buildNumber - Build number
|
|
13
|
-
*/
|
|
14
|
-
export async function publishMicroservice(gitSha, options = {}) {
|
|
15
|
-
// Use environment variables as defaults, but allow overrides
|
|
16
|
-
const config = {
|
|
17
|
-
imageName:
|
|
18
|
-
options.imageName || process.env.IMAGE_NAME || process.env.APP_NAME,
|
|
19
|
-
registryUrl: options.registryUrl || process.env.JF_REGISTRY_URL,
|
|
20
|
-
repoName: options.repoName || process.env.JF_REGISTRY_REPO_NAME,
|
|
21
|
-
username: options.username || process.env.JF_REGISTRY_USER_DEV,
|
|
22
|
-
password: options.password || process.env.JF_REGISTRY_PASSWORD_DEV,
|
|
23
|
-
buildNumber: options.buildNumber || process.env.BITBUCKET_BUILD_NUMBER,
|
|
24
|
-
tag:
|
|
25
|
-
options.tag ||
|
|
26
|
-
process.env.TAG ||
|
|
27
|
-
process.env.BITBUCKET_TAG ||
|
|
28
|
-
process.env.VERSION_TAG,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// Validate required fields
|
|
32
|
-
if (!config.imageName) {
|
|
33
|
-
throw new Error(
|
|
34
|
-
'Image name is required. Set IMAGE_NAME or APP_NAME environment variable.',
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
console.log('=== Docker Image Publishing Configuration ===');
|
|
39
|
-
console.log(`Image Name: ${config.imageName}`);
|
|
40
|
-
console.log(`Git SHA: ${gitSha}`);
|
|
41
|
-
console.log(`Build Number: ${config.buildNumber}`);
|
|
42
|
-
console.log(`Version Tag: ${config.tag || 'none'}`);
|
|
43
|
-
console.log(`Registry: ${config.registryUrl}/${config.repoName}`);
|
|
44
|
-
console.log('==========================================');
|
|
45
|
-
|
|
46
|
-
const registryPath = `${config.registryUrl}/${config.repoName}`;
|
|
47
|
-
const SHA_IMAGE_NAME = `${config.imageName}:sha-${gitSha}`;
|
|
48
|
-
|
|
49
|
-
// Docker login
|
|
50
|
-
await $`echo ${config.password} | docker login --username ${config.username} --password-stdin ${config.registryUrl}`;
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
// Build the image if it doesn't exist locally
|
|
54
|
-
const imageExists = await checkLocalImage(SHA_IMAGE_NAME);
|
|
55
|
-
if (!imageExists) {
|
|
56
|
-
console.log(`Building Docker image ${SHA_IMAGE_NAME}...`);
|
|
57
|
-
await $`docker build -t ${SHA_IMAGE_NAME} .`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Array to track all tags we're pushing
|
|
61
|
-
const tagsToPush = [];
|
|
62
|
-
|
|
63
|
-
// 1. Push SHA tag
|
|
64
|
-
const shaTag = `${registryPath}/${SHA_IMAGE_NAME}`;
|
|
65
|
-
console.log(`Tagging and pushing SHA: ${shaTag}`);
|
|
66
|
-
await $`docker tag ${SHA_IMAGE_NAME} ${shaTag}`;
|
|
67
|
-
await $`docker push ${shaTag}`;
|
|
68
|
-
tagsToPush.push(SHA_IMAGE_NAME);
|
|
69
|
-
|
|
70
|
-
// 2. Push build number tag
|
|
71
|
-
if (config.buildNumber) {
|
|
72
|
-
const BUILD_IMAGE_NAME = `${config.imageName}:build-${config.buildNumber}`;
|
|
73
|
-
const buildTag = `${registryPath}/${BUILD_IMAGE_NAME}`;
|
|
74
|
-
console.log(`Tagging and pushing build: ${buildTag}`);
|
|
75
|
-
await $`docker tag ${SHA_IMAGE_NAME} ${buildTag}`;
|
|
76
|
-
await $`docker push ${buildTag}`;
|
|
77
|
-
tagsToPush.push(BUILD_IMAGE_NAME);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// 3. Push version tag (this is what ArgoCD needs!)
|
|
81
|
-
if (config.tag) {
|
|
82
|
-
// Handle various tag formats
|
|
83
|
-
let version = config.tag;
|
|
84
|
-
|
|
85
|
-
// If tag contains @, extract version after it
|
|
86
|
-
if (version.includes('@')) {
|
|
87
|
-
version = 'v' + version.split('@')[1];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Ensure version starts with 'v' if it's a semver without it
|
|
91
|
-
if (/^\d+\.\d+\.\d+/.test(version) && !version.startsWith('v')) {
|
|
92
|
-
version = 'v' + version;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const VERSION_IMAGE_NAME = `${config.imageName}:${version}`;
|
|
96
|
-
const versionTag = `${registryPath}/${VERSION_IMAGE_NAME}`;
|
|
97
|
-
|
|
98
|
-
console.log(`Tagging and pushing version: ${versionTag}`);
|
|
99
|
-
await $`docker tag ${SHA_IMAGE_NAME} ${versionTag}`;
|
|
100
|
-
await $`docker push ${versionTag}`;
|
|
101
|
-
tagsToPush.push(VERSION_IMAGE_NAME);
|
|
102
|
-
|
|
103
|
-
// Also push 'latest' tag when we have a version
|
|
104
|
-
const LATEST_IMAGE_NAME = `${config.imageName}:latest`;
|
|
105
|
-
const latestTag = `${registryPath}/${LATEST_IMAGE_NAME}`;
|
|
106
|
-
console.log(`Tagging and pushing latest: ${latestTag}`);
|
|
107
|
-
await $`docker tag ${SHA_IMAGE_NAME} ${latestTag}`;
|
|
108
|
-
await $`docker push ${latestTag}`;
|
|
109
|
-
tagsToPush.push(LATEST_IMAGE_NAME);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// 4. Check for git tags at current commit
|
|
113
|
-
try {
|
|
114
|
-
const gitTags = (await $`git tag --points-at HEAD`).stdout
|
|
115
|
-
.trim()
|
|
116
|
-
.split('\n')
|
|
117
|
-
.filter(Boolean);
|
|
118
|
-
|
|
119
|
-
if (gitTags.length > 0) {
|
|
120
|
-
console.log(`Found git tags at HEAD: ${gitTags.join(', ')}`);
|
|
121
|
-
|
|
122
|
-
for (const gitTag of gitTags) {
|
|
123
|
-
// Skip if we already handled this tag above
|
|
124
|
-
if (gitTag === config.tag) continue;
|
|
125
|
-
|
|
126
|
-
let version = gitTag;
|
|
127
|
-
if (version.includes('@')) {
|
|
128
|
-
version = 'v' + version.split('@')[1];
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const TAG_IMAGE_NAME = `${config.imageName}:${version}`;
|
|
132
|
-
const gitTagPath = `${registryPath}/${TAG_IMAGE_NAME}`;
|
|
133
|
-
|
|
134
|
-
console.log(`Tagging and pushing git tag: ${gitTagPath}`);
|
|
135
|
-
await $`docker tag ${SHA_IMAGE_NAME} ${gitTagPath}`;
|
|
136
|
-
await $`docker push ${gitTagPath}`;
|
|
137
|
-
tagsToPush.push(TAG_IMAGE_NAME);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
} catch (e) {
|
|
141
|
-
console.log('No git tags found at HEAD or error checking tags', e);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
console.log('\n✅ Docker image published successfully!');
|
|
145
|
-
console.log('=== Summary of pushed tags ===');
|
|
146
|
-
tagsToPush.forEach((tag) => console.log(` ✓ ${tag}`));
|
|
147
|
-
console.log('==============================\n');
|
|
148
|
-
|
|
149
|
-
// Verify the version tag if we expect one
|
|
150
|
-
if (config.tag) {
|
|
151
|
-
const version = config.tag.includes('@')
|
|
152
|
-
? 'v' + config.tag.split('@')[1]
|
|
153
|
-
: config.tag;
|
|
154
|
-
const expectedTag = `${registryPath}/${config.imageName}:${version}`;
|
|
155
|
-
console.log(`Verifying version tag exists: ${expectedTag}`);
|
|
156
|
-
try {
|
|
157
|
-
await $`docker manifest inspect ${expectedTag}`;
|
|
158
|
-
console.log('✅ Version tag verified in registry!');
|
|
159
|
-
} catch (e) {
|
|
160
|
-
console.error('❌ WARNING: Could not verify version tag in registry!');
|
|
161
|
-
console.error('ArgoCD may fail to pull this image.', e);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
} catch (error) {
|
|
165
|
-
console.error('Error during image publishing:', error);
|
|
166
|
-
throw error;
|
|
167
|
-
} finally {
|
|
168
|
-
// Always logout
|
|
169
|
-
await $`docker logout ${config.registryUrl}`;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
async function checkLocalImage(imageName) {
|
|
174
|
-
try {
|
|
175
|
-
$.verbose = false;
|
|
176
|
-
await $`docker image inspect ${imageName}`;
|
|
177
|
-
return true;
|
|
178
|
-
} catch {
|
|
179
|
-
return false;
|
|
180
|
-
} finally {
|
|
181
|
-
$.verbose = true;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Backward compatibility wrapper
|
|
186
|
-
export async function publishWithDefaults(gitSha) {
|
|
187
|
-
return publishMicroservice(gitSha);
|
|
188
|
-
}
|