@fenwave/agent 1.1.1 → 1.1.3
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/containerManager.js +4 -85
- package/package.json +4 -4
- package/store/configStore.js +2 -9
package/containerManager.js
CHANGED
|
@@ -70,79 +70,6 @@ class ContainerManager {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
/**
|
|
74
|
-
* Authenticate with AWS ECR
|
|
75
|
-
*/
|
|
76
|
-
async authenticateECR() {
|
|
77
|
-
return new Promise((resolve, reject) => {
|
|
78
|
-
const awsRegion = config.awsRegion;
|
|
79
|
-
const awsAccountId = config.awsAccountId;
|
|
80
|
-
|
|
81
|
-
if (!awsRegion || !awsAccountId) {
|
|
82
|
-
console.log(chalk.yellow('⚠️ AWS ECR configuration not set, skipping ECR authentication'));
|
|
83
|
-
console.log(chalk.gray(' Run "fenwave init" to configure ECR settings'));
|
|
84
|
-
resolve();
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
console.log(chalk.blue('🔐 Authenticating with AWS ECR...'));
|
|
89
|
-
|
|
90
|
-
const authProcess = spawn('aws', [
|
|
91
|
-
'ecr',
|
|
92
|
-
'get-login-password',
|
|
93
|
-
'--region',
|
|
94
|
-
awsRegion,
|
|
95
|
-
]);
|
|
96
|
-
|
|
97
|
-
let authToken = '';
|
|
98
|
-
let errorOutput = '';
|
|
99
|
-
|
|
100
|
-
authProcess.stdout.on('data', (data) => {
|
|
101
|
-
authToken += data.toString();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
authProcess.stderr.on('data', (data) => {
|
|
105
|
-
errorOutput += data.toString();
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
authProcess.on('close', (code) => {
|
|
109
|
-
if (code === 0) {
|
|
110
|
-
// Now login to Docker with the auth token
|
|
111
|
-
const loginProcess = spawn('docker', [
|
|
112
|
-
'login',
|
|
113
|
-
'--username',
|
|
114
|
-
'AWS',
|
|
115
|
-
'--password-stdin',
|
|
116
|
-
`${awsAccountId}.dkr.ecr.${awsRegion}.amazonaws.com`,
|
|
117
|
-
]);
|
|
118
|
-
|
|
119
|
-
loginProcess.stdin.write(authToken.trim());
|
|
120
|
-
loginProcess.stdin.end();
|
|
121
|
-
|
|
122
|
-
let loginError = '';
|
|
123
|
-
loginProcess.stderr.on('data', (data) => {
|
|
124
|
-
loginError += data.toString();
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
loginProcess.on('close', (loginCode) => {
|
|
128
|
-
if (loginCode === 0) {
|
|
129
|
-
console.log(chalk.green('✅ Authenticated with ECR'));
|
|
130
|
-
resolve();
|
|
131
|
-
} else {
|
|
132
|
-
console.error(chalk.red('❌ Failed to login to Docker registry:'));
|
|
133
|
-
console.error(loginError);
|
|
134
|
-
reject(new Error('ECR Docker login failed'));
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
} else {
|
|
138
|
-
console.error(chalk.red('❌ Failed to get ECR auth token:'));
|
|
139
|
-
console.error(errorOutput);
|
|
140
|
-
reject(new Error('ECR authentication failed'));
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
|
|
146
73
|
/**
|
|
147
74
|
* Check if image exists locally
|
|
148
75
|
*/
|
|
@@ -158,7 +85,7 @@ class ContainerManager {
|
|
|
158
85
|
}
|
|
159
86
|
|
|
160
87
|
/**
|
|
161
|
-
* Pull the Fenwave DevApp image from
|
|
88
|
+
* Pull the Fenwave DevApp image from GHCR
|
|
162
89
|
*/
|
|
163
90
|
async pullImage() {
|
|
164
91
|
return new Promise(async (resolve, reject) => {
|
|
@@ -169,7 +96,7 @@ class ContainerManager {
|
|
|
169
96
|
console.log(chalk.green('✅ Image already exists locally, checking for updates...'));
|
|
170
97
|
}
|
|
171
98
|
|
|
172
|
-
console.log(chalk.blue('📥 Pulling Fenwave DevApp image
|
|
99
|
+
console.log(chalk.blue('📥 Pulling Fenwave DevApp image...'));
|
|
173
100
|
console.log(chalk.gray(` Image: ${DOCKER_IMAGE}`));
|
|
174
101
|
|
|
175
102
|
const pullProcess = spawn('docker', ['pull', DOCKER_IMAGE], {
|
|
@@ -234,22 +161,14 @@ class ContainerManager {
|
|
|
234
161
|
// Stop existing container if running
|
|
235
162
|
await this.stopContainer();
|
|
236
163
|
|
|
237
|
-
//
|
|
238
|
-
try {
|
|
239
|
-
await this.authenticateECR();
|
|
240
|
-
} catch (ecrError) {
|
|
241
|
-
console.log(chalk.yellow('⚠️ ECR authentication failed, attempting to use cached image...'));
|
|
242
|
-
// Continue with cached image if authentication fails
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// Pull image from ECR
|
|
164
|
+
// Pull image from GHCR (public registry, no auth required)
|
|
246
165
|
try {
|
|
247
166
|
await this.pullImage();
|
|
248
167
|
} catch (pullError) {
|
|
249
168
|
console.log(chalk.yellow('⚠️ Image pull failed, checking for local image...'));
|
|
250
169
|
const imageExists = await this.imageExistsLocally();
|
|
251
170
|
if (!imageExists) {
|
|
252
|
-
throw new Error('No local image available and pull failed. Please check your
|
|
171
|
+
throw new Error('No local image available and pull failed. Please check your network connection.');
|
|
253
172
|
}
|
|
254
173
|
console.log(chalk.green('✅ Using cached local image'));
|
|
255
174
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fenwave/agent",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Fenwave Docker Agent and CLI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fenwave",
|
|
7
7
|
"fenleap",
|
|
8
8
|
"fenwave-idp"
|
|
9
9
|
],
|
|
10
|
-
"homepage": "https://github.com/
|
|
10
|
+
"homepage": "https://github.com/fenleap/fenwave-agent#readme",
|
|
11
11
|
"bugs": {
|
|
12
|
-
"url": "https://github.com/
|
|
12
|
+
"url": "https://github.com/fenleap/fenwave-agent/issues"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "git+https://github.com/
|
|
16
|
+
"url": "git+https://github.com/fenleap/fenwave-agent.git"
|
|
17
17
|
},
|
|
18
18
|
"license": "SEE LICENSE IN LICENSE",
|
|
19
19
|
"author": "Fenleap",
|
package/store/configStore.js
CHANGED
|
@@ -25,10 +25,8 @@ const DEFAULT_CONFIG = {
|
|
|
25
25
|
registriesDir: 'registries',
|
|
26
26
|
containerDataDir: '/data',
|
|
27
27
|
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
awsAccountId: null, // Set during registration from Backstage
|
|
31
|
-
dockerImage: null, // Will be computed if awsAccountId is set
|
|
28
|
+
// Docker Image (GHCR - public registry, no auth required)
|
|
29
|
+
dockerImage: 'ghcr.io/fenleap/fenwave/dev-app:latest',
|
|
32
30
|
|
|
33
31
|
// Other Settings
|
|
34
32
|
authTimeoutMs: 60000,
|
|
@@ -68,11 +66,6 @@ export function loadConfig() {
|
|
|
68
66
|
config.appBuilderUrl = config.backendUrl;
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
// Only compute dockerImage if awsAccountId is configured
|
|
72
|
-
if (!config.dockerImage && config.awsAccountId && config.awsRegion) {
|
|
73
|
-
config.dockerImage = `${config.awsAccountId}.dkr.ecr.${config.awsRegion}.amazonaws.com/fenwave/devapp:latest`;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
69
|
// Fall back to environment variables if config values are not set
|
|
77
70
|
config.backendUrl = config.backendUrl || process.env.BACKEND_URL || DEFAULT_CONFIG.backendUrl;
|
|
78
71
|
config.frontendUrl = config.frontendUrl || process.env.FRONTEND_URL || DEFAULT_CONFIG.frontendUrl;
|