UPDATE October 2017: As of today, OpenShift 2 is officially reached its end of life and is shut down rendering this guide irrelevant. I will keep it here for historical purposes.

Please note that this guide was for version 2 of OpenShift cloud platform. parse-server-example supports OpenShift 3 platform out of the box, so there is no need for any external guide.

TL;DR just take me to the instructions

parse-openshiftFew months ago I was consulting a start-up called AbiliSense on their cloud solution. They build this amazing mobile app for people with hearing disabilities. After understanding their service needs we decided to go with Parse BaaS solution, and it was all good until the dramatic Parse Announcement  about the retirement of their services. So there was a bit of frustration … But then we realized that parse-server gone open-sourced, so I said: You know what, this is even better! We will still use it as before, but now we will also own it!
Most of the functionality work out of the box, including cloud code. And also push notifications are implemented now as well.
There are guides on how to run it on many different cloud platforms. But not for OpenShift. Installing parse-server on OpenShift is a bit tricky, because of an outdated stock node.js and MongoDB cartridges. Luckily, this guy: icflorescu already created custom  node.js and MongoDB cartridges, that are up to date. So we are going to use these custom cartridges with more recent versions. Some people also have reported running into issues because of an old GCC version, but it seems that now parse-server does not rely on any native modules that require recent GCC version, so there should be no problem here. I tested it personally and it worked like a charm.

So let’s dive in, and see how you can run your self-hosted parse-server on OpenShift:

With Deploy to OpenShift button:

Deploy parse-server to OpenShift

IMPORTANT: after that follow the instructions in step #4 of web console steps to configure you APP_ID and MASTER_KEY

With OpenShift Client Tools(RHC):

First Installing the Client Tools (RHC), if you don’t have it already.

Using a web console

  1. Go to Choose a type of application in your OpenShift Online account, paste this URL
    http://cartreflect-claytondev.rhcloud.com/github/icflorescu/openshift-cartridge-nodejs
    into “Code Anything” textbox at the bottom of the page and click “Next”.
  2. Set your public URL, paste a modified for OpenShift parse-server git repo URL: https://github.com/antt001/parse-server-example into “Source Code” textbox and click “Create Application”.
  3. Add custom MongoDB cartridge to your new OpenShift application, go to “See the list of cartridges you can add”, paste this URL http://cartreflect-claytondev.rhcloud.com/github/icflorescu/openshift-cartridge-mongodb into “Install your own cartridge” textbox at the bottom of the page and click “Next”.
    1. If you use rhc, run the following command to set up you Parse APP_ID and MASTER_KEY

      replace myAppId and myMasterKey with your actual app id and master key
    2. If you don’t – then clone your OpenShift application repository with git using “Source Code” link from the application details in web console, and modify “appId” and “masterKey” values in index.js file

      replace myAppId and myMasterKey with your actual app id and master key, commit and push you changes to remote.

Live long and prosper, and enjoy you own parse-server on OpenShift.

Update 1:

This is an all-in-one solution, where you have your node.js server and MongoDB running on the same machine. This is good for development, testing or small-scale production(one small gear can handle around 60 requests per second, which is twice as much as Parse.com free tier). This is not a scalable solution. If you want a solution for a large scale production you will need to run a MongoDB cluster(don’t do it, unless you are an expert in MongoDB clusters) or use external services like mLab to do it for you. I will write a detailed guide for a scalable solution with mLab.

 

How to install your own parse-server on OpenShift
Tagged on:                 

