1.1.0 • Published 10 months ago

@codedazur/cdk-docker-cluster v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

DockerCluster

This construct creates a load balanced Fargate service, for which it builds a Docker image from a local directory. A CloudFront distribution is connected to the load balancer.

Examples

The minimum needed to get a DockerCluster up and running is a path to the source directory that contains a Dockerfile, relative to the CDK app, and the port on which your container needs to be accessible.

new DockerCluster(this, "DockerCluster", {
  source: "../path/to/source",
  service: {
    port: 3000,
  },
});

With Monorepo Build

If your Dockerfile is not located directly in the build context directory, which is common for monorepositories, you can provide the path to the Dockerfile relative to the source directory.

new DockerCluster({
  source: {
    directory: "../path/to/source",
    file: "./apps/myApp/DockerFile",
  },
  // ...
});

With Arguments and Secrets

Additionally, if your Dockerfile requires arguments and/or secrets, you can provide those as well.

new DockerCluster({
  source: {
    // ...
    arguments: {
      MY_BUILD_ARGUMENT: "foo",
    },
    secrets: {
      myBuildSecret: DockerBuildSecret.fromSrc("./foo"),
    },
  },
  // ...
});

With ContainerImage

Alternatively, you can provide your own ContainerImage instance. There are many ways to construct a ContainerImage. For example, you can create one from an asset and take full control over how CDK builds your Docker image.

new DockerCluster({
  source: ContainerImage.fromAsset("../path/to/source", {
    // ...
  }),
  // ...
});

Or, if you want to build your Docker image outside of CDK, you can create a ContainerImage from a path to your image's tarball.

new DockerCluster({
  source: ContainerImage.fromTarball("./path/to/image.tar"),
  // ...
});

Or if the image you need is published to a registry, you can create your ContainerImage from a registry path. You can provide credentials in case the registry is private.

new DockerCluster({
  source: ContainerImage.fromRegistry("node:20"),
  // ...
});

Finally, you can create a ContainerImage from an image that you have published to an ECR repository.

new DockerCluster({
  source: ContainerImage.fromEcrRepository(myRespository, "my-tag"),
  // ...
});

With Scaling

The DockerCluster construct supports both vertical and horizontal scaling.

new DockerCluster(this, "DockerCluster", {
  // ...
  service: {
    // ...
    cpu: 1024, // 1vCPU
    memory: 4096, // 4GB
    tasks: 3,
  },
});

Horizontal auto-scaling is also supported.

new DockerCluster(this, "DockerCluster", {
  // ...
  service: {
    // ...
    tasks: {
      minimum: 1,
      maximum: 5,
    },
  },
});
0.9.8

10 months ago

1.1.0

10 months ago

0.9.7

10 months ago

1.0.0

10 months ago

0.9.9

10 months ago

0.9.4

10 months ago

0.9.3

10 months ago

0.9.6

10 months ago

0.9.5

10 months ago

0.9.2

11 months ago

0.3.0

1 year ago

0.9.0

12 months ago

0.6.3

1 year ago

0.8.0

12 months ago

0.6.2

1 year ago

0.9.1

11 months ago

0.6.4

1 year ago

0.5.0

1 year ago

0.4.0

1 year ago

0.7.0

12 months ago

0.6.1

1 year ago

0.5.2

1 year ago

0.6.0

1 year ago

0.5.1

1 year ago

0.2.0

1 year ago