AppEngine Flexible Environment deploys using gcloud app deploy
are generally slow because AppEngine has to spin up the container environment before deploying the code and switching traffic to it.
A common method to speed up the deployment is to specify the version, that way AppEngine deploys new code to the same container environment. Such as:
gcloud app deploy --version=12345
In a node environment, I would like to use the package.json version in my deploy scripts, for example:
{
"name": "MyApp",
"version": "1.3.4",
"scripts": {
"deploy":"gcloud app deploy --version=$npm_package_version"
}
NPM takes the values in the config and adds it to environment variables prefixed with $npm_package_ out of the box so that's fine.
However, AppEngine does not accept .
in their version names.
So I am looking for a good way to transform $npm_package_version into an AppEngine-approved version number before being able to pass it into gcloud
on the <scripts>
node.