Represents a docker image built during synthesis from a context directory (dir
) with a Dockerfile
.
The image will be built using docker build
and then pushed through docker push
. The URL of the pushed image can be accessed through image.url
.
If you push to a registry other than docker hub, you can specify the registry
URL through the registry
option.
import { Image } from 'cdk8s-image'
new Image(scope: Construct, id: string, props: ImageProps)
Name | Type | Description |
---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
ImageProps |
No description. |
- Type: constructs.Construct
- Type: string
- Type: ImageProps
Name | Description |
---|---|
toString |
Returns a string representation of this construct. |
public toString(): string
Returns a string representation of this construct.
Name | Description |
---|---|
isConstruct |
Checks if x is a construct. |
import { Image } from 'cdk8s-image'
Image.isConstruct(x: any)
Checks if x
is a construct.
Use this method instead of instanceof
to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs
library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct
in each copy of the constructs
library
is seen as a different class, and an instance of one class will not test as
instanceof
the other class. npm install
will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof
will behave
unpredictably. It is safest to avoid using instanceof
, and using
this type-testing method instead.
- Type: any
Any object.
Name | Type | Description |
---|---|---|
node |
constructs.Node |
The tree node. |
url |
string |
The image URL to use in order to pull this instance of the image. |
public readonly node: Node;
- Type: constructs.Node
The tree node.
public readonly url: string;
- Type: string
The image URL to use in order to pull this instance of the image.
Build arg to pass to the docker build.
import { BuildArg } from 'cdk8s-image'
const buildArg: BuildArg = { ... }
Name | Type | Description |
---|---|---|
name |
string |
the name of the build arg. |
value |
string |
the value of the build arg. |
public readonly name: string;
- Type: string
the name of the build arg.
public readonly value: string;
- Type: string
the value of the build arg.
Props for Image
.
import { ImageProps } from 'cdk8s-image'
const imageProps: ImageProps = { ... }
Name | Type | Description |
---|---|---|
dir |
string |
The docker build context directory (where Dockerfile is). |
buildArgs |
BuildArg[] |
List of build args to pass to the build action. |
file |
string |
Path to Dockerfile. |
name |
string |
Name for the image. |
platform |
string |
Set to specify the target platform for the build output, (for example, linux/amd64, linux/arm64, or darwin/amd64). |
registry |
string |
The registry URL to use. |
tag |
string |
Tag for the image. |
public readonly dir: string;
- Type: string
The docker build context directory (where Dockerfile
is).
public readonly buildArgs: BuildArg[];
- Type: BuildArg[]
List of build args to pass to the build action.
public readonly file: string;
- Type: string
Path to Dockerfile.
public readonly name: string;
- Type: string
- Default: auto-generated name
Name for the image.
Docker convention is {registry_name}/{name}:{tag} Visit https://docs.docker.com/engine/reference/commandline/tag/ for more information
public readonly platform: string;
- Type: string
Set to specify the target platform for the build output, (for example, linux/amd64, linux/arm64, or darwin/amd64).
public readonly registry: string;
- Type: string
- Default: "docker.io/library"
The registry URL to use.
This will be used as the prefix for the image name.
For example, if you have a local registry listening on port 500, you can set this to localhost:5000
.
public readonly tag: string;
- Type: string
- Default: "latest"
Tag for the image.
Docker convention is {registry_name}/{name}:{tag} Visit https://docs.docker.com/engine/reference/commandline/tag/ for more information