build
Build an OCI image from a Dockerfile.
Options can be configured in project.json when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/reference/project-configuration#targets.
Note
This executor not handle registry login steps, so if you wanna push your container images to a remote registry, please setup the credentials using the docker login
or podman login
.
Examples
You may want your build result to be available in the Docker client through docker images
to be able to use it in another step of your workflow:
"container": {
"executor": "@nx-tools/nx-container:build",
"options": {
"load": true,
"tags": ["image-name:latest"],
}
}
The following config will connect you to DockerHub and GitHub Container Registry and push the image to these registries.
"container": {
"executor": "@nx-tools/nx-container:build",
"options": {
"push": true,
"tags": [
"user/app:latest",
"user/app:1.0.0",
"ghcr.io/user/app:latest",
"ghcr.io/user/app:1.0.0"
],
}
}
Options:
All options described here, can be customized using environment variables or values in your project.json
. Environment variables takes precedence over harcoded values.
Tip!
All environment values needs to be prefixed with INPUT_
so INPUT_PUSH=true
will replace the options.push
value of your project.json
file
Note: For list values use a comma-delimited string, like INPUT_PLATFORMS=linux/amd64,linux/arm64
. For INPUT_BUILD_ARGS
and INPUT_TAGS
use a newline-delimited string. See FAQ page for more information.
Note: Replace a dash (-) with an underscore in environment variables, like INPUT_CACHE_FROM='type=gha'
Prop | Type | Default |
---|---|---|
metadata? | Metadata | - |
ulimit? | string[] | - |
target? | string | - |
tags? | string[] | - |
ssh? | string[] | - |
shm-size? | string | - |
secret-files? | string[] | - |
secrets? | string[] | - |
sbom? | boolean | false |
push? | boolean | false |
pull? | boolean | false |
provenance? | string | - |
platforms? | string[] | - |
outputs? | string[] | - |
no-cache-filters? | string[] | - |
no-cache? | boolean | false |
network? | string | - |
load? | boolean | false |
labels? | string[] | - |
file? | string | Dockerfile |
context? | string | . |
cgroup-parent? | string | - |
cache-to? | string | string[] | - |
cache-from? | string | string[] | - |
builder? | string | - |
build-contexts? | string[] | - |
build-args? | string[] | - |
allow? | string[] | - |
add-hosts? | string[] | - |
quiet? | boolean | false |
engine? | "docker" | "podman" | docker |
Metadata
Prop | Type | Default |
---|---|---|
bake-target? | string | container-metadata-action |
sep-labels? | string | \n |
sep-tags? | string | \n |
labels? | string[] | - |
flavor? | string[] | - |
tags? | string[] | - |
images? | string[] | - |
Last updated on