Local development for Parse's Cloud Code Functions with Docker Compose

Cover image

I develop a mobile application which uses Parse Platform on the backend side to store and sync data. I really like it and this low-code backend approach allows me to concentrate on my mobile application. But from time to time I need to write some functionality on the backend side which is not offered out of the box. Parse offers Cloud Code Functions for this. It allows to write custom code. You can write code directly in the browser but I wanted a way to tryout stuff on my local machine. There are a few good guides how to setup a local Parse Server e.g. here but they all require to install the node module and mongodb locally. This works, but I prefer development setups with docker-compose. It is independent of my machine and therefore there are no environment conflicts with other projects and it is easy to share. So I created following docker-compose setup:

Docker Compose Setup

Make sure to have docker and docker-compose installed on your machine.

  1. Create a directory for your project e.g. myproject
  2. Create a directory myproject/cloud with a file main.js inside. Here you can place your code. Check out the official docs to learn about Cloud Code Functions.
  3. Create a myproject/docker-compose.yml with following content. Make sure to update the versions of parse-server and parse-dashboard depending on your needs.
version: '3'
  # database used by parse-server
    image: 'mongo:latest'
      - './data/db:/data/db'
      - 27017:27017
  # the backend offering a rest-api etc.
    image: 'parseplatform/parse-server:5.3.3'
      - PARSE_SERVER_MASTER_KEY=parse@master123!
      - PARSE_SERVER_DATABASE_URI=mongodb://mongo:27017/parse
      - PARSE_SERVER_CLOUD=/cloud/main.js
      - './cloud:/cloud'
      - '1337:1337'
  # (optional) parse-dashboard which allows to manage applications via ui
    image: 'parseplatform/parse-dashboard:5.0.0'
      - '4040:4040'
      - PARSE_DASHBOARD_SERVER_URL=http://localhost:1337/parse
      - PARSE_DASHBOARD_MASTER_KEY=parse@master123!
      - MOUNT_PATH=/dashboard/
  1. Run docker-compose up to start the application.
  2. That's it. Your setup should now be up and running. You can now:
  • Reach the parse-server under http://localhost:1337. If you open it in the browser it just displays an "Unauthorized" message. That's fine. To use the server in your client application configure the url and the value of PARSE_SERVER_APPLICATION_ID when establishing the connection. e.g. if using the JS SDK it would look like this:
Parse.serverURL = 'http://localhost:1337/parse'
curl --location 'http://localhost:1337/parse/functions/hello' \
--header 'X-Parse-Application-Id: parse' \
--header 'Content-Type: application/json' \
--data '{}'

You can see the logs in your terminal. If you change your cloud code you need to restart the application.

For me it is a good setup to play around with cloud code locally instead of developing in the browser UI. This setup improved my understanding of Parse Platform and also speeds up my development process. Hope it does the same for you.