I have an scenario in which I need parse server to be run from a Dockerfile, and that docker file should be run inside docker-compose. Also, I need to externalize configuration to a json file.
The main problem is that if I run this Dockerfile inside docker-compose, config file is not found.
This is my dockerfile declaration:
FROM parseplatform/parse-server:4.2.0
COPY config.json config.json
EXPOSE 1337
CMD ["/parse-server/bin/parse-server", "config.json"]
This is my config.json file:
{
"appId": "appId",
"masterKey": "masterKey",
"databaseURI": "mongodb://usr:pass@mongodb:27017"
}
This is working properly, as if I build it and the run this:
docker build -f Dockerfile -t parse .
docker run --name parse -p 1337:1337 -d parse config.json
It works properly, and in a nutshell, the important line from the docker logs is this:
Configuration loaded from /parse-server/config.json
But if I try to run it inside a docker-compose file this way:
version: '3.5'
services:
db:
image: mongo
ports:
- 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME: usr
MONGO_INITDB_ROOT_PASSWORD: pass
parse:
build: .
ports:
- 1337:1337
depends_on:
- db
It doesn't work, it just prints parse-server help, along with this line:
Configuration loaded from /parse-server/bin/parse-server
I've tested a couple of scenarios (note: doesn't work means here that the config file is not found):
- Declaring a command inside docker-compose to run parse-server, and give the --appId, --masterKey and --databaseURI switches manually, it works.
- Declaring a command inside docker-compose pointing to the config.json file doesn't work.
- Mount config.json file inside docker-compose container via volumes, doesn't work.
- Running a command with the previously mentioned switched, and then inspect the container itself to check if the file is there, and yes, it is.
- Copy the file to where parse-server should take it by default ( /parse-server/bin )
Questions:
- There is a slighty chance that config file is being copy after the parse-server command execution?
- How can it be that the Dockerfile alone works fine, and it doesn't work inside a docker-compose file? As far as I know, it wouldn't be that harder, as this is the proper way to run it.
- Any hints about what is wrong with this?
Thanks a lot!