@payfit/nx-core 4.19.1-ephemeral-fix-hard-coded-paths.8 → 4.19.1-ephemeral-fix-hard-coded-paths.10
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 +7 -4
- package/src/executors/publisher/docker.js.map +1 -1
- package/src/executors/publisher/schema.d.ts +1 -0
- package/src/executors/publisher/schema.json +5 -0
- package/src/utils/aws-auth.d.ts +16 -2
- package/src/utils/aws-auth.js +20 -4
- package/src/utils/aws-auth.js.map +1 -1
- package/src/utils/constants.d.ts +7 -0
- package/src/utils/constants.js +11 -0
- package/src/utils/constants.js.map +1 -0
- package/src/utils/docker.d.ts +2 -1
- package/src/utils/docker.js +4 -2
- package/src/utils/docker.js.map +1 -1
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ exports.publishDocker = publishDocker;
|
|
|
4
4
|
const fs = require("node:fs");
|
|
5
5
|
const consola_1 = require("consola");
|
|
6
6
|
const aws_auth_1 = require("../../utils/aws-auth");
|
|
7
|
+
const constants_1 = require("../../utils/constants");
|
|
7
8
|
const docker_1 = require("../../utils/docker");
|
|
8
9
|
const github_1 = require("../../utils/github");
|
|
9
10
|
async function publishDocker(options, context, version, projectRoot) {
|
|
@@ -20,12 +21,14 @@ async function publishDocker(options, context, version, projectRoot) {
|
|
|
20
21
|
success: false,
|
|
21
22
|
};
|
|
22
23
|
}
|
|
24
|
+
// Determine which registry to use based on isPublicRegistry option
|
|
25
|
+
const registryPrefix = options.isPublicRegistry ? constants_1.PUBLIC_ECR_REGISTRY : process.env.AWS_ECR_REGISTRY;
|
|
23
26
|
await (0, aws_auth_1.checkAwsAuth)();
|
|
24
|
-
await (0, aws_auth_1.loginToEcr)();
|
|
27
|
+
await (0, aws_auth_1.loginToEcr)(options.isPublicRegistry ? constants_1.PUBLIC_ECR_REGISTRY : undefined);
|
|
25
28
|
consola_1.consola.start('Building docker image with version ' + version);
|
|
26
|
-
await (0, docker_1.buildDockerImage)(options.ecrRegistry, projectDockerfile, version, await (0, github_1.getSanitizedCurrentGitRepoUrl)(), await (0, github_1.getCurrentGitCommitSha)());
|
|
27
|
-
consola_1.consola.log(`Publishing docker image to ${options.ecrRegistry} with version ${version}`);
|
|
28
|
-
await (0, aws_auth_1.pushImageToEcr)(options.ecrRegistry, version);
|
|
29
|
+
await (0, docker_1.buildDockerImage)(options.ecrRegistry, projectDockerfile, version, await (0, github_1.getSanitizedCurrentGitRepoUrl)(), await (0, github_1.getCurrentGitCommitSha)(), registryPrefix);
|
|
30
|
+
consola_1.consola.log(`Publishing docker image to ${options.isPublicRegistry ? constants_1.PUBLIC_ECR_REGISTRY : process.env.AWS_ECR_REGISTRY}/${options.ecrRegistry} with version ${version}`);
|
|
31
|
+
await (0, aws_auth_1.pushImageToEcr)(options.ecrRegistry, version, registryPrefix);
|
|
29
32
|
consola_1.consola.success('Published the Docker image successfully!');
|
|
30
33
|
return {
|
|
31
34
|
success: true,
|
|
@@ -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":";;AAcA,sCAmDC;AAjED,8BAA6B;AAG7B,qCAAiC;AAEjC,mDAA+E;AAC/E,qDAA2D;AAC3D,+CAAqD;AACrD,+CAG2B;AAGpB,KAAK,UAAU,aAAa,CACjC,OAAiC,EACjC,OAAwB,EACxB,OAAe,EACf,WAAmB;IAInB,MAAM,iBAAiB,GAAG,GAAG,WAAW,aAAa,CAAA;IAErD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACtC,iBAAO,CAAC,IAAI,CAAC,2BAA2B,iBAAiB,gBAAgB,CAAC,CAAA;QAC1E,OAAO;YACL,OAAO,E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20
|
+
"isPublicRegistry": {
|
|
21
|
+
"type": "boolean",
|
|
22
|
+
"description": "Whether to use the public ECR registry",
|
|
23
|
+
"default": false
|
|
19
24
|
}
|
|
20
25
|
},
|
|
21
26
|
"required": []
|
package/src/utils/aws-auth.d.ts
CHANGED
|
@@ -24,7 +24,13 @@ export declare function getAwsCredentialsSet(): {
|
|
|
24
24
|
* @return {Promise<string | boolean>} The authentication details if the profile exists, or false if the profile does not exist.
|
|
25
25
|
*/
|
|
26
26
|
export declare function getAuthWithOidcProfile(): Promise<string | boolean>;
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Login to ECR using the specified registry or the AWS_ECR_REGISTRY environment variable
|
|
29
|
+
*
|
|
30
|
+
* @param registryPrefix - The registry prefix to use, defaults to AWS_ECR_REGISTRY environment variable
|
|
31
|
+
* @returns A promise that resolves to the result of the login command
|
|
32
|
+
*/
|
|
33
|
+
export declare function loginToEcr(registryPrefix?: string): Promise<{
|
|
28
34
|
success: boolean;
|
|
29
35
|
stdout: string;
|
|
30
36
|
stderr: string;
|
|
@@ -34,6 +40,14 @@ export declare function loginToEcr(): Promise<{
|
|
|
34
40
|
* @returns {string} the profile's name
|
|
35
41
|
*/
|
|
36
42
|
export declare function checkAwsAuth(): Promise<string>;
|
|
37
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Push a Docker image to ECR
|
|
45
|
+
*
|
|
46
|
+
* @param repositoryName - The name of the repository
|
|
47
|
+
* @param version - The version of the image
|
|
48
|
+
* @param registryPrefix - The registry prefix to use, defaults to AWS_ECR_REGISTRY environment variable
|
|
49
|
+
* @returns A promise that resolves to the result of the push command
|
|
50
|
+
*/
|
|
51
|
+
export declare function pushImageToEcr(repositoryName: string, version: string, registryPrefix?: string): Promise<{
|
|
38
52
|
success: boolean;
|
|
39
53
|
}>;
|
package/src/utils/aws-auth.js
CHANGED
|
@@ -56,8 +56,15 @@ async function getAuthWithOidcProfile() {
|
|
|
56
56
|
return false;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Login to ECR using the specified registry or the AWS_ECR_REGISTRY environment variable
|
|
61
|
+
*
|
|
62
|
+
* @param registryPrefix - The registry prefix to use, defaults to AWS_ECR_REGISTRY environment variable
|
|
63
|
+
* @returns A promise that resolves to the result of the login command
|
|
64
|
+
*/
|
|
65
|
+
async function loginToEcr(registryPrefix) {
|
|
66
|
+
const registry = registryPrefix || process.env.AWS_ECR_REGISTRY;
|
|
67
|
+
return (0, exec_1.exec_command)(`aws ecr get-login-password --profile ${profileName} --region eu-west-3 | ${await (0, docker_1.getDockerOrPodman)()} login --username AWS --password-stdin ${registry}`);
|
|
61
68
|
}
|
|
62
69
|
/**
|
|
63
70
|
* Check AWS CLI with the OIDC profile otherwise use the default credentials
|
|
@@ -78,7 +85,16 @@ async function checkAwsAuth() {
|
|
|
78
85
|
}
|
|
79
86
|
return profileName;
|
|
80
87
|
}
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Push a Docker image to ECR
|
|
90
|
+
*
|
|
91
|
+
* @param repositoryName - The name of the repository
|
|
92
|
+
* @param version - The version of the image
|
|
93
|
+
* @param registryPrefix - The registry prefix to use, defaults to AWS_ECR_REGISTRY environment variable
|
|
94
|
+
* @returns A promise that resolves to the result of the push command
|
|
95
|
+
*/
|
|
96
|
+
function pushImageToEcr(repositoryName, version, registryPrefix) {
|
|
97
|
+
const registry = registryPrefix || process.env.AWS_ECR_REGISTRY;
|
|
98
|
+
return (0, exec_1.exec_command)(`docker push ${registry}/${repositoryName}:${version}`);
|
|
83
99
|
}
|
|
84
100
|
//# sourceMappingURL=aws-auth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aws-auth.js","sourceRoot":"","sources":["../../../../../packages/nx-core/src/utils/aws-auth.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"aws-auth.js","sourceRoot":"","sources":["../../../../../pack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AAc,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAA;IAC/D,OAAO,IAAA,mBAAY,EACjB,wCAAwC,WAAW,yBAAyB,MAAM,IAAA,0BAAiB,GAAE,0CAA0C,QAAQ,EAAE,CAC1J,CAAA;AACH,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,YAAY;IAChC,MAAM,YAAY,GAAG,MAAM,sBAAsB,EAAE,CAAA;IACnD,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAA;QAC3C,WAAW,GAAG,cAAc,CAAA;IAC9B,CAAC;SAAM,IAAI,oBAAoB,EAAE,EAAE,CAAC;QAClC,OAAO,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;AAED;;;;;;;GAOG;AACH,SAAgB,cAAc,CAC5B,cAAsB,EACtB,OAAe,EACf,cAAuB;IAEvB,MAAM,QAAQ,GAAG,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAA;IAC/D,OAAO,IAAA,mBAAY,EACjB,eAAe,QAAQ,IAAI,cAAc,IAAI,OAAO,EAAE,CACvD,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Constants used throughout the nx-core package
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PUBLIC_ECR_REGISTRY = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* The public ECR registry URL
|
|
9
|
+
*/
|
|
10
|
+
exports.PUBLIC_ECR_REGISTRY = 'public.ecr.aws/payfit';
|
|
11
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages/nx-core/src/utils/constants.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH;;GAEG;AACU,QAAA,mBAAmB,GAAG,uBAAuB,CAAA"}
|
package/src/utils/docker.d.ts
CHANGED
|
@@ -12,9 +12,10 @@ export declare function getDockerOrPodman(): Promise<string>;
|
|
|
12
12
|
* @param version
|
|
13
13
|
* @param gitRepoUrl
|
|
14
14
|
* @param commitSha
|
|
15
|
+
* @param registryPrefix - The registry prefix to use, defaults to AWS_ECR_REGISTRY environment variable
|
|
15
16
|
* @return {Promise<{success: boolean, stdout: string, stderr: string}>} A promise that resolves to an object containing the success status, stdout, and stderr of the command.
|
|
16
17
|
*/
|
|
17
|
-
export declare function buildDockerImage(imageName: string, dockerfilePath: string, version: string, gitRepoUrl: string, commitSha: string): Promise<{
|
|
18
|
+
export declare function buildDockerImage(imageName: string, dockerfilePath: string, version: string, gitRepoUrl: string, commitSha: string, registryPrefix?: string): Promise<{
|
|
18
19
|
success: boolean;
|
|
19
20
|
stdout: string;
|
|
20
21
|
stderr: string;
|
package/src/utils/docker.js
CHANGED
|
@@ -26,10 +26,12 @@ async function getDockerOrPodman() {
|
|
|
26
26
|
* @param version
|
|
27
27
|
* @param gitRepoUrl
|
|
28
28
|
* @param commitSha
|
|
29
|
+
* @param registryPrefix - The registry prefix to use, defaults to AWS_ECR_REGISTRY environment variable
|
|
29
30
|
* @return {Promise<{success: boolean, stdout: string, stderr: string}>} A promise that resolves to an object containing the success status, stdout, and stderr of the command.
|
|
30
31
|
*/
|
|
31
|
-
async function buildDockerImage(imageName, dockerfilePath, version, gitRepoUrl, commitSha) {
|
|
32
|
+
async function buildDockerImage(imageName, dockerfilePath, version, gitRepoUrl, commitSha, registryPrefix) {
|
|
32
33
|
const dockerOrPodman = await getDockerOrPodman();
|
|
33
|
-
|
|
34
|
+
const registry = registryPrefix || process.env.AWS_ECR_REGISTRY;
|
|
35
|
+
return (0, exec_1.exec_command)(`${dockerOrPodman} buildx build -t ${registry}/${imageName}:${version} -f ${dockerfilePath} --secret id=NPM_TOKEN . --annotation org.opencontainers.image.source=${gitRepoUrl} --annotation org.opencontainers.image.revision=${commitSha} --build-arg DD_GIT_REPOSITORY_URL=${gitRepoUrl} --build-arg DD_GIT_COMMIT_SHA=${commitSha}`);
|
|
34
36
|
}
|
|
35
37
|
//# sourceMappingURL=docker.js.map
|
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":";;AAQA,8CAQC;AAaD,4CAaC;AAzCD,iCAAqC;AAErC;;;;GAIG;AACI,KAAK,UAAU,iBAAiB;IACrC,IAAI,CAAC;QACH,MAAM,IAAA,mBAAY,EAAC,kBAAkB,CAAC,CAAA;QACtC,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,cAAuB;IAEvB,MAAM,cAAc,GAAG,MAAM,iBAAiB,EAAE,CAAA;IAChD,MAAM,QAAQ,GAAG,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAA;IAC/D,OAAO,IAAA,mBAAY,EACjB,GAAG,cAAc,oBAAoB,QAAQ,IAAI,SAAS,IAAI,OAAO,OAAO,cAAc,yEAAyE,UAAU,mDAAmD,SAAS,sCAAsC,UAAU,kCAAkC,SAAS,EAAE,CACvU,CAAA;AACH,CAAC"}
|