@codedazur/cdk-next-app 0.1.0 → 0.2.0
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/CHANGELOG.md +11 -0
- package/README.md +15 -1
- package/dist/index.d.mts +7 -19
- package/dist/index.d.ts +7 -19
- package/dist/index.js +22 -53
- package/dist/index.mjs +12 -56
- package/package.json +13 -11
- package/tsconfig.json +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @codedazur/cdk-next-app
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`36a8727`](https://github.com/codedazur/toolkit/commit/36a87277e9150970420b6ac046f297653f95f087) Thanks [@thijsdaniels](https://github.com/thijsdaniels)! - The NextApp now uses a DockerCluster instead of an AmplifyApp. This completely changes the entire infrastructure and is a major breaking change.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`bcb3361`](https://github.com/codedazur/toolkit/commit/bcb33613b40edcfb0097d961fa16511035c18b83)]:
|
|
12
|
+
- @codedazur/cdk-docker-cluster@0.1.0
|
|
13
|
+
|
|
3
14
|
## 0.1.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# NextApp
|
|
2
|
+
|
|
3
|
+
The NextApp CDK construct deploys a standalone Next.js build to a load balanced Fargate service on AWS.
|
|
4
|
+
|
|
5
|
+
## Example
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
new NextApp(this, "Next", {
|
|
9
|
+
path: "../next", // Must contain a Dockerfile.
|
|
10
|
+
});
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Docker
|
|
14
|
+
|
|
15
|
+
In order to use this construct, your Next.js application needs to be configure for Docker deployments. See the [official documentation](https://nextjs.org/docs/pages/building-your-application/deploying#docker-image) for more information.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,26 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { BasicAuth, Branch, Environment, GitRegistry, GitSource, Redirect, RedirectStatus, Rewrite, RewriteStatus } from '@codedazur/cdk-amplify-app';
|
|
1
|
+
import { DockerClusterProps, DockerCluster } from '@codedazur/cdk-docker-cluster';
|
|
3
2
|
import { Construct } from 'constructs';
|
|
4
3
|
|
|
5
|
-
interface
|
|
4
|
+
interface NextDockerClusterProps extends DockerClusterProps {
|
|
6
5
|
}
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* ```
|
|
11
|
-
* {
|
|
12
|
-
* experimental: {
|
|
13
|
-
* outputFileTracingRoot: path.join(__dirname, "../../"),
|
|
14
|
-
* },
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
* assuming that the project root is at `"../../"` relative to the the
|
|
18
|
-
* `next.config.js` file.
|
|
19
|
-
* @see https://github.com/aws-amplify/amplify-hosting/issues/3179
|
|
20
|
-
* @see https://nextjs.org/docs/advanced-features/output-file-tracing#caveats
|
|
7
|
+
* A docker cluster preconfigured for running a Next.js application with support
|
|
8
|
+
* for private NPM packages using a build-time secret.
|
|
21
9
|
*/
|
|
22
|
-
declare class
|
|
23
|
-
constructor(scope: Construct, id: string, props:
|
|
10
|
+
declare class NextDockerCluster extends DockerCluster {
|
|
11
|
+
constructor(scope: Construct, id: string, { port, secrets, ...props }: NextDockerClusterProps);
|
|
24
12
|
}
|
|
25
13
|
|
|
26
|
-
export {
|
|
14
|
+
export { NextDockerCluster, NextDockerClusterProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { BasicAuth, Branch, Environment, GitRegistry, GitSource, Redirect, RedirectStatus, Rewrite, RewriteStatus } from '@codedazur/cdk-amplify-app';
|
|
1
|
+
import { DockerClusterProps, DockerCluster } from '@codedazur/cdk-docker-cluster';
|
|
3
2
|
import { Construct } from 'constructs';
|
|
4
3
|
|
|
5
|
-
interface
|
|
4
|
+
interface NextDockerClusterProps extends DockerClusterProps {
|
|
6
5
|
}
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* ```
|
|
11
|
-
* {
|
|
12
|
-
* experimental: {
|
|
13
|
-
* outputFileTracingRoot: path.join(__dirname, "../../"),
|
|
14
|
-
* },
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
* assuming that the project root is at `"../../"` relative to the the
|
|
18
|
-
* `next.config.js` file.
|
|
19
|
-
* @see https://github.com/aws-amplify/amplify-hosting/issues/3179
|
|
20
|
-
* @see https://nextjs.org/docs/advanced-features/output-file-tracing#caveats
|
|
7
|
+
* A docker cluster preconfigured for running a Next.js application with support
|
|
8
|
+
* for private NPM packages using a build-time secret.
|
|
21
9
|
*/
|
|
22
|
-
declare class
|
|
23
|
-
constructor(scope: Construct, id: string, props:
|
|
10
|
+
declare class NextDockerCluster extends DockerCluster {
|
|
11
|
+
constructor(scope: Construct, id: string, { port, secrets, ...props }: NextDockerClusterProps);
|
|
24
12
|
}
|
|
25
13
|
|
|
26
|
-
export {
|
|
14
|
+
export { NextDockerCluster, NextDockerClusterProps };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,74 +17,41 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
21
31
|
var src_exports = {};
|
|
22
32
|
__export(src_exports, {
|
|
23
|
-
|
|
33
|
+
NextDockerCluster: () => NextDockerCluster
|
|
24
34
|
});
|
|
25
35
|
module.exports = __toCommonJS(src_exports);
|
|
26
36
|
|
|
27
37
|
// src/constructs/NextApp.ts
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
|
|
38
|
+
var import_os = __toESM(require("os"));
|
|
39
|
+
var import_path = __toESM(require("path"));
|
|
40
|
+
var import_cdk_docker_cluster = require("@codedazur/cdk-docker-cluster");
|
|
41
|
+
var import_aws_cdk_lib = require("aws-cdk-lib");
|
|
42
|
+
var NextDockerCluster = class extends import_cdk_docker_cluster.DockerCluster {
|
|
43
|
+
constructor(scope, id, { port = 3e3, secrets, ...props }) {
|
|
31
44
|
super(scope, id, {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
applications: [
|
|
37
|
-
{
|
|
38
|
-
appRoot: props.source.directory,
|
|
39
|
-
frontend: {
|
|
40
|
-
phases: {
|
|
41
|
-
preBuild: {
|
|
42
|
-
commands: [
|
|
43
|
-
"npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}",
|
|
44
|
-
"npm install"
|
|
45
|
-
]
|
|
46
|
-
},
|
|
47
|
-
build: {
|
|
48
|
-
commands: ["npm run build"]
|
|
49
|
-
},
|
|
50
|
-
postBuild: {
|
|
51
|
-
commands: [
|
|
52
|
-
/**
|
|
53
|
-
* This command moves the Next.js `standalone` directory
|
|
54
|
-
* into the right location for AWS to recognize it.
|
|
55
|
-
* @todo Remove this command when AWS has implemented a fix.
|
|
56
|
-
* @see https://github.com/aws-amplify/amplify-hosting/issues/3179
|
|
57
|
-
*/
|
|
58
|
-
`cp -r .next/standalone/${props.source.directory}/. .next/standalone`
|
|
59
|
-
]
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
artifacts: {
|
|
63
|
-
baseDirectory: ".next",
|
|
64
|
-
files: ["**/*"]
|
|
65
|
-
},
|
|
66
|
-
cache: {
|
|
67
|
-
paths: ["node_modules/**/*"]
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
]
|
|
45
|
+
port,
|
|
46
|
+
secrets: {
|
|
47
|
+
npmrc: import_aws_cdk_lib.DockerBuildSecret.fromSrc(import_path.default.join(import_os.default.homedir(), "/.npmrc")),
|
|
48
|
+
...secrets
|
|
72
49
|
},
|
|
73
|
-
rewrites: [
|
|
74
|
-
{
|
|
75
|
-
source: "/<*>",
|
|
76
|
-
status: import_cdk_amplify_app.RewriteStatus.NOT_FOUND,
|
|
77
|
-
target: "/index.html"
|
|
78
|
-
},
|
|
79
|
-
...props.rewrites ?? []
|
|
80
|
-
],
|
|
81
50
|
...props
|
|
82
51
|
});
|
|
83
52
|
}
|
|
84
53
|
};
|
|
85
54
|
// Annotate the CommonJS export names for ESM import in node:
|
|
86
55
|
0 && (module.exports = {
|
|
87
|
-
|
|
56
|
+
NextDockerCluster
|
|
88
57
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,66 +1,22 @@
|
|
|
1
1
|
// src/constructs/NextApp.ts
|
|
2
|
+
import os from "os";
|
|
3
|
+
import path from "path";
|
|
2
4
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
var NextApp = class extends AmplifyApp {
|
|
9
|
-
constructor(scope, id, props) {
|
|
5
|
+
DockerCluster
|
|
6
|
+
} from "@codedazur/cdk-docker-cluster";
|
|
7
|
+
import { DockerBuildSecret } from "aws-cdk-lib";
|
|
8
|
+
var NextDockerCluster = class extends DockerCluster {
|
|
9
|
+
constructor(scope, id, { port = 3e3, secrets, ...props }) {
|
|
10
10
|
super(scope, id, {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
applications: [
|
|
16
|
-
{
|
|
17
|
-
appRoot: props.source.directory,
|
|
18
|
-
frontend: {
|
|
19
|
-
phases: {
|
|
20
|
-
preBuild: {
|
|
21
|
-
commands: [
|
|
22
|
-
"npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}",
|
|
23
|
-
"npm install"
|
|
24
|
-
]
|
|
25
|
-
},
|
|
26
|
-
build: {
|
|
27
|
-
commands: ["npm run build"]
|
|
28
|
-
},
|
|
29
|
-
postBuild: {
|
|
30
|
-
commands: [
|
|
31
|
-
/**
|
|
32
|
-
* This command moves the Next.js `standalone` directory
|
|
33
|
-
* into the right location for AWS to recognize it.
|
|
34
|
-
* @todo Remove this command when AWS has implemented a fix.
|
|
35
|
-
* @see https://github.com/aws-amplify/amplify-hosting/issues/3179
|
|
36
|
-
*/
|
|
37
|
-
`cp -r .next/standalone/${props.source.directory}/. .next/standalone`
|
|
38
|
-
]
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
artifacts: {
|
|
42
|
-
baseDirectory: ".next",
|
|
43
|
-
files: ["**/*"]
|
|
44
|
-
},
|
|
45
|
-
cache: {
|
|
46
|
-
paths: ["node_modules/**/*"]
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
]
|
|
11
|
+
port,
|
|
12
|
+
secrets: {
|
|
13
|
+
npmrc: DockerBuildSecret.fromSrc(path.join(os.homedir(), "/.npmrc")),
|
|
14
|
+
...secrets
|
|
51
15
|
},
|
|
52
|
-
rewrites: [
|
|
53
|
-
{
|
|
54
|
-
source: "/<*>",
|
|
55
|
-
status: RewriteStatus.NOT_FOUND,
|
|
56
|
-
target: "/index.html"
|
|
57
|
-
},
|
|
58
|
-
...props.rewrites ?? []
|
|
59
|
-
],
|
|
60
16
|
...props
|
|
61
17
|
});
|
|
62
18
|
}
|
|
63
19
|
};
|
|
64
20
|
export {
|
|
65
|
-
|
|
21
|
+
NextDockerCluster
|
|
66
22
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codedazur/cdk-next-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"main": ".dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -15,26 +15,28 @@
|
|
|
15
15
|
},
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"scripts": {
|
|
18
|
-
"
|
|
18
|
+
"develop": "tsup src/index.ts --format esm,cjs --dts --watch",
|
|
19
19
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
20
|
+
"audit": "npm audit --omit dev",
|
|
20
21
|
"lint": "TIMING=1 eslint \"**/*.ts*\"",
|
|
21
|
-
"
|
|
22
|
+
"types": "tsc --noEmit",
|
|
23
|
+
"test": "vitest run --passWithNoTests"
|
|
22
24
|
},
|
|
23
25
|
"dependencies": {
|
|
24
|
-
"@codedazur/cdk-
|
|
26
|
+
"@codedazur/cdk-docker-cluster": "*"
|
|
25
27
|
},
|
|
26
28
|
"peerDependencies": {
|
|
27
29
|
"aws-cdk-lib": ">=2",
|
|
28
30
|
"constructs": ">=10"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
33
|
+
"@codedazur/eslint-config": "*",
|
|
34
|
+
"@codedazur/tsconfig": "*",
|
|
35
|
+
"@types/node": "^20.12.8",
|
|
36
|
+
"aws-cdk-lib": "^2.139.1",
|
|
37
|
+
"constructs": "^10.3.0",
|
|
38
|
+
"esbuild": "^0.20.2",
|
|
35
39
|
"eslint": "^8.30.0",
|
|
36
|
-
"
|
|
37
|
-
"tsconfig": "*",
|
|
38
|
-
"typescript": "^4.9.4 || ^5.2.2"
|
|
40
|
+
"typescript": "^5.4.5"
|
|
39
41
|
}
|
|
40
42
|
}
|