@codedazur/cdk-next-app 0.2.2 → 0.2.3

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @codedazur/cdk-next-app
2
2
 
3
+ ## 0.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`17034ee`](https://github.com/codedazur/toolkit/commit/17034ee5fcbc026fc779a12130572d515d2b8298) Thanks [@thijsdaniels](https://github.com/thijsdaniels)! - Dependency versions were made explicit.
8
+
9
+ - Updated dependencies [[`d1f3d51`](https://github.com/codedazur/toolkit/commit/d1f3d512d31d659ffdc115147d9631057fe8d073), [`17034ee`](https://github.com/codedazur/toolkit/commit/17034ee5fcbc026fc779a12130572d515d2b8298), [`737fe0d`](https://github.com/codedazur/toolkit/commit/737fe0ddd4d353db1e005d2dab886a4a60bc02d8)]:
10
+ - @codedazur/cdk-docker-cluster@0.5.0
11
+
3
12
  ## 0.2.2
4
13
 
5
14
  ### Patch Changes
package/README.md CHANGED
@@ -16,13 +16,13 @@ Your `next.config.js` file needs to be configured for standalone output.
16
16
  const nextConfig = {
17
17
  // ...
18
18
  output: "standalone",
19
- }
19
+ };
20
20
  // ...
21
21
  ```
22
22
 
23
23
  ### Docker
24
24
 
25
- 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.
25
+ In order to use this construct, your Next.js application needs to be configured for Docker deployments. See the [official documentation](https://nextjs.org/docs/pages/building-your-application/deploying#docker-image) for more information.
26
26
 
27
27
  ## Example
28
28
 
@@ -32,7 +32,7 @@ For a non-monorepo build, simply provide the path to the directory that contains
32
32
 
33
33
  ```ts
34
34
  new NextApp(this, "NextApp", {
35
- path: "../next",
35
+ source: "../next",
36
36
  });
37
37
  ```
38
38
 
@@ -42,20 +42,54 @@ For monorepo builds, set the build context to the root of your monorepo, and pro
42
42
 
43
43
  ```ts
44
44
  new NextApp(this, "NextApp", {
45
- path: "../../",
46
- file: "apps/next/Dockerfile",
45
+ source: {
46
+ directory: "../../",
47
+ file: "apps/next/Dockerfile",
48
+ },
49
+ });
50
+ ```
51
+
52
+ ### Arguments and Secrets
53
+
54
+ 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 related to Docker's build arguments and secrets.
55
+
56
+ These arguments and secrets need to be handled appropriately by your Dockerfile in order for them to have any effect.
57
+
58
+ ```ts
59
+ import { DockerBuildSecret } from "aws-cdk-lib";
60
+
61
+ new NextApp(this, "NextApp", {
62
+ source: {
63
+ // ...
64
+ arguments: {
65
+ MY_BUILD_ARGUMENT: process.env.MY_BUILD_ARGUMENT,
66
+ },
67
+ secrets: {
68
+ myBuildSecret: new DockerBuildSecret.fromEnvironment("MY_BUILD_SECRET"),
69
+ },
70
+ },
47
71
  });
48
72
  ```
49
73
 
50
74
  ### Scaling
51
75
 
52
- 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.
76
+ 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 vertical scaling and horizontal (auto-)scaling.
53
77
 
54
78
  ```ts
55
79
  new NextApp(this, "NextApp", {
56
80
  // ...
57
81
  cpu: 1024,
58
82
  memory: 4096,
59
- tasks: { min: 1, max: 10 },
83
+ tasks: 3,
84
+ });
85
+ ```
86
+
87
+ ```ts
88
+ new NextApp(this, "NextApp", {
89
+ // ...
90
+ tasks: {
91
+ minimum: 1,
92
+ maximum: 5,
93
+ },
60
94
  });
61
95
  ```
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { DockerClusterProps, DockerCluster } from '@codedazur/cdk-docker-cluster';
2
+ import { ContainerImage } from 'aws-cdk-lib/aws-ecs';
2
3
  import { Construct } from 'constructs';
3
4
 
4
5
  interface NextAppProps extends DockerClusterProps {
@@ -8,7 +9,16 @@ interface NextAppProps extends DockerClusterProps {
8
9
  * for private NPM packages using a build-time secret.
9
10
  */
10
11
  declare class NextApp extends DockerCluster {
11
- constructor(scope: Construct, id: string, { port, secrets, ...props }: NextAppProps);
12
+ constructor(scope: Construct, id: string, { port, source, ...props }: NextAppProps);
13
+ protected static withNpmSecret(source: NextAppProps["source"]): ContainerImage | {
14
+ secrets: {
15
+ npmrc: string;
16
+ };
17
+ directory: string;
18
+ exclude?: string[];
19
+ file?: string;
20
+ arguments?: Record<string, string>;
21
+ };
12
22
  }
13
23
 
14
- export { NextApp, NextAppProps };
24
+ export { NextApp, type NextAppProps };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { DockerClusterProps, DockerCluster } from '@codedazur/cdk-docker-cluster';
2
+ import { ContainerImage } from 'aws-cdk-lib/aws-ecs';
2
3
  import { Construct } from 'constructs';
3
4
 
4
5
  interface NextAppProps extends DockerClusterProps {
@@ -8,7 +9,16 @@ interface NextAppProps extends DockerClusterProps {
8
9
  * for private NPM packages using a build-time secret.
9
10
  */
10
11
  declare class NextApp extends DockerCluster {
11
- constructor(scope: Construct, id: string, { port, secrets, ...props }: NextAppProps);
12
+ constructor(scope: Construct, id: string, { port, source, ...props }: NextAppProps);
13
+ protected static withNpmSecret(source: NextAppProps["source"]): ContainerImage | {
14
+ secrets: {
15
+ npmrc: string;
16
+ };
17
+ directory: string;
18
+ exclude?: string[];
19
+ file?: string;
20
+ arguments?: Record<string, string>;
21
+ };
12
22
  }
13
23
 
14
- export { NextApp, NextAppProps };
24
+ export { NextApp, type NextAppProps };
package/dist/index.js CHANGED
@@ -39,17 +39,35 @@ var import_os = __toESM(require("os"));
39
39
  var import_path = __toESM(require("path"));
40
40
  var import_cdk_docker_cluster = require("@codedazur/cdk-docker-cluster");
41
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 }) {
42
+ var import_aws_ecs = require("aws-cdk-lib/aws-ecs");
43
+ var NextApp = class _NextApp extends import_cdk_docker_cluster.DockerCluster {
44
+ constructor(scope, id, { port = 3e3, source, ...props }) {
44
45
  super(scope, id, {
45
46
  port,
46
- secrets: {
47
- npmrc: import_aws_cdk_lib.DockerBuildSecret.fromSrc(import_path.default.join(import_os.default.homedir(), "/.npmrc")),
48
- ...secrets
49
- },
47
+ source: _NextApp.withNpmSecret(source),
50
48
  ...props
51
49
  });
52
50
  }
51
+ static withNpmSecret(source) {
52
+ if (source instanceof import_aws_ecs.ContainerImage) {
53
+ return source;
54
+ }
55
+ if (typeof source === "string") {
56
+ return {
57
+ directory: source,
58
+ secrets: {
59
+ npmrc: import_aws_cdk_lib.DockerBuildSecret.fromSrc(import_path.default.join(import_os.default.homedir(), "/.npmrc"))
60
+ }
61
+ };
62
+ }
63
+ return {
64
+ ...source,
65
+ secrets: {
66
+ npmrc: import_aws_cdk_lib.DockerBuildSecret.fromSrc(import_path.default.join(import_os.default.homedir(), "/.npmrc")),
67
+ ...source.secrets
68
+ }
69
+ };
70
+ }
53
71
  };
54
72
  // Annotate the CommonJS export names for ESM import in node:
55
73
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -5,17 +5,35 @@ import {
5
5
  DockerCluster
6
6
  } from "@codedazur/cdk-docker-cluster";
7
7
  import { DockerBuildSecret } from "aws-cdk-lib";
8
- var NextApp = class extends DockerCluster {
9
- constructor(scope, id, { port = 3e3, secrets, ...props }) {
8
+ import { ContainerImage } from "aws-cdk-lib/aws-ecs";
9
+ var NextApp = class _NextApp extends DockerCluster {
10
+ constructor(scope, id, { port = 3e3, source, ...props }) {
10
11
  super(scope, id, {
11
12
  port,
12
- secrets: {
13
- npmrc: DockerBuildSecret.fromSrc(path.join(os.homedir(), "/.npmrc")),
14
- ...secrets
15
- },
13
+ source: _NextApp.withNpmSecret(source),
16
14
  ...props
17
15
  });
18
16
  }
17
+ static withNpmSecret(source) {
18
+ if (source instanceof ContainerImage) {
19
+ return source;
20
+ }
21
+ if (typeof source === "string") {
22
+ return {
23
+ directory: source,
24
+ secrets: {
25
+ npmrc: DockerBuildSecret.fromSrc(path.join(os.homedir(), "/.npmrc"))
26
+ }
27
+ };
28
+ }
29
+ return {
30
+ ...source,
31
+ secrets: {
32
+ npmrc: DockerBuildSecret.fromSrc(path.join(os.homedir(), "/.npmrc")),
33
+ ...source.secrets
34
+ }
35
+ };
36
+ }
19
37
  };
20
38
  export {
21
39
  NextApp
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codedazur/cdk-next-app",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "main": ".dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -22,21 +22,17 @@
22
22
  "types": "tsc --noEmit",
23
23
  "test": "vitest run --passWithNoTests"
24
24
  },
25
- "dependencies": {
26
- "@codedazur/cdk-docker-cluster": "^0.4.0"
27
- },
28
25
  "peerDependencies": {
29
26
  "aws-cdk-lib": ">=2",
30
27
  "constructs": ">=10"
31
28
  },
29
+ "dependencies": {
30
+ "@codedazur/cdk-docker-cluster": "^0.5.0"
31
+ },
32
32
  "devDependencies": {
33
- "@codedazur/eslint-config": "*",
34
- "@codedazur/tsconfig": "*",
35
- "@types/node": "^20.14.2",
36
- "aws-cdk-lib": "^2.145.0",
33
+ "@types/node": "^20.14.9",
34
+ "aws-cdk-lib": "^2.147.2",
37
35
  "constructs": "^10.3.0",
38
- "esbuild": "^0.20.2",
39
- "eslint": "^8.30.0",
40
- "typescript": "^5.4.5"
36
+ "esbuild": "^0.21.5"
41
37
  }
42
38
  }
package/tsconfig.json CHANGED
@@ -1,5 +1,3 @@
1
1
  {
2
- "extends": "@codedazur/tsconfig/cdk.json",
3
- "include": ["."],
4
- "exclude": ["dist", "build", "node_modules"]
2
+ "extends": "@codedazur/tsconfig/cdk.json"
5
3
  }