Run Doctrine migrations automatically on container start

Open Beginner friendly
#309 1 comment 0 reactions 0 assignees View on GitHub

@akramer-zibra is already working on this.

Since Oct 15, 2026.

  • #310 by @akramer-zibra — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
66/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, php, shell

Research direction

Start with the Dockerfile and Dockerfile-standalone at the repo root, and the docker/configurations/ directory where the proposed entrypoint.sh would live. Check how bin/console runs under APP_ENV=prod. Add the script, wire it in as the ENTRYPOINT in both Dockerfiles, then build an image and start a container to confirm migrations run before php-fpm or supervisord starts. Done when a fresh container migrates and boots, and docker run CMD overrides still pass through.

Written by the indexing model from the issue text.

Description

feature request
Problem / motivation

Currently, after docker pull + restart, migrations must be run manually:

docker exec -it davis sh -c "APP_ENV=prod bin/console doctrine:migrations:migrate --no-interaction"

If this step is forgotten, Davis boots fine but fails in confusing ways (PROPPATCH errors, address books that won't create, etc.) instead of refusing to start. Time spend for upgrading would also decrease with this automation.

Proposed solution

Bake a minimal entrypoint.sh into both docker images that runs migrations before the server starts, then execs the normal process:

#!/bin/sh
set -e

php bin/console doctrine:migrations:migrate --no-interaction

exec "$@"

Wire it up in both Dockerfiles:

COPY ./docker/configurations/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

# In Dockerfile
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["php-fpm"]

# In Dockerfile-standalone
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"] # Dockerfile-standalone

exec "$@" keeps it transparent to whatever CMD (or a docker run override) supplies.

Known limitations
  • No DB-ready retry: if the database isn't accepting connections yet on first docker-compose up, the migrate step fails fast and the container exits. Compose files don't currently gate depends_on on a healthcheck.
  • No concurrency lock: if the image is ever scaled to multiple replicas, each would race to run migrations on start. Not an issue for the single-instance docker-compose setups in this repo.
Alternatives considered

No response

Area

Docker / deployment

Additional context

No response

Dominant language
PHP
Stars
761
Forks
45
Avg merge
9h 45m
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tchapi/davis

All issues in tchapi/davis

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.