Run Doctrine migrations automatically on container start
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 66/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- devops, infrastructure
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
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 gatedepends_onon 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tchapi/davis
-
feature request
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Add an updaterOpenfeature request
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
feature request
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
feature request
Difficulty 5/5 Over a week Newbie friendliness 45/100
-
feature request
Difficulty 5/5 Over a week Newbie friendliness 30/100
Similar issues
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
grokability/snipe-it#19996 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Add a dark themeOpengood first issue laravel-appointment-reminders
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Text to Speech fails on Windows: the temp file path loses its backslashes when stored in post metaPossibly taken @azizulhasan claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day