Skip to main content

Warmup Script (Deprecated)

Note

The warmup script is optional, and deprecated. It is recommended to use the prebuild scripts feature instead. There are a couple other ways to accomplish initialization before runtime (contact us for more info) In most cases, environments can be spawned successfully without it.

The warmup script is executed from the context of the dev container before building and deploying the rest of the environment. This script can help you prepare what is necessary for the containers build to be successful or for preparing the dev container for convenient use. The warmup script is run when an environment is created, but does not run when it wakes up from hibernation.

Remember

Add all warmup script dependencies to the dev container using its Dockerfile.

Here are a few examples of what can be done in the warmup script:

Example 1 - Download Build Dependencies

Let's assume your services are written in Go, and you compile them on your dev container. Having all the go modules downloaded to the dev container may be convenient, so compilation will be speedy. The following warmup script is an example of how to accomplish that:

cd /code
nohup go mod download > /dev/null & # Perform async so the warmup script does not block the build and deploy process.

Example 2 - Compiling Protobuf

Your services may communicate between them using Protobuf, GraphQL, or any other schema language requiring generation. You can automatically generate the relevant files using something like:

find . -name '*.proto' -exec protoc --go_out=paths=source_relative:./ '{}' ';'