1

I've configured a little cluster using docker-compose, consisting of parse-server, mongo and parse-dashboard:

  version: "3"
  services:
  myappdb:
    image: mongo
    ports:
      - 27017:27017
  myapp-parse-server:
    image: parseplatform/parse-server
    environment:
      - PARSE_SERVER_MASTER_KEY=xxxx
      - PARSE_SERVER_APPLICATION_ID=myapp
      - VERBOSE=0
      - PARSE_SERVER_DATABASE_URI=mongodb://myappdb:27017/dev
      - PARSE_SERVER_URL=http://myapp-parse-server:1337/parse
    depends_on:
      - myappdb
    ports:
      - 5000:1337
  parse-dashboard:
    image: parseplatform/parse-dashboard
    ports:
      - 5001:4040
    environment:
      - PARSE_DASHBOARD_ALLOW_INSECURE_HTTP=1
      - PARSE_DASHBOARD_SERVER_URL=http://myapp-parse-server:1337/parse
      - PARSE_DASHBOARD_APP_ID=myapp
      - PARSE_DASHBOARD_MASTER_KEY=xxxx
      - PARSE_DASHBOARD_USER_ID=admin
      - PARSE_DASHBOARD_USER_PASSWORD=xxxx

Try as I might, however, I cannot get the deployed parse-dashboard to connect to the myapp-parse-server. After I log in to the dashboard using my browser (at localhost:5001), the dashboard app informs me that it is 'unable to connect to server'.

I've tried pinging the host 'myapp-parse-server' from the parse-dashboard container, and it can see the container just fine. Similarly, it can see the endpoint http://myapp-parse-server:1337/parse; wget returns the expected 403.

If I use a copy of parse-dashboard running on my host machine, it works just fine against http://localhost:5000/parse. So the forwarded port from my host to the parse-server works.

I've also tried configuring dashboard using parse-dashboard-config.json mounted into the container. Yields exactly the same result.

I'm at a loss as to what I'm doing wrong here. Can anybody shed some light on this?

Darren Black
  • 1,030
  • 1
  • 9
  • 28

1 Answers1

1

It looks like you have some issues with your docker-compose file:

  1. PARSE_SERVER_URL is pointing to myapp-parse-server and it should point to http://localhost:1337/parse instead (unless you modified your hosts file on the container somehow but I don't see it)

  2. Your myapp-parse-server should link to your database using links

here is an example of a docker-compose file from one blog that I wrote on how to deploy parse-server to google container enginee

version: "2"
services:
# Node.js parse-server application image
  app:
    build: ./app
    command: npm start -- /parse-server/config/config.json
    container_name: my-parse-app
    volumes:
    - ./app:/parse-server/
    - /parse-server/node_modules
    ports:
    - "1337:1337"
    links:
    - mongo
# MongoDB image 

  mongo:
    image: mongo
    container_name: mongo-database
    ports:
    - "27017:27017"
    volumes_from:
    - mongodata
# MongoDB image volume for persistence
  mongodata:
    image: mongo
    volumes:
    - ./data/db:/data/db
    command:
    - --break-mongo

You can see from the example above that I use links and also create and attach volume for the database disk.

Also, I personally think that it's better to run parse-server with config file in order to decouple all configurations so my configuration file looks like the following (in my docker compose you can see that I'm running parse server with config file and not with env variables)

{
"databaseURI": "mongodb://localhost:27017/my-db",
"appId": "myAppId",
"masterKey": "myMasterKey",
"serverURL": "http://localhost:1337/parse",
"cloud": "./cloud/main.js",
"mountPath": "/parse",
"port": 1337
}

Finally, In my parse-dashboard image I also use config file and simply create it as volume and replace the default config file with my own. Because this step was not covered in my blogs your final docker-compose file should look like the following:

version: "2"
services:
# Node.js parse-server application image
  app:
    build: ./app
    command: npm start -- /parse-server/config/config.json
    container_name: my-parse-app
    volumes:
    - ./app:/parse-server/
    - /parse-server/node_modules
    ports:
    - "1337:1337"
    links:
    - mongo
# MongoDB image 

  mongo:
    image: mongo
    container_name: mongo-database
    ports:
    - "27017:27017"
    volumes_from:
    - mongodata
# MongoDB image volume for persistence
  mongodata:
    image: mongo
    volumes:
    - ./data/db:/data/db
    command:
    - --break-mongo
    
  dashboard:
    image: parseplatform/parse-dashboard:1.1.0
    volumes:
      - ./dashboard/dashboard-config.json:/src/Parse-Dashboard/parse-dashboard-config.json   
    environment:
      PORT: 4040
      PARSE_DASHBOARD_ALLOW_INSECURE_HTTP: 1
      ALLOW_INSECURE_HTTP: 1
      MOUNT_PATH: "/parse"

And the parse-dashboard.json (the config file) should be:

{ "apps": [ { "serverURL": "http://localhost:3000/parse", "appId": "myMasterKey", "masterKey": "myMasterKey", "appName": "My App" }
], "users": [ { "user": "myuser", "pass": "mypassword" } ], "useEncryptedPasswords": false }

I know that it's a little bit long so I really encourage you to read the series of blogs.

Hope it will help you.

Ran Hassid
  • 2,788
  • 1
  • 12
  • 20
  • According to https://docs.docker.com/compose/compose-file/#links, links are deprecated... – Darren Black Jan 25 '18 at 21:18
  • And having my server url set to localhost doesn't make any sense? The server and the dashboard are running in separate Docker containers. localhost:1337 on the dashboard container wouldn't hit the parse-server, since that's running on a different container. – Darren Black Jan 25 '18 at 21:25
  • Hi, this is not related. The docker container is running on your local machine and use port forwarding 1337 --> 1337 so eventually its running on your machine. The same is applicable for the parse-dashboard which running on port 4040. in parse-dashboard config you need to provide a URL of where your parse-server is running. If you will go according to my blogs it will 100% work for you since it is working in more than 5 parse-server projects that I am working on... – Ran Hassid Jan 26 '18 at 09:51
  • I can't pretend to understand why, but changing the PARSE_SERVER_URL in the Dashboard config to localhost:1337 did the trick. Thanks. – Darren Black Jan 26 '18 at 10:15
  • You can also do it with internal hosts trick but then you need to make sure that the parse-server container "know" the parse-dashboard container. It works like selectors & labels in Kubernetes – Ran Hassid Jan 26 '18 at 10:30
  • That's what confused me about all this. They *do* know each other! They can ping each other by the names given to the services in the yml file. – Darren Black Jan 26 '18 at 10:43
  • And to anybody reading this in the future, I changed PARSE_SERVER_URL to http://localhost:5000/parse, not port 1337 as my earlier comment suggested. – Darren Black Jan 26 '18 at 10:49
  • That’s because the port forwarding ... you can also use the same port for both by changing 5000:1337 to 1337:1337 but it’s really depend on the port that you want to use ... – Ran Hassid Jan 26 '18 at 13:50
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/163953/discussion-between-darren-black-and-ran-hassid). – Darren Black Jan 26 '18 at 14:28