You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: astro-docs/src/content/docs/technologies/build-tools/docker/introduction.mdoc
+123Lines changed: 123 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,129 @@ The `@nx/docker` plugin is configured in the `plugins` array in `nx.json`.
58
58
59
59
The `buildTarget` and `runTarget` options control the names of the inferred Docker tasks. The default names are `docker:build` and `docker:run`.
60
60
61
+
### Advanced Plugin Configuration
62
+
63
+
The `buildTarget` and `runTarget` options can be configured as objects to provide additional customization beyond just naming the targets. This allows you to pass custom arguments, set environment variables, and use pattern interpolation.
64
+
65
+
```json
66
+
// nx.json
67
+
{
68
+
"plugins": [
69
+
{
70
+
"plugin": "@nx/docker",
71
+
"options": {
72
+
"buildTarget": {
73
+
"name": "docker:build",
74
+
"args": [
75
+
"--platform",
76
+
"linux/amd64,linux/arm64",
77
+
"--label",
78
+
"project={projectName}"
79
+
],
80
+
"env": {
81
+
"DOCKER_BUILDKIT": "1"
82
+
},
83
+
"envFile": ".env.docker",
84
+
"cwd": "{projectRoot}/docker"
85
+
},
86
+
"runTarget": {
87
+
"name": "docker:run",
88
+
"args": ["--rm"],
89
+
"env": {
90
+
"NODE_ENV": "production"
91
+
}
92
+
}
93
+
}
94
+
}
95
+
]
96
+
}
97
+
```
98
+
99
+
#### Configuration Properties
100
+
101
+
When using the object format, the following properties are available:
102
+
103
+
- **`name`** (string, required): The name of the inferred target
104
+
- **`args`** (string[], optional): Additional arguments to pass to the Docker command. Supports pattern interpolation.
105
+
- **`env`** (object, optional): Environment variables to set when running the Docker command. Values support pattern interpolation.
106
+
- **`envFile`** (string, optional): Path to an environment file to load
107
+
- **`cwd`** (string, optional): Working directory for the command. Supports pattern interpolation.
108
+
109
+
#### Pattern Interpolation
110
+
111
+
All string values in the configuration support pattern interpolation using the following tokens:
112
+
113
+
- **`{projectName}`** - The name of the project from `project.json` or `package.json`
114
+
- **`{projectRoot}`** - The root directory of the project (e.g., `apps/api`)
115
+
- **`{imageRef}`** - The default image reference derived from the project root (e.g., `apps-api`)
116
+
- **`{currentDate}`** - Current date in ISO format (e.g., `2025-01-30T14:30:00.000Z`)
117
+
- **`{currentDate|FORMAT}`** - Current date with custom formatting (e.g., `{currentDate|YYYY.MM.DD}` → `2025.01.30`)
118
+
- **`{commitSha}`** - Full Git commit SHA
119
+
- **`{shortCommitSha}`** - First 7 characters of the commit SHA
0 commit comments