I have a node.js application on my Github. Right now I am using Heroku for hosting it but I want to give DigitialOcean a try (the $5/month is more affordable).
I am used to using Heroku, where I just go create an app > connect it to my github account > deploy from the master branch > boom app deployed.
When I signed up for DO and started exploring it seemed way too much and too many steps to get my app deployed. I researched around to find a simpler way (similar to one I follow in Heroku) but all the blogs and YouTube videos go through the same tedious process.
I know I am being lazy but I just need a few clicks app deployment. Does anyone know a better (smarter) way I can deploy my app on DO from Github?
It will not be as easy with Heroku. It is always tempting to use cheaper services like Digital Ocean or Vultr and pay only fraction of the price (especially using coupon links that can make it free for months - Digital Ocean, Vultr) but having your own VPS means that you need to manage it yourself. Simplifying that process is what you pay for when you're using Heroku. But it doesn't have to be that bad.
Here is a good tutorial on how to do it:
https://www.distelli.com/docs/tutorials/build-and-deploy-nodejs-to-digitalocean/
And see this list of tutorials - search for those with "deploy" in the title:
https://www.digitalocean.com/community/tags/node-js?type=tutorials
Basically you have few options that I would consider here:
A semi-manual deploy with git - You can install a git server on your VPS and push to it whenever you want to deploy a new version
Automatic deploy with git - You can add a deployment process to you CI scripts that will do what you do manually in (1) but after all tests pass
You can trigger a pull from git on the server with ssh or a custom API
You can do (3) in your CI scripts
You can add a custom webhook in GitHub to notify your server about new version and your server may then pull the code and restart
You can add a custom webhook in CI and do the same as in (5)
Related
Okay so i recently finished my portfolio and i wanted to host it on netlify through github but it failed.
Their docs and build log are so confusing that i do not know how to trouble shoot the problem. However, when i ran
npm run build
locally on my system and then i dragged it onto netlify, it worked.
I'm not saying i cant just keep doing this for all my websites but i would like to know any potential reason as to why it didn't work when i tried it from github.
For context, the current node version is 16 and the one i am using on my system is version 14. I'm not sure whether that is enough to affect the build from github but i just thought i would mention it. if However, that is a reason as to why it isn't deploying from github then how do i fix it?
Is it throwing errors when you are deploying your site from GitHub or what? I am sure you have created a GitHub repository and logged/signed into netlify with GitHub (and authorize it). And from there(netlify's dashboard) to Team overview > Add new site > Import an existing > GitHub (it will again ask for authorization) > Pick a repository > and > Deploy site (with default settings).
This should pretty much deploy your website without any troubles. Now you can also try commit to your GitHub repository and it would automatically trigger deploy of your website on netilfy (what you call a continuous deployment).
I'm getting lost in the heroku documentation but I've basically finished the following steps and now I want to view the webpage showing the app (not on my local machine but on the web).
1) I've used package.json to specify the build of my node.js project
2) I've used a pipeline to connect my github project black-tomcat-dev/heroku-node-test to my main heroku app so once I update my own github repo it updates the main project.
3) Ive created express.js routing command to get to make a cool page that creates smileys.
**EDIT How does the pipeline work How can I push code from my black-tomcat-dev repo to the test environment in my main heroku app
This is a heroku, node.js and github question.
Pipelines in Heroku is basically a collection of individual Heroku apps. All the apps literally shares the same code between each other. It is similar to Continuous Delivery. Where it flows like
Review --> Development ---> Staging ----> Production
As you have connected GitHub with Heroku already, for every pull request, Heroku will automatically create an app (here, review app).
When you merge the pull request to master branch in GitHub, Heroku will automatically deploy the branch to Staging.
From the staging, you need to promote your app to production. This can be done either from Heroku environment or through command line - heroku pipelines:promote
Since you have only one app, this doesn't require pipeline. So, once you deploy to Heroku, you can directly open the app using command line:
heroku open -a <your_app_name_here>
Let's say I have an Azure App Service web app at foo.azurewebsites.net. The code for the web app (a simple Node.js server and React frontend) is hosted on VSTS, and a custom deployment script is configured build and deploy the web app every time code is pushed to the repository's master branch. In other words, the standard web app configuration.
Now, all of my API code (just a Node.js server) is in another repository on VSTS. I'd like to be able to do the following:
Have all requests to foo.azurewebsites.net/api be handled by the API server (an implication of this, which I would nonetheless like to state explicitly, is that the server can ask the browser to set cookies that the web app can then read, and vice versa).
Set up similar continuous deployment for the API server, such that it gets redeployed whenever there are code changes in the API repo.
Be able to maintain the web app and API repositories completely separately.
This seems like a fairly standard scenario...is there an accepted solution? I came across this, but it seems like a pretty hacky way to do it, not to mention the fact that I have no idea what the correct URL is for the web hook for VSTS and can't seem to find any information on it. Also, that example doesn't cover how to deal with point (1) above.
EDIT: Additional clarification
Note that the accepted answer on this question is not what I'm looking for. It describes how to pull from a second repository at deployment time, but not how to have that second repository trigger deployments, or how to handle the fact that the the second repository is its own server. Additionally, it introduces a dependency between the two repositories, since the deploy.cmd is presumably under source control in the first repository.
EDIT: Virtual Directories
Thanks to #CtrlDot for pointing out that Virtual Directories are the way to solve (1). Still seeking guidance on (2) and (3).
I think the concept you are referring to is called Virtual Directories
I'm not sure which VSTS task you are using to deploy, but based on the article provided, you should be to configure it to target only the virtual directory you want to deploy to.
EDIT
Sorry for not being more clear. The AzureRmWebAppDeployment task has a parameter for virtual application name. You would simply set that in your deployment pipeline for the API project (/api) and for the main project (leave it blank)
I'am looking for a simple and straightforward way to deploy a node application from the repo service (bitbucket or gitlab) to a separate server/vps.
I want to proceed so that a push to the repo would trigger a deploy on the server (one for a staging environment and one for production) When initially looking into this I get uncertain on what would be best, easiest, most efficient, best practice and so on. What tools should I pick, a gitlab runner or is it possible with pm2, some webhook or some other node npm service that could be installed on the vps for this? Any suggestions or links to further info would be appreciated.
I would suggest you trying CI/CD tool like Jenkins, but I needs to be run separately.
You can set cron at Jenkins to check repo changes, it's the easiest way. Better way would be using webhooks like Bitbucket Webhook Jenkins addon. Here is setup guide for Gitlab.
Jenkins installation guide
I'm building a Node.js application and I'm using Heroku as my host. I want to be able to maybe have a development subdomain for my app where I can test changes before I push it into production. It'd be great if I could do something like git push heroku dev, and access my prerelease code at dev.myapp.heroku.com or something similar. Is something like that possible without having to set up an entirely separate app? If not, how would I configure the toolbelt to push to 2 different Heroku apps from different branches of the same repository?
I usually just create another app for staging
then add the remote for the new app like
git remote add staging https://git.heroku.com/staging.git
then you can push your development branch to the staging master branch like
git push staging development:master
i think it's actually kind of nice to have 2 different apps, so you can try out new settings or addons without messing with your production instance.
you can always add a dev.yourapp.com as a domain for this app, then point your dns to it. here is a link to a detailed way to do that
https://devcenter.heroku.com/articles/custom-domains#add-a-custom-domain-with-a-subdomain
Very easy. Use Heroku Pipelines.
You put your Dev app and your Production app in a pipeline (you might want to also add a Staging app in the pipeline - up to you).
The you push to your dev app from your development environment.
Test everything in the dev app, and when you're satisfied, you simply "Promote" the compiled slug to the next phase in the pipeline.