Felix Rieseberg

Running your own Parse with Azure and Docker

It's always sad when a great developer service rides into the sunset - but in the case of Facebook's Parse, one has to commend the excellent handling of the shutdown. Thanks to a just released open-source version of the Parse core service, you can run your own version of Parse. In this post, I'll explain how to get up and running with Parse and Docker on Azure. The cool part - it'll only take a few minutes.

Components

This puzzle has only two pieces: A Docker Image that contains MongoDB, Express, and Parse - and an Azure Deployment Template, allowing you to spin up an Ubuntu Server with Docker and the mentioned Docker Image preinstalled. Obviously, nothing keeps you from running the image in a different cloud, or in a different environment - like Deis or Mesos.

From Zero to Parse on Azure

  1. To deploy, simply head over to the parse-docker-azure repository and hit the 'Deploy to Azure' button.

  2. After logging into the Azure Portal, the deployment wizard needs to know a few parameters. For the virtual machine, you will have to specify location, size, username, password, and DNS prefix. If you're just trying things out, I'd recommend "Standard_D1" for the machine size and "West US" for the location. The required parameters in detail are:

  • vmSize: The size of your virtual machine, which will host the Docker Image. If you're just testing things, go with Standard_D1 - otherwise, feel free to specify any valid machine size.
  • location: The location of your virtual machine, for instance "West US", "East US", or "West Europe". You can find all available locations here.
  • parseAppId: The Parse application id to host with this server instance.
  • parseMasterKey: The Parse master key to use for overriding ACL security.
  • parseFileKey: (Optional) For migrated apps, this is necessary to provide access to files already hosted on Parse.
  • adminUsername: The admin username for your Ubuntu machine.
  • adminPassword: The admin password for your Ubuntu machine.
  • dnsLabelPrefix: The DNS prefix for your machine. If you choose myparseserver and deploy to the "West US" region, the resulting address of the machine will be myparseserver.westus.cloudapp.azure.com.
  1. As soon as you hit the 'Create' button, Azure will go ahead and deploy the whole thing. Once deployed, you can reach your custom Parse server at http://YOUR=DNS-LABEL-PREFIX.LOCATION.cloudapp.azure.com.com/parse!

Configuration and Customization

It is likely that you will want to change the code running in your custom Parse server.

The Docker Image is built using the Dockerfile and code found in this repository - simply fork the repository and change both parse.js and cloud/main.js to your liking. If you're looking for help, consult Parse's migration guide, explaining in detail how you can move your Cloud Code hosted on Facebook Parse to your freshly created Docker Parse installation. So, to reiterate:

  1. Fork the parse-docker repository

  2. Configure the Dockerfile, the server file parse.js and the Cloud Code running in cloud/main.js to your liking.

  3. Build a Docker Image (using docker build) and push the image to Docker Hub, so that Azure will be able to find the image.

  4. You have now two choices: You can either login to your existing Ubuntu machine and simply use the docker command line tools to replace the existing felixrieseberg/parse image - or continue to create a new Azure Resource Manager template. The latter would allow you to deploy your Parse server with the same one-click logic used to deploy the sample above. If you want to, read on - everyone else is already done.

  5. Fork or download the parse-docker-azure repository. In there, you will find a file called azuredeploy.json. Open it, and search for felixrieseberg/parse. Simply replace that line with your own Docker Image.

  6. You can now use the changed ARM template to deploy your solution to Azure. To do so, use either the Azure CLI - or head over to your browser and open https://portal.azure.com/#create/Microsoft.Template/uri/, directly followed by the URL to your ARM template. In the case of my parse-docker-azure template, that "Deploy to Azure" button is for instance just a link to the following address:

https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Ffelixrieseberg%2Fparse-docker-azure%2Fmaster%2Fazuredeploy.json