Run Doctrine migrations automatically on container start
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 66/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 領域
- devops, infrastructure
調査の方向性
リポジトリのルートにある Dockerfile と Dockerfile-standalone、そして提案された entrypoint.sh が置かれる docker/configurations/ ディレクトリから始めてください。APP_ENV=prod の下で bin/console がどう動くかを確認します。スクリプトを追加し、両方の Dockerfile で ENTRYPOINT として組み込み、その後イメージをビルドしてコンテナを起動し、php-fpm や supervisord が起動する前にマイグレーションが実行されることを確認してください。新しいコンテナがマイグレーションを実行して起動し、docker run による CMD の上書きが引き続き渡されることが確認できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- PHP
- スター
- 760
- フォーク
- 45
- 平均マージ
- 1日 14時間
- マージ済み PR(30日)
- 3
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
tchapi/davis のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
Add an updaterオープンfeature request
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
-
feature request
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
feature request
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
似ている issue
-
14.3.x
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
CMS video element: "CmsVideoPlugin" sets `volume = 0`, so videos cannot be unmuted on Android Chromeオープンneeds-triage Platform(Default)
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
GD decoder discards the finfo media type in mediaTypeByBinary() since 4.4.0対応中かも @lazerg が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
Intervention/image#1556 ·
メンテナーはふだん 1 日以内に返信
-
bug No Code Attached Yet
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
joomla/joomla-cms#48730 ·
メンテナーはふだん 1 日以内に返信
-
sync-en
難易度 1/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信