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?
It looks like you have some issues with your docker-compose file:
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)
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.