Integrate MongoDB with Sinatra
This quickstart guide will help you to integrate your Sinatra application with MongoDB service on App42 PaaS.
Kontena – Kontena is a lightweight container that will run your apps and services in an isolated and secured manner. You can specify the power of the Kontena while setting up infra or creating services. One Kontena power specifies to 256 MB Memory and 128 MHz CPU.
Service – Services in the App42 PaaS are add-on components which are needed in an App. App42 PaaS supports multiple services like SQL databases, NoSQL databases and more.
Once you have created the MongoDB service, You also need a configuration file for mongoid, which is a gem that helps us bind our models to MongoDb. This should look familiar, as it’s just a yaml file exactly like you usually work with in rails:
sessions: default: database: < database name > # Database Name hosts: - < host >:< port > # VM Ip and VM Port username: < user name > # User Name password: < password > # Password options: consistency: :strong # In the test environment we lower the retries and retry interval to # low amounts for fast failures. max_retries: 1 retry_interval: 0
You can also use our Sample Apps and extend it to suit your needs. Here is the link to Sinatra MongoDB Sample App
$ app42 update Enter App Name: javademo 1: Binary 2: Source Choose Upload Type [Binary]: 2 Updating Application... OK Operation is in progress, Please wait...- App deployed successfully.