For deployments I use a custom Ubuntu 18.04 Docker container. This container is spun up by a dynamic host Ubuntu worker provided by Octopus Cloud.
This container has been modified with tools that we require for deployments. One of the modifications is the installation of NodeJS via Node Version Manager (nvm). The specified default node version being 14.5.0.
As part of the install
/etc/environment is updated so the $PATH environment variable contains the install path of node, npm, and other packages installed globally via npm.
$PATH environment variable looks like:
The problem is, when running a step that uses node/npm; these binaries cannot be found as the path is overwritten to be the default:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin (notice that
/root/.nvm/versions/node/v14.5.0/bin is no longer there)
cat /etc/environment shows that the file has been completely overwritten.
Is there a way to set environment variables in Octopus when defining the process?
Is there a way to stop the $PATH environment variable being overwritten?
For those that may have a similar issue, the work around is to symlink the node, npm, etc binaries to
/usr/bin, this way an updated $PATH is not needed.
Regardless, I am sure there will come a time where we will need to set an environment variable as part of a deployment.