67 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			67 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| ---
 | |
| title: Deploying to Openshift
 | |
| ---
 | |
| If you deploy your applications to Heroku you can only upload 5 applications, if you want to deploy a new one, you need to verify you account with your credit card.
 | |
| 
 | |
| 
 | |
| 
 | |
| These are the steps you need to follow to deploy to <a href='https://www.openshift.com/app/account/new' target='_blank' rel='nofollow'>OpenShift</a>.
 | |
| 
 | |
| ## Requirements
 | |
| 
 | |
| *   An account in <a href='https://www.openshift.com/app/account/new' target='_blank' rel='nofollow'>OpenShift</a>
 | |
| *   Our app in a [Git](//forum.freecodecamp.com/t/wiki-git-resources/13136) Repository
 | |
| 
 | |
| ## Changes in your code
 | |
| 
 | |
| *   `app.listen` with `process.env.OPENSHIFT_NODEJS_PORT` and `process.env.OPENSHIFT_NODEJS_IP`, both requires.
 | |
| *   In your **package.json** set your `"main": 'yourMainFile.js` and `"script": { "start": "node yourMainFile.js" }`
 | |
| 
 | |
| ## Deploying our app
 | |
| 
 | |
| *   <a href='https://openshift.redhat.com/app/console/application_types' target='_blank' rel='nofollow'>Add a new application</a>
 | |
| 
 | |
| 
 | |
| 
 | |
| *   Choose a name (second input will be same for all you apps)
 | |
| 
 | |
| [
 | |
| 
 | |
| *   Fill our Git URL and our branch name
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| *   "Create Application". It will take some time
 | |
| 
 | |
| 
 | |
| 
 | |
| *   Enter to "Application", then into your App and check it's started.
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| ## Enviroment variables
 | |
| 
 | |
| In my case I have my database in mLab, so I need to create some enviroment variables.
 | |
| 
 | |
| *   <a href='https://developers.openshift.com/getting-started/windows.html#client-tools' target='_blank' rel='nofollow'>Install Ruby and rhc.</a>
 | |
| 
 | |
| **rhc** only works with versions 1.9.3 and 2.0.0 of Ruby.
 | |
| 
 | |
| *   <a href='https://developers.openshift.com/getting-started/windows.html#rhc-setup' target='_blank' rel='nofollow'>Setting up Your Machine</a>
 | |
| 
 | |
| If you are having trouble with setting up `rhc`, try <a href='http://stackoverflow.com/questions/28896733/rhc-setup-gives-error-no-such-file-dl-import' target='_blank' rel='nofollow'>this</a> answer on StackOverflow.
 | |
| 
 | |
| *   <a href='https://developers.openshift.com/managing-your-applications/environment-variables.html#custom-variables' target='_blank' rel='nofollow'>Custom Environment Variables</a>
 | |
| 
 | |
| `rhc env set VARIABLE=value VARIABLE2=value2 -a App_Name`.
 | |
| 
 | |
| You need to restart your app to load the variables.
 | |
| 
 | |
| If you find a better way to solve this limitation. Feel free to contribute to our <a>Wiki</a> and share it with us.
 | |
| 
 | |
| You can check the app working at <a href='http://voting-pitazo.rhcloud.com/#/polls' target='_blank' rel='nofollow'>http://voting-pitazo.rhcloud.com/#/polls</a>
 |