Play Framework Application and embedded Database packaging - mongodb

I implemented a server application with Play Framework.
I built native packages for different Operating Systems (Linux, Windows, Mac OS X) with SBT Native Packager.
This application requires a NoSQL Database. In particular, I am using MongoDB. Is there a way to embed MongoDB binary/package in my native package? Is this the best practice? Or do you suggest to install MongoDB and my Play application with two different packages?
If it is not possible / recommended to embed MongoDB in a package, do you suggest another DBMS (for instance Nitrite Database)? Thanks

This is not really best practise. Play has H2 in-memory DB embedded but this is only intended for development (because it is quicker than something that reads/writes to disk as well).
You really want to have your Mongo (or whatever other data store you decide to use) instance running in a different process, and packaged, deployed, stopped, started separately from your Play application.
You could probably figure out how to package it with your Play application and then have some script run during app startup to setup the database and load any existing data in -dbpath ie. whenever you redeploy/restart your application. But then you would have to stop/redeploy your Mongo binaries each time you redeploy a code change. You may update your application several times over a year but you are unlikely going to want to update your Mongo binaries as often. I could go on, but don't do it. It is best practise to manage your data stores separately from your applications.

Related

Can Electron apps bundle VueJS, MongoDB, etc. or do they need to be installed on users PCs for the app to run?

I've been looking for over an hour and can't find an answer on this, not even on docs and the ones I have found are just too confusing. I want to know before starting to use Electron if the built apps with electron-bundler or any other bundlers can bundle Vue & MongoDB, so that when a user installs the Electron app - he doesn't need those libraries installed on his computer, but can use the app straight ahead.
I know it's a noob question, sorry, but I'm just too confused about all of this.
Vue, like all other Client SPA frameworks, is designed to build static assets that can run "standalone" in a browser. So it is straightforward bundling those assets in an electron app.
MongoDB, like most Server databases, is totally the opposite: it is designed to be installed once, run as a service, and Clients (including your electron app) connect to it (usually through a network). So it is very difficult bundling it in a standalone installer, not even talking about a portable app. The repo linked by Andrei Gheorghiu is an example of such architecture: it does not bundle the Mongo service, but connects to it.
If you look for "electron database" keywords, you will find plenty resources about this subject. The key is to look for self-contained / embedded databases, like SQLite. There are also some NoSQL alternatives, e.g. NeDB.

Can we create a local database for my application without making it dependent of the OS in which it is installed?

I mean, for example, installing a database using a webserver then deploy the database with my application without more configuration, just a portable database, is it possible? Currently my mongo database is installed and dependent of my computer system, I would make it portable, it is possible to build a database upon my webserver, hence make it portable?
Any hint would be great,
thanks

Play Framework Running in Dev Mode

I'm looking for some suggestions on how I could manage external dependencies when I want to run my Play framework based app locally.
I have a Play based application that connects to a database to look up application data. In order to run this against a specific environment, it is not a problem, but what if say I want to run this locally? With the current setup, if there is no database available, my app would just not start! I mean, without a database running my application also has no meaning as I could not do anything without data!
I'm using MongoDB as my database, so I see the following possibilities to enable running my application locally!
Use in memory mode from MongoDB
Use some sort of docker container to run a MongoDB instance locally
Is there any other possibility that is worth exploring?

Should i use the Mongo DB that comes with meteor?

When creating a Meteor app., Mongo is installed by default and runs automatically when I run my app. In the past, with other non-Meteor apps, I have always tried to place my app code files and database on separate servers to ensure that I can scale them independently. It feels as though this default Mongo install is a convenient way simply for Meteor to use a database out-of-the box, just to get you going. Thinking ahead, I want my app to scale, so should I start thinking about using a Mongo instance on separate server and, if so, what process do I go through to detach this default Mongo instance from my Meteor app?
The instance of mongodb that comes with meteor is only for use when developing your app. In a production environment, you should either install your own mongo instance or use a service.
I strongly recommend using compose.io in production. We've had a really good experience with them and the most basic deployment comes with access to the oplog which is critical for scaling your app.
Either way, in production you will provide two URLs to your app via environment variables:
MONGO_URL
MONGO_OPLOG_URL (this is optional but strongly recommended)
If you go with compose, here is the guide for integrating with meteor.

Web framework with user-friendly desktop deployment?

I'm building a web app with Backbone.js (I'm not tied to Backbone yet though). I need a back-end framework only for persistence to a database via a RESTful API. However, I also need to able to deploy it as a 'desktop' app for off-line use, i.e. running a local server and launching a browser window, but I don't want users to have to start a server from the command line to run the application.
I can use SQLite as a database since it's only a single user application, it's just the framework that I'm stuck on. I have looked at the following:
Rails and Django: Default web servers are too flimsy, requires Ruby/Python and runs from the command line. I'm aware of the Bitnami stacks but at 99mb it's too big of a dependency and not exactly hidden from the user.
Sproutcore: Run from command line, also too bulky.
Pyjamas Desktop - Depends on MSHTML which I suspect limits my ability to use HTML5 features.
I'm leaning towards creating a Java app that starts a Scala/Lift server instance and opens a web browser, then sits in the system tray (kind of like WAMP). Is anyone familiar with a tool or framework built for user-friendly deployment as a standalone desktop app?
I do not know if PHP is an option for you? Then I would recommend phpdock.
web2py has a standalone deploy-to-desktop feature with no dependency on Python: http://web2py.com/books/default/chapter/29/14#How-to-distribute-your-applications-as-binaries
As Eydun said, phpdock is an option but it's commercially licensed .
I settled on using Java/Spring/H2/Hibernate/Jetty. I find that Jetty serves requests VERY quickly so the application looks real-time when launched in a browser. There is a tutorial on embedding the Jetty server here. I imagine it's quite trivial to build a GUI that launches the server and a browser.
Another Java option is to use the Play Framework, which may be more at home to those coming from a Django/Rails background. However, the documentation for "creating a standalone version of your application" for Play 2.0+ indicates that they have ditched using Java EE containers (Tomcat/Jetty) and WAR files in favor of running the JARs with the bundled copy of JBoss Netty, so it may take a bit of work to get it running the way you want it.
I would recommend the Play Framework approach if you're OK with using/learning Scala.