I have built a nodejs app and now I want to deploy it into openshift.
I don't want to use github because I should create private repository which I cannot.
Also I cannot use 'rhc' since I am new user.
Is there any way to do that?
I cannot find any tutorial about that.
For OpenShift 3, you can use a binary input source build.
First create a binary input build.
oc new-build --name myapp --strategy=source --binary --image-stream=nodejs:latest
Now start a new build and upload source code from the current directory.
oc start-build myapp --from-dir=.
Once the build has completed, deploy the image created by the build.
oc new-app myapp
You can then expose the service.
oc expose svc/myapp
Every time you want to make a change, you will need to run the same oc start-build command in the directory where your source code is.
Is there any other code repo you are using? SVN? If SVN, you can use pipelines with Jenkins.
If not, put the nodejs app in a docker container and push it to the docker hub.
I don't see anybody to suggest this so I will do - you can equally well deploy code from gitlab, pagure, bigbucket, or any other git hosting service.
In fact you can even run your own git server inside OpenShift.
oc create -f https://raw.githubusercontent.com/openshift/origin/master/examples/gitserver/gitserver-persistent.yaml
oc env dc/git -p ALLOW_ANON_GIT_PULL=false
oc policy add-role-to-user edit -z git
oc get route # to see your git server URL
Now you should be able to push/pull from that server using your OpenShift username and token (also any other users you add to the project). From buildconfigs and other pods you can also use simply git as the hostname of your git server, because this should resolve to the IP of the service with the same name (again only within the same OpenShift project).
Read the template YAML (the URL after oc create) for more options you can use like REQUIRE_GIT_AUTH.
Of course it is good to keep a git mirror/backup somewhere else as with any other git service.
HTH
P.S. Forgot to say, you need to install an OpenShift v3 cluster by yourself or subscribe to OpenShift Online (which unfortunately may take awhile ATM).
Related
Currently, I'm working on a project which is hosted on Microsoft Azure as a resource. The project is presented on a virtual machine and is operated using commands on the Azure CLI.
Now I've been asked to create a web app for it using Node.js and React.js. I'm totally lost on how to connect the Node.js API to the virtual machine. Is there any way to trigger those Azure CLI commands through a Node.js app. Any help would be appreciated!
EDIT:
Managed to solve the issue. Used this npm package 'ssh-exec' which lets you execute commands on a virtual machine remotely after connecting using IP Address, username, password. Very simple to use.
Link to package - https://www.npmjs.com/package/ssh-exec
Managed to solve the issue. Used this npm package 'ssh-exec' which lets you execute commands on a virtual machine remotely after connecting using IP Address, username, password. Very simple to use.
Link to package - https://www.npmjs.com/package/ssh-exec
There are some few steps to connect Node.js API to VM,
Firstly, we need to clone the project that we will be deploying to the Azure VM. This project is a basic Node.js API with a single endpoint for returning an array of todo objects. Go to the location where you want to store the project and clone it:
git clone --single-branch --branch base-project https://github.com/coderonfleek/node-azure-vm.git
Once the project has been cloned, go to the root of the project and install dependencies:
cd node-azure-vm
npm install
Run the application using the npm run dev command. The application will start up at the address http://localhost:5000. When the application is up and running, enter http://localhost:5000/todos in your browser to see the list of todos.
enter image description here
Now, go to the package.json file of your project and add these scripts in the scripts sections:
"scripts": {
.....,
"stop": "pm2 kill",
"start": "pm2 start server.js"
}
The start and stop scripts will use the pm2 process manager to start and stop the Node.js application on the VM. The pm2 script will be installed globally on the VM when it has been set up.
At the root of the project, run the rm -rf .git command to remove any .git history. Then push the project to GitHub. Make sure that this is the GitHub account connected to your CircleCI account.
Then, Setting up a virtual machine on Azure to run Node.js.
Next, create a new VM on Azure and set its environment up for hosting the Node.js application. These are the steps:
Create a new VM instance
Install nginx
Configure nginx to act as a proxy server. Route all traffic to port 80 on your VM to the running instance of the Node.js application on port 5000
Install Node.js on the VM and clone the app from the GitHub repo into a folder in the VM
Install pm2 globally
Do not be intimidated by the complexity of these steps! You can complete all five with one command. At the root of your project, create a new file named cloud-init-github.txt; it is a cloud-init file. Cloud-init is an industry-standard method for cloud instance initialization.
cloud init- code
(REFER THE BELOW LINK FOR COMPLETE DETAILS)
https://circleci.com/blog/cd-azure-vm/
So I have a node js app I would like to deploy to EC2.
I'm planning on creating multiple instances of it and put it beyond Nginx for load balancing.
I know I can use AWS Beanstalk but I think it's over provisioning stuff I don't need.
My question is about the app update process. I thought of two options.
The first one is to create a bare git repository on the EC2 and every time I push some changes, it will hook into the after receive event, create new instances of the app and update Nginx to switch to the new instances.
Another option is to work with Amazon ECR and containers. Every time I update my app image at ECR, it will send an event to the EC2 machine (I'm not sure it is even possiable) to create new instances of the app and again, tell the Nginx to switch.
Which one do you think is preferred?
Here is the deployment method we used
1)Created git bare repo in ec2 server and its tracked with production branch.
2)in the post-receive hook
#!/bin/sh
git --work-tree=/var/www/domain.com --git-dir=/var/repo/site.git checkout -f
cd /var/www/domain.com && npm install && forever restart app.js
3)In the nginx configuration
{
proxy_pass:https://localhost:3000
}
Note:
You can customise post hook to check if its first deployment then run npm install otherwise run npm update.
I hope this will help to solve your issues
I have a great working website built with MEAN and works great locally.
i wish to deploy it on my server,
but i never deployed a website
other than uploading the files to my website ftp.
Tutorials anyone?
Another good starting point would be Digital Ocean, they offer a one click install MEAN stack, with tutorials. https://www.digitalocean.com/community/tutorials/how-to-use-the-mean-one-click-install-image
I have just deployed my MEAN Stack application on Heroku cloud application environment. The deployment steps are easy.
Steps to deploy:
Your mean stack project structure should be like this. This is very important step. The bottonline is your package.json and server.js should be under your root directory. Have a look at the link to know more about the structure.
Clone your remote repository locally i.e. git clone https://github.com/heroku/node-js-getting-started.git
Go inside the cloned repository e.g. cd node-js-getting-started
Run git add .
Run git commit -m "Sample"
Run Heroku login (It will ask you to press any key and then open up the browser and ask you to click login. After logged in closed the browser instance.
Run heroku create myApp --buildpack heroku/nodejs. Note: Buildpacks are responsible for transforming deployed code into a slug, which can then be executed on a dyno. More information
Run git push heroku master. Your deplyment will start.
Once deployment is done, you will see the complete deployment logs on command prompt terminal
The application is now deployed. Ensure that at least one instance of the app is running: heroku ps:scale web=1
Run heroku open. It will run your deployed instance.
Run heroku logs to view information about your running app. More information
You can find more details visiting following links:
https://devcenter.heroku.com/articles/getting-started-with-nodejs#prepare-the-app
https://devcenter.heroku.com/articles/deploying-nodejs
Start from here...
https://github.com/linnovate/mean#hosting-mean
What operating system do you plan to host it on?
I am new to heroku and I am trying to create an app and deploy, but when i do heroku create on CLI this creates a random name for the application. So I used heroku app:create project-name which created the application with the project-name but how do i deploy my existing code to that application.
If you've already performed heroku create without specifying a name in your application folder then you will already have a git remote named heroku. You can confirm this by doing
git remote -v
in your project folder which will probably show something like
heroku git#heroku.com:stark-taiga-7738.git (fetch)
heroku git#heroku.com:stark-taiga-7738.git (push)
When you then create an application specifying an application name then the existing remote will not get updated with the new application details.
To fix this you will need to remove the existing git remote named heroku and then add a new one pointed to the correct application.
git remote rm heroku will remove the existing remote
heroku git:remote --app <new app name> will create a new heroku remote pointing at your new application will then let you do git push heroku master and deploy to the correct application.
Heroku uses Git to deploy. Navigate to the home directory of your application and simply do
git push heroku master
See the documentation for deploying a node.js application to Heroku for details.
I am a node.js developer. I have used Heroku and Joyent's no.de platform before .
For both of these platforms , the deployment used to be simple
git push heroku master ( Heroku )
git push joyent master ( Joyent's node)
The above commands used to do the magic . They enabled me to push the code from my local machine to the cloud server, deploy it and automatically restart the server .
Now I am planning to use Amazon AWS as its more configurable to my needs. How do I setup a similar thing on Amazon EC2 for continuos deployment ?
I am using an Ubuntu AMI.
Is there any tool that help me achieve this ?
If there are any resources/tutorials that might help me - please let me know.
Thanks !
That auto-deploy mechanism is implemented with Git Hooks. The most likely hook used is post-update.
It's a simple bash script that is executed on a git push; put one in a git repository on your EC2 server including the code to re-run NPM (if needed) and restart your code.
That's should do it. :)
Use roco - deployment solution inspired by capistrano, working great with express/railwayjs + git + upstart. If you have another env feel free to customize it using Roco.coffee
It also can be simply configured with post-update hook to work exacty as in heroku and joyent.
Here is tiny tutorial for this tool: http://node-js.ru/4-deploy-with-roco
Check out AWS Elastic Beanstalk
It lets you deploy your application to an amazon ec2 instance by running:
git aws.push --environment testing
// or
git aws.push --environment production
The documentation page contains a lot of quality information to get your started!