Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Stuck deploying nodejs api to VPS

Gaius Temple August 5, 2019

Hi there,

I'm trying to set up Bitbucket Pipelines - my first time using CI, I've been searching through the examples for a while but I'm not quite sure how to perform the following steps:

  • Run `npm run build`
  • Zip the files
  • Copy the zip to my vps - to something like `/tmp/appname-api-$(buildnumber).tar.gz`
  • On my VPS, stop pm2
  • On my VPS make a new build directory `mkdir -p /var/api/build-$(buildnumber)/`
  • Ensure that directory is clean `rm -rf /var/api/build-$(buildnumber)/*`
  • Go to that directory `cd /var/api/build-$(buildnumber)`
  • Extract the zip there `tar zxvf /tmp/appname-api-(buildnumber).tar.gz`
  • Remove current `rm -rf /var/api/current`
  • Symlink build to current `ln -s /var/api/build-$(buildnumber) /var/api/current`
  • Start pm2

 

2 answers

0 votes
Gaius Temple August 5, 2019

--

0 votes
Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 5, 2019

Hello @Gaius Temple

Here's probably a good tutorial for you to start with: Javascript (Node.js) with Bitbucket Pipelines. It also links to the demo Node.js repository with example of Pipelines setup.

Steps starting from #3 belong to the deployment process. Here's an entry point to the documentation on deployments in Bitbucket Pipelines.

Hope this helps.

Cheers,
Daniil

Gaius Temple August 5, 2019

Hey @Daniil Penkin 

Thank you for your reply.

I've now got it building and producing the dist files, but using scp to deploy them to the server takes ages each time racking up my build minutes even if only one or two files have changed.  I could use rsync but does this run over ssh (-e ssh) or are my files transferred unencrypted?

Edit: Ah can I do EXTRA_ARGS: "-e ssh"?

Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 5, 2019

rsync itself doesn't do any encryption, so a separate protocol, usually SSH, must be specified to make transfer secure. However I'm not an expert with rsync, and I'm not sure what's the best way to set it up in your case.

Cheers,
Daniil

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events