Join 1M+ other developers and:
- Get help and share knowledge in Q&A
- Subscribe to topics of interest
- Get courses & tools that help you grow as a developer or small business owner
NuxtJS deployment using CircleCi CPU spikes 100%+
I am deploying my NuxtJS app using a deployment script, which I added below. I use some of the instructions from this tutorial: https://www.digitalocean.com/community/tutorials/how-to-automate-deployment-using-circleci-and-github-on-ubuntu-18-04
If I access my droplet using SSH and run the
deploy.sh script manually, it seems to work fine. But as soon as CircleCI starts a docker instance (see config.yml below), it needs at least 5 minutes to run the script, if I am lucky. And while doing that, the CPU of my droplet spikes, and it takes a lot of patience trying to reconnect with my droplet using SSH from my local machine.
Quite odd this only happens when running the script through CircleCI. I tried to spin up a medium docker instance, instead of a small, but without luck. Most of the time, the deployment is killed after 10 minutes, so I end up with a failed deployment most of the time.
If CircleCI fails, my droplet’s CPU stays over 100% and
node_modules/.bin/nuxt build keeps running. Rebooting the droplet is the easiest solution (sometimes necessary, if reconnecting using SSH just isn’t possible or the terminal which is already connected, isn’t responding anymore). After reboot, the first CircleCi deployment succeeds and the rest fail again.
I looked at htop, and it seems that
kswapd0 takes over 40% CPU,
snapd over 30 and the rest are for node, etc.
#!/bin/bash #move to project folder cd /var/www/mywebsite.nl #pull from the branch git pull origin main # build nuxt project and run pm2 npm install npm run build pm2 start
version: 2.1 jobs: deploy: docker: - image: buildpack-deps:trusty resource_class: small # we use a small docker instance to use as little credits as possible steps: - add_ssh_keys: fingerprints: - "xx:xx:xx:xx:xx:xx:xx:xx" - run: name: Deploy Over SSH command: | ssh -oStrictHostKeyChecking=no -v $SSH_USER@$SSH_HOST "./deploy.sh" workflows: build-and-deploy: jobs: - deploy: filters: branches: only: - main # only deploy on the main branch
My droplet: 1 GB Memory / 25 GB Disk / AMS3 - Ubuntu 20.04 (LTS) x64
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×