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:
yarn servercheck that the database exists and automatically run
- Create and
entrypoint.shfile that checks the database and runs
setupdb, and then keep
CMD ["yarn", "server"]as the main command in docker.