How to install your own parse-server on OpenShift

Few 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:

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

Go to Choose a type of application in your OpenShift Online account, paste this URLhttp://cartreflect-claytondev.rhcloud.com/github/icflorescu/openshift-cartridge-nodejs
into “Code Anything” textbox at the bottom of the page and click “Next”.

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”.

If you use rhc, run the following command to set up you Parse APP_ID and MASTER_KEY

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 MongoLab to do it for you. I will write a detailed guide for a scalable solution with MongoLab.

Update 2:

After running for a month a set-up with scalable parse-server on OpenShift and MongoLab(mLab), I cannot in my right mind suggest it to anybody. It performed badly and unstable. Some times it was slow, some times unresponsive and there were quite a few outages. I am not sure if the connectivity between OpenShift and mLab is a problem, or it is the mLab itself. So we are back to an all-in-one instance, which works really good. I will do another update about a scalable solution when I will figure it out.

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

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.

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.

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.

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.

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?

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 ./

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?

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?

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

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.

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

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.

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

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

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?

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

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

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.

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}”

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?

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.

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

I tried cloning the repository locally using git clone from my cartridge on openshift in order to modify the code but it seems to have only few config files and nothing from the parse server code. What am I missing here?

The same query works well on Parse.com.
From Parse documentation, the error code implies that perhaps this is not implemented for users table.
Do you have any idea what might be missing on the self hosted implementation?

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

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.