I’ve been using lambda for some time and haven’t provisioned a classic machine in a while.
What I used to do was run a git hook on the machine so that whenever an update happened via git it would update the code on the machine.
I’m trying to figure out ways to elegantly make updates to google compute engine.
I’d like to use docker so I can easily spin new instances, but I’m not sure what to do in order to update the node js code on the machine
2
Answers
Deploying on compute engine is pretty broad, it depends on your needs. I ended up using several different methods.
With Docker: Inside my package.json I have a command
yarn deploy
that builds and submits a fresh docker instance to the Google container repository.Then it uses
gcloud
to restart the instance group (I don't think you need a group, the command would be different for single instance, similar concept). Which then pulls the latest Docker image with the fresh code.I had some issues with Docker and accessing Nvidia GPU drivers inside my container (I think I know how to fix now). Out of frustration I skipped docker and instead used a startup.sh script.
Still working on making booting up an instance automatic, but my strategy without docker is a bash script that has been tested and to make sure I am using the same OS.
I manually installed a --bare git repo on the machine following this https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps
Ideally the startup script will do that and I can easily manage multiple instances this way. Even better would be to go back to my Docker strategy and fix the issues with the drivers (it can be tricky using Google Container Optimized OS)
I hope this helps, your workflow is up to you and or your team. Leverage
Docker
,gcloud
, andbash
when you canIf you are using Github, you can use this extensions
https://github.com/marketplace/actions/google-cloud-compute-engine-deploy
If you are using Jenkins, you can connect machine with ssh and update your code.
If you want a native solution, Cloud Build helps to you
more -> Google cloud build with Compute Engine