@payfit/nx-core 4.32.2-ephemeral-log-docker-dc0e8a4.0 → 4.32.2
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 +1 -1
- package/src/executors/publisher/docker.js +0 -13
- package/src/executors/publisher/docker.js.map +1 -1
- package/src/generators/init/files/.circleci/config.yml +2 -2
- package/src/utils/aws-auth.d.ts +0 -7
- package/src/utils/aws-auth.js +1 -72
- package/src/utils/aws-auth.js.map +1 -1
- package/src/utils/docker.js +1 -15
- package/src/utils/docker.js.map +1 -1
package/package.json
CHANGED
|
@@ -23,19 +23,6 @@ async function publishDocker(options, context, version, projectRoot) {
|
|
|
23
23
|
: process.env.AWS_ECR_REGISTRY;
|
|
24
24
|
await (0, aws_auth_1.checkAwsAuth)();
|
|
25
25
|
await (0, aws_auth_1.loginToEcr)(registry);
|
|
26
|
-
// Verify that we have valid ECR credentials before proceeding
|
|
27
|
-
const hasValidCredentials = await (0, aws_auth_1.verifyEcrCredentials)(registry);
|
|
28
|
-
if (!hasValidCredentials) {
|
|
29
|
-
logger_1.consola.warn('ECR credentials verification failed. Attempting to login again...');
|
|
30
|
-
// Try logging in again
|
|
31
|
-
await (0, aws_auth_1.loginToEcr)(registry);
|
|
32
|
-
// Verify credentials again
|
|
33
|
-
const retryCredentials = await (0, aws_auth_1.verifyEcrCredentials)(registry);
|
|
34
|
-
if (!retryCredentials) {
|
|
35
|
-
logger_1.consola.error('Failed to obtain valid ECR credentials after retry. Cannot push Docker image.');
|
|
36
|
-
throw new Error('No valid ECR credentials available for pushing Docker image');
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
26
|
logger_1.consola.box(`Publishing docker image to ${registry}/${options.ecrRegistry} with version ${version}`);
|
|
40
27
|
logger_1.consola.start('Building docker image');
|
|
41
28
|
await (0, docker_1.buildDockerImage)(options.ecrRegistry, projectDockerfile, version, await (0, github_1.getSanitizedCurrentGitRepoUrl)(), await (0, github_1.getCurrentGitCommitSha)(), registry);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../../../../../../packages/nx-core/src/executors/publisher/docker.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../../../../../../packages/nx-core/src/executors/publisher/docker.ts"],"names":[],"mappings":";;AAkBA,sCAqDC;AAvED,8BAA6B;AAI7B,mDAA+D;AAC/D,qDAA2D;AAC3D,+CAI2B;AAC3B,+CAG2B;AAC3B,+CAA4C;AAGrC,KAAK,UAAU,aAAa,CACjC,OAAiC,EACjC,OAAwB,EACxB,OAAe,EACf,WAAmB;IAEnB,MAAM,iBAAiB,GAAG,GAAG,WAAW,aAAa,CAAA;IAErD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACtC,gBAAO,CAAC,IAAI,CAAC,2BAA2B,iBAAiB,YAAY,CAAC,CAAA;QACtE,OAAM;IACR,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACzB,gBAAO,CAAC,KAAK,CACX,mGAAmG,CACpG,CAAA;QACD,OAAM;IACR,CAAC;IAED,mEAAmE;IACnE,MAAM,QAAQ,GAAG,OAAO,CAAC,gBAAgB;QACvC,CAAC,CAAC,+BAAmB;QACrB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAA;IAEhC,MAAM,IAAA,uBAAY,GAAE,CAAA;IACpB,MAAM,IAAA,qBAAU,EAAC,QAAQ,CAAC,CAAA;IAE1B,gBAAO,CAAC,GAAG,CACT,8BAA8B,QAAQ,IAAI,OAAO,CAAC,WAAW,iBAAiB,OAAO,EAAE,CACxF,CAAA;IAED,gBAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAA;IACtC,MAAM,IAAA,yBAAgB,EACpB,OAAO,CAAC,WAAW,EACnB,iBAAiB,EACjB,OAAO,EACP,MAAM,IAAA,sCAA6B,GAAE,EACrC,MAAM,IAAA,+BAAsB,GAAE,EAC9B,QAAQ,CACT,CAAA;IACD,gBAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAA;IAEtC,gBAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACrC,MAAM,IAAA,uBAAc,EAAC,OAAO,CAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;IAC5D,gBAAO,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAA;IAEpD,wFAAwF;IACxF,IAAI,OAAO,CAAC,gBAAgB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/D,gBAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAA;QAC/C,MAAM,IAAA,uBAAc,EAAC,OAAO,CAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;QAC5D,MAAM,IAAA,uBAAc,EAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;QAC7D,gBAAO,CAAC,OAAO,CAAC,6CAA6C,CAAC,CAAA;IAChE,CAAC;AACH,CAAC"}
|
|
@@ -15,7 +15,7 @@ orbs:
|
|
|
15
15
|
references:
|
|
16
16
|
setup_env_node: &setup_env_node
|
|
17
17
|
docker:
|
|
18
|
-
- image: cimg/node:22.
|
|
18
|
+
- image: cimg/node:22.16
|
|
19
19
|
setup_env_machine: &setup_env_machine # Used for getting docker cli
|
|
20
20
|
machine:
|
|
21
21
|
image: ubuntu-2204:current
|
|
@@ -28,7 +28,7 @@ references:
|
|
|
28
28
|
nx/set-shas: &nx_set_shas_option
|
|
29
29
|
error-on-no-successful-workflow: false
|
|
30
30
|
main-branch-name: main
|
|
31
|
-
workflow-name: build-test-
|
|
31
|
+
workflow-name: build-test-deploy
|
|
32
32
|
<% if (keepContinuationJobs) { %>
|
|
33
33
|
only_main_and_deploy_branches: &only_main_and_deploy_branches
|
|
34
34
|
branches:
|
package/src/utils/aws-auth.d.ts
CHANGED
|
@@ -32,13 +32,6 @@ export declare function getAuthWithOidcProfile(): Promise<string | boolean>;
|
|
|
32
32
|
* @returns A promise that resolves to the result of the login command
|
|
33
33
|
*/
|
|
34
34
|
export declare function loginToEcr(registry: string): Promise<Result>;
|
|
35
|
-
/**
|
|
36
|
-
* Verify that we have valid ECR credentials by checking the Docker config file
|
|
37
|
-
*
|
|
38
|
-
* @param registry The ECR registry to verify credentials for
|
|
39
|
-
* @returns A promise that resolves to true if credentials are valid, false otherwise
|
|
40
|
-
*/
|
|
41
|
-
export declare function verifyEcrCredentials(registry: string): Promise<boolean>;
|
|
42
35
|
/**
|
|
43
36
|
* Check AWS CLI with the OIDC profile otherwise use the default credentials
|
|
44
37
|
* @returns {string} the profile's name
|
package/src/utils/aws-auth.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.getProfileName = getProfileName;
|
|
|
4
4
|
exports.getAwsCredentialsSet = getAwsCredentialsSet;
|
|
5
5
|
exports.getAuthWithOidcProfile = getAuthWithOidcProfile;
|
|
6
6
|
exports.loginToEcr = loginToEcr;
|
|
7
|
-
exports.verifyEcrCredentials = verifyEcrCredentials;
|
|
8
7
|
exports.checkAwsAuth = checkAwsAuth;
|
|
9
8
|
const consola_1 = require("consola");
|
|
10
9
|
const constants_1 = require("./constants");
|
|
@@ -71,77 +70,7 @@ async function loginToEcr(registry) {
|
|
|
71
70
|
ecrCommand = `aws ecr-public get-login-password --region us-east-1`;
|
|
72
71
|
registry = registry.split('/')[0]; // Remove the repository part for public ECR
|
|
73
72
|
}
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
const result = await (0, exec_1.exec)(ecrCommand, { throwOnError: true }).pipe(await (0, docker_1.getDockerOrPodman)(), `login --username AWS --password-stdin ${registry}`.split(' '));
|
|
77
|
-
consola_1.consola.success(`Successfully logged in to ECR registry: ${registry}`);
|
|
78
|
-
return result;
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
consola_1.consola.error(`Failed to login to ECR registry: ${registry}`);
|
|
82
|
-
consola_1.consola.error(error);
|
|
83
|
-
throw error;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Verify that we have valid ECR credentials by checking the Docker config file
|
|
88
|
-
*
|
|
89
|
-
* @param registry The ECR registry to verify credentials for
|
|
90
|
-
* @returns A promise that resolves to true if credentials are valid, false otherwise
|
|
91
|
-
*/
|
|
92
|
-
async function verifyEcrCredentials(registry) {
|
|
93
|
-
if (!registry) {
|
|
94
|
-
consola_1.consola.error('No ECR registry provided for credential verification');
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
const dockerOrPodman = await (0, docker_1.getDockerOrPodman)();
|
|
98
|
-
try {
|
|
99
|
-
consola_1.consola.log(`Verifying ECR credentials for registry: ${registry}`);
|
|
100
|
-
// Check if we're using Docker or Podman
|
|
101
|
-
if (dockerOrPodman === 'docker') {
|
|
102
|
-
// For Docker, check the config.json file
|
|
103
|
-
const fs = require('fs');
|
|
104
|
-
const path = require('path');
|
|
105
|
-
const os = require('os');
|
|
106
|
-
// Docker config file path
|
|
107
|
-
const configPath = path.join(os.homedir(), '.docker', 'config.json');
|
|
108
|
-
// Check if the config file exists
|
|
109
|
-
if (!fs.existsSync(configPath)) {
|
|
110
|
-
consola_1.consola.error('Docker config file not found');
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
// Read and parse the config file
|
|
114
|
-
const configContent = fs.readFileSync(configPath, 'utf8');
|
|
115
|
-
const config = JSON.parse(configContent);
|
|
116
|
-
// Check if the registry is in the auths section
|
|
117
|
-
if (config.auths && config.auths[registry]) {
|
|
118
|
-
consola_1.consola.success(`ECR credentials verified for registry: ${registry}`);
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
consola_1.consola.error(`ECR credentials verification failed: No authentication found for ${registry}`);
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
// For Podman, we might need a different approach
|
|
128
|
-
// For now, we'll use a simple check to see if we can list images from the registry
|
|
129
|
-
const result = await (0, exec_1.exec)(`${dockerOrPodman} login --get-login ${registry}`, { throwOnError: false });
|
|
130
|
-
if (result.exitCode === 0) {
|
|
131
|
-
consola_1.consola.success(`ECR credentials verified for registry: ${registry}`);
|
|
132
|
-
return true;
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
consola_1.consola.error(`ECR credentials verification failed for registry: ${registry}`);
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
consola_1.consola.error(`ECR credentials verification failed with unexpected error`);
|
|
142
|
-
consola_1.consola.error(error);
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
73
|
+
return (0, exec_1.exec)(ecrCommand).pipe(await (0, docker_1.getDockerOrPodman)(), `login --username AWS --password-stdin ${registry}`.split(' '));
|
|
145
74
|
}
|
|
146
75
|
/**
|
|
147
76
|
* Check AWS CLI with the OIDC profile otherwise use the default credentials
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aws-auth.js","sourceRoot":"","sources":["../../../../../packages/nx-core/src/utils/aws-auth.ts"],"names":[],"mappings":";;AAYA,wCAEC;AAYD,oDAmBC;AAQD,wDAUC;AAQD,
|
|
1
|
+
{"version":3,"file":"aws-auth.js","sourceRoot":"","sources":["../../../../../packages/nx-core/src/utils/aws-auth.ts"],"names":[],"mappings":";;AAYA,wCAEC;AAYD,oDAmBC;AAQD,wDAUC;AAQD,gCAkBC;AAMD,oCAgBC;AA/GD,qCAAiC;AAGjC,2CAAiD;AACjD,qCAA4C;AAC5C,iCAA6B;AAE7B,IAAI,WAAW,GAAG,cAAc,CAAA;AAEhC;;GAEG;AACH,SAAgB,cAAc;IAC5B,OAAO,WAAW,CAAA;AACpB,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,oBAAo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AC,CAAA,CAAC,4CAA4C;IAChF,CAAC;IACD,OAAO,IAAA,WAAI,EAAC,UAAU,CAAC,CAAC,IAAI,CAC1B,MAAM,IAAA,0BAAiB,GAAE,EACzB,yCAAyC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAC/D,CAAA;AACH,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,YAAY;IAChC,MAAM,YAAY,GAAG,MAAM,sBAAsB,EAAE,CAAA;IACnD,IAAI,YAAY,EAAE,CAAC;QACjB,iBAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAA;QAC3C,WAAW,GAAG,cAAc,CAAA;IAC9B,CAAC;SAAM,IAAI,oBAAoB,EAAE,EAAE,CAAC;QAClC,iBAAO,CAAC,GAAG,CACT,oEAAoE,CACrE,CAAA;QACD,WAAW,GAAG,SAAS,CAAA;IACzB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CACb,iLAAiL,CAClL,CAAA;IACH,CAAC;IACD,OAAO,WAAW,CAAA;AACpB,CAAC"}
|
package/src/utils/docker.js
CHANGED
|
@@ -5,7 +5,6 @@ exports.buildDockerImage = buildDockerImage;
|
|
|
5
5
|
exports.pushImageToEcr = pushImageToEcr;
|
|
6
6
|
exports.tagLatestImage = tagLatestImage;
|
|
7
7
|
const exec_1 = require("./exec");
|
|
8
|
-
const logger_1 = require("./logger");
|
|
9
8
|
/**
|
|
10
9
|
* Determines the available container management tool by checking for Docker and fallback to Podman if Docker is unavailable.
|
|
11
10
|
*
|
|
@@ -51,20 +50,7 @@ async function buildDockerImage(imageName, dockerfilePath, version, gitRepoUrl,
|
|
|
51
50
|
*/
|
|
52
51
|
async function pushImageToEcr(repositoryName, version, registry) {
|
|
53
52
|
const dockerOrPodman = await getDockerOrPodman();
|
|
54
|
-
|
|
55
|
-
return await (0, exec_1.exec)(`${dockerOrPodman} push ${registry}/${repositoryName}:${version}`, { throwOnError: true });
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
// Check if the error is related to authentication
|
|
59
|
-
const errorMessage = error.toString();
|
|
60
|
-
if (errorMessage.includes('no basic auth credentials')) {
|
|
61
|
-
logger_1.consola.error('Authentication error when pushing to ECR. Your Docker credentials may have expired.');
|
|
62
|
-
logger_1.consola.error('Please ensure you are properly authenticated with ECR before pushing images.');
|
|
63
|
-
throw new Error(`Failed to push image due to authentication error: ${errorMessage}`);
|
|
64
|
-
}
|
|
65
|
-
// Re-throw the original error for other types of errors
|
|
66
|
-
throw error;
|
|
67
|
-
}
|
|
53
|
+
return (0, exec_1.exec)(`${dockerOrPodman} push ${registry}/${repositoryName}:${version}`);
|
|
68
54
|
}
|
|
69
55
|
async function tagLatestImage(repositoryName, version, registry) {
|
|
70
56
|
const dockerOrPodman = await getDockerOrPodman();
|
package/src/utils/docker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../../../../../packages/nx-core/src/utils/docker.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../../../../../packages/nx-core/src/utils/docker.ts"],"names":[],"mappings":";;AASA,8CAQC;AAaD,4CAkBC;AAUD,wCAOC;AAED,wCASC;AA1ED,iCAA6B;AAE7B;;;;GAIG;AACI,KAAK,UAAU,iBAAiB;IACrC,IAAI,CAAC;QACH,MAAM,IAAA,WAAI,EAAC,kBAAkB,CAAC,CAAA;QAC9B,OAAO,QAAQ,CAAA;IACjB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAA;QAC9C,OAAO,QAAQ,CAAA;IACjB,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACI,KAAK,UAAU,gBAAgB,CACpC,SAAiB,EACjB,cAAsB,EACtB,OAAe,EACf,UAAkB,EAClB,SAAiB,EACjB,QAAgB;IAEhB,MAAM,cAAc,GAAG,MAAM,iBAAiB,EA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