@forge/cli-shared 9.3.0-next.12 → 9.3.0-next.13
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docker-compose-lifecycle.d.ts","sourceRoot":"","sources":["../../src/tunnel/docker-compose-lifecycle.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAO3C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,eAAO,MAAM,wBAAwB,qBAAqB,CAAC;AAC3D,eAAO,MAAM,wBAAwB,8BAA8B,CAAC;AACpE,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"docker-compose-lifecycle.d.ts","sourceRoot":"","sources":["../../src/tunnel/docker-compose-lifecycle.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAO3C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,eAAO,MAAM,wBAAwB,qBAAqB,CAAC;AAC3D,eAAO,MAAM,wBAAwB,8BAA8B,CAAC;AACpE,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;AAgCvD,eAAO,MAAM,gBAAgB,QAAY,CAAC;AAC1C,eAAO,MAAM,uBAAuB,QAAW,CAAC;AAEhD,qBAAa,2BAA4B,SAAQ,SAAS;gBAC5C,UAAU,EAA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E_NAME = 'proxy-sidecar';
|
|
18
|
+
const PROXY_SIDECAR_IMAGE_PATH = 'forge-platform/proxy-sidecar:latest';
|
|
19
|
+
const PROXY_SIDECAR_REGISTRIES = {
|
|
20
|
+
portable: {
|
|
21
|
+
production: 'forge-registry.services.atlassian.com',
|
|
22
|
+
staging: 'forge-registry.stg.services.atlassian.com'
|
|
23
|
+
},
|
|
24
|
+
ecr: {
|
|
25
|
+
production: 'forge-ecr.services.atlassian.com',
|
|
26
|
+
staging: 'forge-ecr.stg.services.atlassian.com'
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const isStagingEnvironment = () => process.env.FORGE_GRAPHQL_GATEWAY?.startsWith('https://api-private.stg.atlassian.com/graphql') ?? false;
|
|
30
|
+
const getProxySidecarRegistry = (registryType) => PROXY_SIDECAR_REGISTRIES[registryType][isStagingEnvironment() ? 'staging' : 'production'];
|
|
18
31
|
const LIFECYCLE_PATTERNS = [
|
|
19
32
|
/Container .* (Starting|Started|Stopping|Stopped|Creating|Created|Recreated)/,
|
|
20
33
|
/Network .* (Creating|Created|Removing|Removed)/,
|
|
@@ -134,11 +147,10 @@ const adjustFilePath = (filePath) => {
|
|
|
134
147
|
const getProxySidecarConfig = async (serviceKey, containerKeys, port, appId, envId, serviceIndex, healthEndpointPath) => {
|
|
135
148
|
let fopBaseUrl = 'https://forge-outbound-proxy.services.atlassian.com';
|
|
136
149
|
let jwksUrl = 'https://forge.cdn.prod.atlassian-dev.net/.well-known/jwks.json';
|
|
137
|
-
|
|
138
|
-
if (
|
|
150
|
+
const proxySidecarRegistry = getProxySidecarRegistry('portable');
|
|
151
|
+
if (isStagingEnvironment()) {
|
|
139
152
|
fopBaseUrl = 'https://forge-outbound-proxy.stg.services.atlassian.com';
|
|
140
153
|
jwksUrl = 'https://forge.cdn.stg.atlassian-dev.net/.well-known/jwks.json';
|
|
141
|
-
proxySidecarImage = 'forge-ecr.stg.services.atlassian.com/forge-platform/proxy-sidecar:latest';
|
|
142
154
|
}
|
|
143
155
|
let appIdShort = appId;
|
|
144
156
|
if (appId.startsWith('ari:cloud:ecosystem::app/')) {
|
|
@@ -146,7 +158,7 @@ const getProxySidecarConfig = async (serviceKey, containerKeys, port, appId, env
|
|
|
146
158
|
}
|
|
147
159
|
return {
|
|
148
160
|
[PROXY_SIDECAR_SERVICE_NAME]: {
|
|
149
|
-
image:
|
|
161
|
+
image: `${proxySidecarRegistry}/${PROXY_SIDECAR_IMAGE_PATH}`,
|
|
150
162
|
container_name: getProxySidecarContainerName(serviceKey),
|
|
151
163
|
environment: [
|
|
152
164
|
`SERVICE_URL=http://${containerKeys[0]}:8080`,
|
|
@@ -190,19 +202,44 @@ const deleteDockerComposeFile = async (composeFile) => {
|
|
|
190
202
|
};
|
|
191
203
|
exports.deleteDockerComposeFile = deleteDockerComposeFile;
|
|
192
204
|
const startDockerComposeStack = async (dockerComposeFilePath, serviceKey, logger) => {
|
|
205
|
+
const pullOptions = {
|
|
206
|
+
cwd: path.dirname(dockerComposeFilePath),
|
|
207
|
+
log: true,
|
|
208
|
+
config: dockerComposeFilePath
|
|
209
|
+
};
|
|
193
210
|
try {
|
|
194
|
-
await (0, docker_compose_1.pullOne)(
|
|
195
|
-
cwd: path.dirname(dockerComposeFilePath),
|
|
196
|
-
log: true,
|
|
197
|
-
config: dockerComposeFilePath
|
|
198
|
-
});
|
|
211
|
+
await (0, docker_compose_1.pullOne)(PROXY_SIDECAR_SERVICE_NAME, pullOptions);
|
|
199
212
|
}
|
|
200
|
-
catch (
|
|
201
|
-
|
|
213
|
+
catch (portableRegistryError) {
|
|
214
|
+
logger.warn('Unable to pull the proxy sidecar image. Retrying from an alternate source...');
|
|
215
|
+
useEcrProxySidecarImage(dockerComposeFilePath);
|
|
216
|
+
try {
|
|
217
|
+
await (0, docker_compose_1.pullOne)(PROXY_SIDECAR_SERVICE_NAME, pullOptions);
|
|
218
|
+
}
|
|
219
|
+
catch (ecrRegistryError) {
|
|
220
|
+
throw new DockerUnableToPullProxySidecarImage(new Error(`Initial pull error: ${getDockerComposeErrorMessage(portableRegistryError)}. Retry error: ${getDockerComposeErrorMessage(ecrRegistryError)}`));
|
|
221
|
+
}
|
|
202
222
|
}
|
|
203
223
|
await waitForContainersToStart(dockerComposeFilePath, serviceKey, logger);
|
|
204
224
|
};
|
|
205
225
|
exports.startDockerComposeStack = startDockerComposeStack;
|
|
226
|
+
const getDockerComposeErrorMessage = (error) => {
|
|
227
|
+
if (error && typeof error === 'object') {
|
|
228
|
+
const dockerComposeError = error;
|
|
229
|
+
return dockerComposeError.err || dockerComposeError.out || dockerComposeError.message || 'Unknown Error Occurred.';
|
|
230
|
+
}
|
|
231
|
+
return error != null ? String(error) : 'Unknown Error Occurred.';
|
|
232
|
+
};
|
|
233
|
+
const useEcrProxySidecarImage = (dockerComposeFilePath) => {
|
|
234
|
+
const composeConfig = yaml.parse(fs.readFileSync(dockerComposeFilePath, 'utf8'));
|
|
235
|
+
const proxySidecar = composeConfig?.services?.[PROXY_SIDECAR_SERVICE_NAME];
|
|
236
|
+
if (!proxySidecar) {
|
|
237
|
+
throw new Error(`The Docker Compose file does not contain the ${PROXY_SIDECAR_SERVICE_NAME} service.`);
|
|
238
|
+
}
|
|
239
|
+
const ecrRegistry = getProxySidecarRegistry('ecr');
|
|
240
|
+
proxySidecar.image = `${ecrRegistry}/${PROXY_SIDECAR_IMAGE_PATH}`;
|
|
241
|
+
fs.writeFileSync(dockerComposeFilePath, yaml.stringify(composeConfig));
|
|
242
|
+
};
|
|
206
243
|
const determineComposeFlags = async (dockerComposeFilePath, serviceKey, logger) => {
|
|
207
244
|
const flags = ['--build', '--quiet-pull'];
|
|
208
245
|
try {
|
|
@@ -318,8 +355,7 @@ const waitForContainersToStart = async (dockerComposeFilePath, serviceKey, logge
|
|
|
318
355
|
callback: logFilter
|
|
319
356
|
}).catch((error) => {
|
|
320
357
|
clearTimeout(startupTimer);
|
|
321
|
-
|
|
322
|
-
reject(new DockerUnableToStartError(new Error(errorMessage)));
|
|
358
|
+
reject(new DockerUnableToStartError(new Error(getDockerComposeErrorMessage(error))));
|
|
323
359
|
});
|
|
324
360
|
setTimeout(async () => {
|
|
325
361
|
if (containersStarted)
|