83 thoughts on “How to install your own parse-server on OpenShift

    1. Most probably your parse-server failed to start, the common reason for that is, that you didn’t set APP_ID and MASTER_KEY correctly. To know for sure you need to ssh into your gear and check the logs. Try tail_all command from openshit shell. It also could be a problem with installation, or with MongoDB connection.

  • Another question is if it’s possible to install Mongo db in another gear so that another 1G space will be available. Thanks.

    1. Yes. It should be possible, but it is not covered by this guide. You can create a gear(a node gear for instance) and add to it a mongo cartridge as it described here cartridge. Then use “rhc port-forward” to allow external access to your database, and update connection string in parse.

  • Thanks for the guide! Used your deploy link but the app fails to start saying:

    You must provide a serverURL!
    /var/lib/openshift/56dc08a77628e1f9e4000203/app-root/runtime/repo/node_modules/p
    arse-server/lib/requiredParameter.js:8

    How to fix this?

      1. This is strange, serverURL should not be a problem. Are you sure you set your Parse APP_ID and MASTER_KEY correctly as described in step #4?
        I am getting this error(‘You must provide a serverURL!’) when my APP_ID and MASTER_KEY are not set. Anyway, thanks for the update! I updated the repository with serverURL. So it should be fine from now on.

  • Awesome! Just all the good words use to this material! Thank you from the base of my heart as well as spirit and I will certainly come see once more if you maintain up the excellent work!

  • Hello,

    Which address did you use to migrate the parse DB to openShift DB, the mongodb_uri is not working for me.

  • Hi,

    Thanks for putting this guide together. It worked for me the very first time 🙂

    I have two questions:
    1. How can I go about updating the parse server code when there are updates on github?
    2. How can I set up parse dashboard?

    Thanks

    1. Hey. These are very good questions.
      1. I will put together a guide for it, but basically you should clone a repository of your OpenShift instance and add a github remote. Then you should fetch from github remote, merge to local master and push to OpenShift.
      2. For now you can use somekind of mongodb front-end. I heard a rumor that Parse team are working on it. In the meantime, i have plans to do an admin panel for our parse-server, and than I will release it on github.

      1. Hi, thanks for your reply. The Parse team already open-sourced a stripped down version of the Parse Dashboad (https://github.com/ParsePlatform/parse-dashboard). That’s the one I’m referring to. I want to hook that up with my Parse server on Openshift

        Something else: I tried to import an existing Parse.com app to my OpenShift app. I tried using the MONGODB_URL: mongodb://127.x.y.z:27017/dev as my database connection string but I got the error “No reachable servers”. I’m I doing something wrong? How can I best migrate my existing apps from Parse.com?

        Thanks a bunch!

          1. Port forwarding is on… Is there a default username and password (I assume not). Also is the database name ‘dev’ correct?

            I’ll need to find a way to inspect the database…

            Any ideas?

          2. Hi, first of all, the release of parse-dashboard is a great news, that I missed somehow. So, thanks for sharing! By looking at it, I would suggest deploying the dashboard to a separate gear on OpenShift, and then setting your appId, serverURL, masterKey and appName in Parse-Dashboard/parse-dashboard-config.json.
            You can also run a dashboard on you localhost as they pointed out in the readme.md and it can be used to inspect you db. Other than that, I just use mongo cli with port-forward
            2. dev name in incorrect. The correct DB name is ‘parse-server’. So after running rhc port-forward command, I restore my DB like this: mongorestore -h 127.0.0.1:27018 -d parse-server ./

          3. 1. You’re welcome. I’ll give setting up parse dashboard in a separate gear a shot (though I’m not that familiar with OpenShift but I bet there’s enough help online)
            2. I’ll update the database name and try again. Why is it necessary to “restore” the db?

          4. Hey, it’s not necessary. It is just an example. I did it because I had a backup to restore, when I moved my database from MongoLab

        1. Hi. Just add this: app.use(function(req, res, next) {
          if (req.headers['x-forwarded-proto'] == 'http') {
          res.redirect('https://' + req.headers.host + req.path);
          } else {
          return next();
          }
          });

          after line 66: var app = express();
          in index.js

          1. Hi,

            I tried installing two instances of the parse server/dashboard as separate openshift applications and it seems like both instances were using the same MongoDB. Could that be the case (e.g. because of the same localhost port)? Do you know how I can safely run to non-interfering instances of the parse server?

            Thanks!

          2. Do you want run two parse servers in the same gear? It is not supported. Alsp if it is a small gear, i am not yit can handle it properly. If your goal is to have 2 parse applications, than I saw someone did it. The should be a pull request for it on official parse-server git repository

          3. Not in the same gear. I tried to run two parse applications each in its own openshift gear. Do you know the pull request ID so I can track it?

  • Hi,

    I made some progress with setting up the Parse dashboard! I’ve prepared a draft guide available here (https://goo.gl/gF4qaH). There are still some open items at the end of the document. Do you have any idea how I can tackle those issues? Feel free to add comments to the document or respond here. Thanks.

    1. Sorry, I didn’t get a chance to review your document. I have a lot of work at the moment. I will review it when I’ll have some free time.
      Thanks

          1. Yep. First of all – geat research job. Second: i don’t think it’s good to just install this in a working directory abd execut manually. We should better merge it to with parse-server repo in some subfolder, that way you won’t be worried about instance restarting or reinstall

          2. Yep. Give me annotation or edit access to a document, and I will leave my notes for each issue. Great research job, btw! In general host is stored in environment variable and you can access it from the code and i would rather put dashboard as a subfolder of parse-server if not separate gear instead of installation in user directory and manual execution.

          3. i added my comments to the document. Let me know if you need any more assistance with that.

          4. Thanks for your comments. I’ll find time to process them and get in touch if I need further clarification

  • Hi folks

    I installed the parse server in OpenShift without problems, but when trying to use the POST test page, it returns me { “error”: “unauthorized”}

    What can I do ?

    1. Hi! The app id in your test page doesn’t match the app id in your parse-server. You can set your app id in public/assets/js/script.js replace myAppId with correct one. Lines 136 and 143

      1. P.s. This will expose your app id to any body who can read javascript. So better remove it right away when you are done testing

  • Hi,
    I have an android app on parse
    Well, now I must have a parse server
    and only free thing I’ve got is openshift
    But I have no experience
    and I want the new one to be parse exactly
    I followed the tutorial
    But I can’t see my files here or the dashboard
    So can you help me with a more detailed guide?
    Thanks for your great effort

    1. Hi, i am working on adding a dashboard to this guide. I will update a template to include dashboard that is pre-configured.

      1. Well can you see
        Adminca.com
        And how to migrate all files from parse to this openshift?
        Thanks for your soo much help

        1. The file migration of Parse is not supported yet, as far as i know. But you files should still be accessible from your OpenShift installation even though they still on parse.com

  • Can you please notify me when I can migrate everything to openshift and have a dashboard installed
    (A complete tutorial)
    Well I thank you so so much because of your great help if you’ll make a complete tutorial
    Thanks

  • Thank you very much!
    Great start for a small free hosted parse server 🙂
    Is there any way we can manage the database to see size usage etc. ?

  • Hi antt
    Thank you very much for server and dashboard
    Well you helped me so much
    Now I want to ask you how exactly migrate from parse to mongodb
    Is it also with openshift or how
    Can you send me a complete tutorial for it?

  • And I opened parse dashboard but it requires username and password
    I tried app id and master key. Well, it didn’t work

    1. did you configure the app id and master key properly? Did you do it with rhc or did you write it into index js after cloning with git?

      1. Yes, it was not configured. It is solved now.
        But just one thing. How to create a mongodb database on an openshift gear and migrate from parse to it instead of mlab.
        Note:- I succesfully made the dashboard take the classes from mlab

          1. Thank you very much
            Now I’ve got parse server working with mlab
            Now just some questions:
            1. Is mlab 500gb enough?
            2. When will we migrate files to the server?
            Thanks very much antt
            I was 10 seconds before I pay to digitalocean

          2. hi. mlab’s 500gb is more than enough for us, but it is a sandbox service and, as mlab is saying it out loud – it is not suitable for production. we had some performance and availability issues with it, and we consider to move our data to the shared cluster, which is $15/month. we are currently hosted on azure documentDB which is not working out for us as well. it supposed to cost around $160 while we have about 10mb of data. AFAIK parse doesn’t have the file migration path, but they promised to release it. Your old file will be still accessible from their service even after migration (you will have to configure the correct file key) and your new files will be stored in gridfs(which is a mongodb collection) in your new db, e.g. mlab.

        1. This mongo cartridge is not really suited for production or scalable solution. It is also not configured for authentication or any type of security, since it is not accessible for outside world. I will suggest you to stay with mLab for now. Just connect you parse server to it with “rhc env set MONGOLAB_URI={YOUR_MLAB_CONNECTION_STRING}”

  • It says
    No such module
    For
    parse-image
    Any alternative for parse-image or How do I get it working.?
    Can u help me Antt?

  • I knew why
    Because parse-image isn’t found in parse server
    I found a npm or whatever parse-image on github.
    But how do i install it in windows?

    1. on windows run in console npm install --save parse-image form your server folder. This will add parse-image as dependency to package.json. To test it locally you shoud run npm install.

      1. Well I tried it.. It gives an error
        And I searched for its issues on github. They say that it is configured for os x and ubuntu not for windows…
        Any help?

  • Hi,

    First, thanks for this very helpful guide. installing was a breeze. I have a question regarding the actual usage – when I called Parse API from my app, I use a REST API key. Now, I do not see where I can configure such a key so it will be identifiable by the server. Should I use the master key instead? this is unsafe. Is there a way to configure a rest api key?

  • Hi,

    when I attempt to migrate my data from Parse to the new server, what path should I place?
    I’ve tried using port-forward and then placing this path “mongodb://127.0.0.1:27017/parse-server”
    as indicated above but its probably wrong as it didn’t find the server. Please advise.

    1. Hi. You cannot migrate data using port forwarding. You will need a separate db publicly available through the Internet, like mLab. You can migrate data there and then set your server to use it from there

    1. Hi, you have server settings in index js file. you should see there ‘var server = {‘ and all the parameters underneath. you can add your settings there

    1. oh, i know why. it is because your query is url-encoded. replace all the %3D with an actual = symbol and %2C with , symbol

  • Hi,
    I’ve integrated before accounts ( sign up and sign in and reset password) with parse
    ..
    Now, signing up and signing in is working….
    But resetting password isn’t working…
    Any help?

  • Thanks for this Parse Server setup. My ParseServer is now happily running on OpenShift!

    But I’m not able to access the Parse-Dashboard at the default location …/parse-dashboard
    The first time I access the page I am asked to sign in – after which all I see is a 404 page

    Any ideas?

    1. Hi, so you heed to setup a valid publicServerURL, appName in your parse-server settings in addition to emailAdapter. and don’t forget to set up a module.

      server: {4
      ...
      // The public URL of your app.
      // This will appear in the link that is used to verify email addresses and reset passwords.
      // Set the mount path as it is in serverURL
      publicServerURL: 'https://myserver.com/parse',
      // Your apps name. This will appear in the subject and body of the emails that are sent.
      appName: 'MyParseApp',
      // The email adapter
      emailAdapter: {
      module: 'parse-server-simple-mailgun-adapter',
      options: {
      // The address that your emails come from
      fromAddress: 'me@myserver.com',
      // Your domain from mailgun.com
      domain: 'myserver.com',
      // Your API key from mailgun.com
      apiKey: 'key-6456547657567',
      }
      }
      }

      you will also have to add “parse-server-simple-mailgun-adapter” as a dependency to your package json


      "dependencies": {
      "express": "^4.14.0",
      "parse-dashboard": "^1.0.19",
      "parse-server": "^2.2.23"
      "parse-server-simple-mailgun-adapter": "^1.0.0"
      }

  • Hi there, I am wondering why the app settings in the dashboard is gone?

    So the only option to set the mailgun apikey and publicServerURL is in the index.js?

    How should I insert the “from address” since i grab the from address from a static form insert by my visitor? I did that with request.object.get() in cloudcode previously but not sure index.js is same as cloudcode.

Leave a Reply

Your email address will not be published. Required fields are marked *