@codedazur/cdk-next-app 0.1.0 → 0.2.1
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 +17 -0
- package/README.md +43 -1
- package/dist/index.d.mts +6 -18
- package/dist/index.d.ts +6 -18
- package/dist/index.js +20 -51
- package/dist/index.mjs +11 -55
- package/package.json +13 -11
- package/tsconfig.json +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @codedazur/cdk-next-app
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4aad27259400d8c8c4fd6825ee20ef970b6ad718`](https://github.com/codedazur/toolkit/commit/4aad27259400d8c8c4fd6825ee20ef970b6ad718) Thanks [@thijsdaniels](https://github.com/thijsdaniels)! - The construct name was corrected.
|
|
8
|
+
|
|
9
|
+
## 0.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`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.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`bcb3361`](https://github.com/codedazur/toolkit/commit/bcb33613b40edcfb0097d961fa16511035c18b83)]:
|
|
18
|
+
- @codedazur/cdk-docker-cluster@0.1.0
|
|
19
|
+
|
|
3
20
|
## 0.1.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1 +1,43 @@
|
|
|
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
|
+
### Standard Repository
|
|
8
|
+
|
|
9
|
+
For a non-mnonorepo build, simply provide the path to the directory that contains your Dockerfile.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
new NextApp(this, "NextApp", {
|
|
13
|
+
path: "../next",
|
|
14
|
+
});
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Monorepo
|
|
18
|
+
|
|
19
|
+
For monorepo builds, set the build context to the root of your monorepo, and provide the path to your Next.js module's Dockerfile.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
new NextApp(this, "NextApp", {
|
|
23
|
+
path: "../../",
|
|
24
|
+
file: "apps/next/Dockerfile",
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Scaling
|
|
29
|
+
|
|
30
|
+
The NextApp is based on the [DockerCluster](https://github.com/codedazur/toolkit/tree/main/packages/cdk-docker-cluster) construct and supports all of its features for horizontal and vertical scaling.
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
new NextApp(this, "NextApp", {
|
|
34
|
+
...
|
|
35
|
+
cpu: 1024,
|
|
36
|
+
memory: 4096,
|
|
37
|
+
tasks: { min: 1, max: 10 },
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Docker
|
|
42
|
+
|
|
43
|
+
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 NextAppProps extends
|
|
4
|
+
interface NextAppProps 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 NextApp extends
|
|
23
|
-
constructor(scope: Construct, id: string, props: NextAppProps);
|
|
10
|
+
declare class NextApp extends DockerCluster {
|
|
11
|
+
constructor(scope: Construct, id: string, { port, secrets, ...props }: NextAppProps);
|
|
24
12
|
}
|
|
25
13
|
|
|
26
14
|
export { NextApp, NextAppProps };
|
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 NextAppProps extends
|
|
4
|
+
interface NextAppProps 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 NextApp extends
|
|
23
|
-
constructor(scope: Construct, id: string, props: NextAppProps);
|
|
10
|
+
declare class NextApp extends DockerCluster {
|
|
11
|
+
constructor(scope: Construct, id: string, { port, secrets, ...props }: NextAppProps);
|
|
24
12
|
}
|
|
25
13
|
|
|
26
14
|
export { NextApp, NextAppProps };
|
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,6 +17,14 @@ 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
|
|
@@ -25,59 +35,18 @@ __export(src_exports, {
|
|
|
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 NextApp = 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
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,62 +1,18 @@
|
|
|
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 NextApp = 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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codedazur/cdk-next-app",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
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.14.2",
|
|
36
|
+
"aws-cdk-lib": "^2.145.0",
|
|
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
|
}
|