Custom Build Scripts
custom
Using custom
as build tool allows you to define a custom command for building images. This is particularly useful if you want to use a remote build system such as Google Cloud Build.
warning
Make sure your custom
build command terminates with exit code 0 when the build process was successful.
command
The onChange
option expects an array of strings which represent paths to files or folders that should be watched for changes. DevSpace uses these paths and the hash values it stores about these paths for evaluating if an image should be rebuilt or if the image building can be skipped because the context of the image has not changed.
info
It is highly recommended to specify this option when using custom
as build tool in order to speed up the build process.
custom
Build Command
Example: Building Images With Explanation:
The image backend
would be built using the command ./build arg1 --flag=flag-value arg2 "[IMAGE]:[TAG]"
while [IMAGE]
would be replaced with the image
option (in this case: john/appbackend
) and [TAG]
would be replaced with the tag generated according to the tagging schema.
imageFlag
The imageFlag
option expects a string which states the name of the flag that is used to pass the image name (including auto-generated tag) to the custom build script defined in command
.
imageFlag
Default Value For imageFlag
For custom
Build Command
Example: Defining Explanation:
The image backend
would be built using the command ./build --arg1 --flag flag-value --arg2 --image="[IMAGE]:[TAG]"
while [IMAGE]
would be replaced with the image
option (in this case: john/appbackend
) and [TAG]
would be replaced with the tag generated according to the tagging schema.
skipImageArg
The skipImageArg
option expects a boolean which specifies if DevSpace should add an argument to the command with the image:tag
. If enabled DevSpace will omit the image argument completely
skipImageArg
For custom
Build Command
Example: Defining Explanation:
The image backend
would be built using the command ./build --arg1 --flag flag-value --arg2
imageTagOnly
The imageTagOnly
option expects a boolean which specifies if DevSpace should only add the image tag
instead of image:tag
as argument.
imageTagOnly
For custom
Build Command
Example: Defining Explanation:
The image backend
would be built using the command ./build --arg1 --flag flag-value --arg2 --image="[TAG]"
while [TAG]
would be replaced with the tag generated according to the tagging schema.
args
The args
option expects an array of strings which represent additional flags and arguments that should be passed to the custom build command before the argument containing [IMAGE]:[TAG]
.
args
Default Value For args
and appendArgs
for Custom Builds
Example: Using Explanation:
The image backend
would be built using the command ./build --flag1 flag-value-1 arg1 arg2 [IMAGE]:[TAG] arg3 --flag2 flag-value-2
while [IMAGE]
would be replaced with the image
option (in this case: john/appbackend
) and [TAG]
would be replaced with the tag generated according to the tagging schema.
appendArgs
The appendArgs
option expects an array of strings which represent additional flags and arguments that should be passed to the custom build command after the argument containing [IMAGE]:[TAG]
.
appendArgs
Default Value For Example
See "Example: Using args
and appendArgs
For Custom Builds"
commands
The commands
option expects an array of commands that should be executed on a specific operating system. This will only exchange the base command, but all other arguments will be appended the same way.
commands
for Custom Builds
Example: Using Explanation:
- linux: The image
backend
would be built using the command./build-default.sh --flag1 flag-value-1 arg1 arg2 [IMAGE]:[TAG]
- windows: The image
backend
would be built using the command./build-windows.ps --flag1 flag-value-1 arg1 arg2 [IMAGE]:[TAG]
- darwin (macOS): The image
backend
would be built using the command./build-darwin.sh --flag1 flag-value-1 arg1 arg2 [IMAGE]:[TAG]
onChange
The onChange
option expects an array of strings which represent paths to files or folders that should be watched for changes. DevSpace uses these paths and the hash values it stores about these paths for evaluating if an image should be rebuilt or if the image building can be skipped because the context of the image has not changed.
info
It is highly recommended to specify this option when using custom
as build tool in order to speed up the build process.
onChange
Default Value For Example: OnChange Option For custom Build Command
Explanation:
The image backend
would be built using the command ./build --image="[IMAGE]:[TAG]"
and DevSpace would skip the build if none of the files within some/path/
nor the file another/path/file.txt
has changed since the last build.