Discuss docker best practices
Ideally Dockerfiles are able to bring an application up from zero to production. At present a single image is not able to start a pubsweet app since it requires to set the database (yarn setupdb
) before running the server (yarn server
) - and both commands need to be triggered at run time (i.e. the CMD
statement in the Dockerfile), effectively requiring two separate images (one for setup and one for running).
There are two solutions I can think of:
- Make
yarn server
check that the database exists and automatically runsetupdb
otherwise. - Create and
entrypoint.sh
file that checks the database and runssetupdb
, and then keepCMD ["yarn", "server"]
as the main command in docker.