Warm-up
Dev environments can significantly increase the speed of development by removing the IDE warm-up phase: a period of time when the IDE builds indexes, and does other background activities like resolving project dependencies. You can put all these routines into a dev environment warm-up and run it on schedule. The result of the warm-up is a warm-up snapshot (a Docker volume) that is then mounted to a dev environment. Make sure the warm-up is run regularly: The fresher the index data is, the faster a dev environment will be ready for work.
When creating a dev environment, users will be able to choose the warm-up snapshot to start from.
Configure the warm-up
To configure warm-up, use the Startup performance | Warm-up section of a dev environment template.
Here:
Instance type – the resources allocated to the dev environment that will be used for creating the warm-up snapshot. As performance is not critical for the warm-up dev environments, you can choose a smaller instance type than for user dev environments.
Create project indexes for IDE – if enabled, the warm-up will build project indexes for the IDE specified in the template. Note that if you disable this option, you should provide a warm-up script in Script. Otherwise, the warm-up will be useless.
If the template has multiple repositories, the warm-up will build indexes for all of them.
Script – your custom shell script that will be run before the warm-up runs the IDE to build indexes. For example, you can use it to build your project with
./gradlew build
or to configure the IDE. Don't use the script to install additional tools (e.g., withapt get
) – this data will not be saved in the snapshot.Script working directory – a path to the working directory where the Script will be run. This path is relative to the
/mnt/jetbrains/work
directory. If not specified, the script will be run in/mnt/jetbrains/work
. See directory structureParameters – environment variables that will be available in the warm-up. Use them to provide sensitive data to the warm-up environment like user credentials or access tokens. Learn more
Execution timeout (minutes) – CodeCanvas stops the warm-up and considers it failed if it takes longer than the specified time.
Cron triggers – the schedule for the warm-up. Use the crontab format to specify the schedule (UTC timezone). For example,
0 1 * * 1-5
runs the warm-up every day at 1:00AM except for weekends. Learn more
How the warm-up works
When the warm-up is triggered, CodeCanvas creates a dev environment based on the template settings: the specified container image, environment variables, and so on. Important: the environment can't be personalized for a particular user, that is, it can't use personal parameters. If you need to provide sensitive data to the warm-up, use warm-up parameters.
In this warm-up environment, CodeCanvas:
Checks out the project source code.
Runs your custom shell script if you specified it in the Script field. The warm-up will proceed to the next step only if the script exits successfully with a zero status code.
Runs the IDE specified in the template and builds project indexes.
Project indexes are specific for each IDE and most often for each IDE version. For the warm-up, CodeCanvas uses the IDE version specified in the IDE version parameter of the template. If it's Default, the warm-up will build indexes for the default IDE version.
If you don't want the warm-up to build project indexes, clear the Create project indexes for IDE checkbox.
Saves a snapshot of the file system – a warm-up snapshot.
Warm-up snapshot
Technically, a warm-up snapshot is a Docker volume that contains the /root
(a container based on the default image always runs under the root
user), the /mnt/jetbrains
, and the var/lib/docker
directories:
Everything outside these directories is discarded. For this reason you shouldn't use the warm-up, for example, to install additional tools with apt get
. For this purpose, use custom dev environment images.
Important notes:
CodeCanvas stores only the latest warm-up snapshot for each combination of an IDE and a Git branch. An IDE version is not taken into account. For example, a project has two branches:
main
andfeature-branch
. Suppose some developers use JetBrains Rider and some use IntelliJ IDEA. There can be four snapshots maximum:main
+ Rider,main
+ IDEA,feature-branch
+ Rider, andfeature-branch
+ IDEA.Dev environments started from the same snapshot are independent of each other and don't share their state in any way.
The way snapshots are taken depends on the infrastructure. For example, in AWS, dev environment disks and snapshotting are based on EBS.
To view warm-up snapshots available in a namespace
In the sidebar namespace menu, select Warm-up Snapshots.
To delete a warm-up snapshot
In the sidebar namespace menu, select Warm-up Snapshots.
Find the snapshot and click Delete.
Trigger the warm-up
There are two ways to trigger the warm-up: manually in the CodeCanvas UI and by schedule.
In the sidebar namespace menu, select Warm-up Snapshots.
Click New warm-up snapshot.
In the dialog, specify the required dev environment template and repository branch, and click Create.
The Cron triggers parameter of a dev environment template specifies the warm-up schedule. During the warm-up, CodeCanvas will use the environment settings (including the branch) specified in the template.
When specifying the schedule, use the UTC timezone and the crontab format (MIN HOUR DAY MONTH DAYOFWEEK). For example, to run warm-up every Friday at 23:59 UTC, specify 59 23 * * FRI
.
To add one more trigger, click Add another and specify the schedule.
Provide sensitive data to a warm-up dev environment
Your project might require sensitive data, like user credentials or access tokens, for example, for getting dependencies from a private repository or for accessing a database. While you can use personal user parameters for individual user dev environments, warm-up dev environments also require this data for their work. You define the required warm-up parameters on the namespace level and then assign them to the corresponding environment variables in the warm-up settings.
To define a warm-up parameter
In the sidebar namespace menu, select Settings, then Warm-up Parameters.
Click New parameter.
Specify
Key: a parameter name. You will use this name to reference this parameter in the warm-up settings.
Value: a parameter value.
Notes:
Parameters are stored in the encrypted form.
Parameters are used only during the warm-up with no user access to them.
Parameters exist only in the scope of a particular namespace. So, if you create a parameter in one namespace, you can't use them in other namespaces.
Parameter keys must be unique within a namespace.
A key must be no longer than 128 characters and can only contain alphanumeric characters (
[a-z]
,[A-Z]
,[0-9]
), dashes (-
), or underscores (_
).Keys are case-insensitive.
Max secret's or parameter's value size is 30KB.
To add a parameter to a template
In the template settings, open the Startup performance section.
In the warm-up settings, under Parameters, click Add parameter.
Specify parameter settings:
Type– select the type of the variable: Variable (environment variable) or File.
Name – the name of the environment variable or an absolute path to a file on the warm-up environment.
Warm-up parameter – a reference to a warm-up parameter defined on the namespace level.
Create a warm-up snapshot for a custom branch
By default, the warm-up snapshot is created for the branch specified in the dev environment template. If you need to create a snapshot for another branch, you can do it manually.
In the sidebar namespace menu, select Warm-up Snapshots.
Click New warm-up snapshot.
In the dialog:
Specify the required dev environment template
Click Add branch override and specify the branch. In the case of multiple repositories, you can specify a custom branch for each repository.
Click Create.