Code Monkey home page Code Monkey logo

mongolab-openshift-quickstart's Introduction

MongoLab OpenShift Quickstart (Node.js and MongoDB)

###Step 1. Create an OpenShift account and application###

Create an account at http://openshift.redhat.com and install the rhc command line tool on your development machine. For more info about rhc, see https://openshift.redhat.com/community/developers/rhc-client-tools-install.

Once rhc is installed, create a nodejs-0.6 application using the path to this repository as the --from-code argument and by replacing with your desired application name:

> rhc app create <app name> nodejs-0.6 --from-code https://github.com/mongolab/mongolab-openshift-quickstart
> cd <app name>

rhc initializes your application using this repository as a baseline.

###Step 2. Create a MongoLab account and database###

  1. Sign up for an account at http://www.mongolab.com. When successful, a database landing page with no databases displays.
  2. Create a database. Be sure to specify a database user name and password. These credentials are not the same as your MongoLab account credentials.
  3. Click on your database. The database landing page provides a mongodb URI connection string of the form:
  mongodb://<user>:<password>@host.mongolab.com:12345/my-db-name
  1. Copy this value somewhere helpful and replace placeholders with your database user credentials.

###Step 3. Commit and deploy the app### When you created your app, the rhc command line client automatically initialized a git repo with a remote link to OpenShift. The code is also already deployed to your app gear.

If you don't make any changes, you can skip this step. However, if you make any modifications (now or later), perform the following to update the code on the gear:

    git add .
    git commit -m "my first commmit"
    git push

###Step 4. Configure environment variables on the app gear### The example code uses mongodb://localhost:27017/test when the MONGOLAB_URI environment variable is not available. This is sufficient for testing locally with your own mongodb, but not for production.

Fortunately, the rhc client allows you to configure your environment variable without placing credentials in a repository (see Custom Environment Variables for more information). Use the following commands configure your production URI and restart your app.

    rhc env set MONGOLAB_URI='<db uri>' --app <app name>
    rhc app restart --app <app name>

db uri is the mongodb URI you obtained in Step 2, with your database user credentials added.

Note: Though there are repository-driven methods for configuring this environment variable that meet your requirements, we find that configuring this value outside of the code (and not storing it in a repository) allows for maximum security and flexibility.

###Step 5. View the app###

Visit your deployed app at:

    http://<app name>-<app namespace>.rhcloud.com

###Questions? Email [email protected]

mongolab-openshift-quickstart's People

Contributors

banzaiman avatar esedor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mongolab-openshift-quickstart's Issues

Fails to create app with current node version

Running the following command on openshift fails.

$ rhc app create nodemongo nodejs-0.10 --from-code https://github.com/mongolab/mongolab-openshift-quickstart
Creating application 'nodemongo' ... 
The initial build for the application failed: Shell command '/sbin/runuser -s /bin/sh 5612d4c82d5271be87000071 -c "exec /usr/bin/runcon 'unconfined_u:system_r:openshift_t:s0:c6,c223' /bin/sh -c \"gear
postreceive --init >> /tmp/initial-build.log 2>&1\""' returned an error. rc=255

and

Application 'nodemongo' failed to start (port 8080 not available) 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.