dehaze

Docker Compose

This guide helps you run a local development setup that sets up both Space Cloud and Postgres. It lets you explore the GraphQL APIs of Space Cloud on Postgres without having to set up any frontend projects.

Note: If you want to get started with some other database, then you can follow these getting started guides - Getting started with MySQL and Getting started with MongoDB.

Prerequisites

Step 1: Get the docker-compose file

The spaceuptech/space-cloud/install-manifests repo contains all installation manifests required to deploy Space Cloud anywhere. Get the docker compose file from there:

wget https://raw.githubusercontent.com/spaceuptech/space-cloud/master/install-manifests/quick-start/docker-compose/postgres/docker-compose.yaml

You should be able to see a docker-compose.yaml file with the following contents:

version: '3.6'
services:
  postgres:
    image: postgres
    restart: always
  space-cloud:
    image: spaceuptech/space-cloud
    ports:
    - "4122:4122"
    - "4126:4126"
    depends_on:
    - "postgres"
    restart: always
    environment:
      ## The DEV environment lets you use Mission Control (Admin UI) without login
      ## Change the dev mode to false if you want a login to your Mission Control UI
      DEV: "true"
      ## Uncomment next lines to change the login credentials of Mission Control UI
      # ADMIN_USER: "admin"
      # ADMIN_PASS: "123"
      # ADMIN_SECRET: "some-secret" # This is the JWT secret used for login authentication in Mission Control

Step 2: Run Space Cloud & Postgres

docker-compose up -d

Check if the containers are running:

docker ps

Step 3: Configure Space Cloud

If you exec into docker container of Space Cloud, you can see a config.yaml file generated by Space Cloud in the home directory.

Space Cloud needs this config file to function. The config file is used to load information like the database to be used, its connection string, security rules, etc.

Space Cloud has it’s own Mission Control (admin UI) to configure all of this quickly.

Open Mission Control

Head over to http://localhost:4122/mission-control to open Mission Control.

Note: Replace localhost with the address of your Space Cloud if you are not running it locally.

Creating a project

Click on Create a Project button to open the following screen:

Create a project screen

Give a name to your project.

Select POSTGRESQL as your database.

Hit Next to create the project.

Configuring DB config

Head over to the Database section.

As you can see, the connection status would be disconnected.

Click on the Edit Connection button:

Edit connection details

Copy-paste the following connection string in it:

postgres://postgres:mysecretpassword@postgres:5432/postgres?sslmode=disable

That’s all that is required to configure Space Cloud for this guide!

Step4: Let us try it out

Our backend is up and running, configured to expose APIs on Postgres. Time to explore its awesome powers.

Explore GraphQL APIs of Space Cloud using GraphiQL.

Have a technical question?

Improve the docs!