Chang Hak Yeon
Chang Hak Yeon

Reputation: 13

How to speed up Jenkins when build nodejs with vagrant setting?

I tried to build and upload files automatically by Jenkins.

So I'm using Jenkins/Git/vagrant now, and it work fine!

But.. it is too late.. The process waste over 30 minutes now.

In now, I destroy past vagrant setting and delete past workspace. In my opinion, this issue is the main cause of wasting time.

Is there any other ways to make CI sever with safe options??(like.. checking vagrant setting together..)

P.S.

This is my Vagrant file's script. Is there any improvement points?? I really need your helps..

Vagrant file:

Vagrant.configure("2") do |config|

    config.vm.box = "ubuntu/trusty64"
    config.vm.provision :shell, :path => "node-bootstrap.sh"
    config.vm.network :private_network, ip: 'xx.xxx.xxx.xx(secret)'


    config.vm.provider :virtualbox do |vb|
        vb.memory = "2048"    
        vb.cpus = 2
    end

    config.vm.provision "shell", run: "always" do |s|
    s.inline = "cd /vagrant/frontend && gulp --production true"
    end

end

node-bootstrap.sh:

#!/bin/bash

echo "======================"
echo "Install 3rd parties for Node.js.........."
echo "======================"
sudo apt-get update
sudo apt-get install -y build-essential curl libssl-dev git

echo "======================"
echo "Node source 4.x......."
echo "======================"
sudo curl -sL https://deb.nodesource.com/setup_4.x | bash -

echo "======================"
echo "Node.js..............."
echo "======================"
sudo apt-get install -y nodejs


echo "======================"
echo "Install bower........."
echo "======================"
sudo npm install -g bower


echo "======================"
echo "Install gulp.........."
echo "======================"
sudo npm install -g gulp


echo "======================"
echo "Install packages on /vagrant......"
echo "======================"
cd /vagrant/frontend
sudo npm install

echo "======================"
echo "Install bower packages on /vagrant....."
echo "======================"
cd /vagrant/frontend
sudo bower install --allow-root --config.interactive=false

Upvotes: 1

Views: 436

Answers (1)

Frederic Henri
Frederic Henri

Reputation: 53733

what you should do rather than destroy and provisioning each time is to create a new box with Node, Jenkins, etc installed so when you do vagrant up it will not need to run this step. of course it also means that when you need an updated version of node/jenkins you would need to recreate the base box but it will save you a lot of time on your daily activity.

you should:

  • up your box and run the provisioning
  • run vagrant repackage to save this new VM state (with all software installed) as a new box
  • add this box into Vagrant config
  • point the vm.box to your new box rather than the old one and remove the provisioning part.

Upvotes: 1

Related Questions