Skip to content

Commit

Permalink
refactor #860 [docker] - Enable cron container to wait for migrations…
Browse files Browse the repository at this point in the history
… (Ferror)

This PR was merged into the 1.12 branch.

Discussion
----------

Wait for #859

Now we want each service to be waiting for migrations to end.

Commits
-------

6192af1 [docker] - Enable cron container to wait for migrations
21b1401 Merge branch \'1.12\' into docker-cron-fix
bc7685e Merge branch \'1.12\' into docker-cron-fix
  • Loading branch information
lchrusciel committed Dec 7, 2022
2 parents 8becff8 + bc7685e commit 4bc8c24
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ RUN set -eux; \
;

COPY docker/cron/crontab /etc/crontabs/root
COPY docker/cron/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint

ENTRYPOINT ["crond"]
CMD ["-f"]
ENTRYPOINT ["docker-entrypoint"]
CMD ["crond", "-f"]

FROM sylius_php_prod AS sylius_migrations_prod

Expand Down
12 changes: 12 additions & 0 deletions docker/cron/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
set -e

while ping -c1 migrations >/dev/null 2>&1;
do
(>&2 echo "Waiting for Migrations container to finish")
sleep 1;
done;

(>&2 echo "Migrations container finished. Starting Cron process.")

exec docker-php-entrypoint "$@"

0 comments on commit 4bc8c24

Please sign in to comment.