Skip to content

Commit

Permalink
[docker] - Enable cron container to wait for migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferror committed Oct 31, 2022
1 parent f2cdf22 commit 6192af1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ENV PATH="${PATH}:/root/.composer/vendor/bin"
WORKDIR /srv/sylius

# build for production
ARG APP_ENV=prod
ENV APP_ENV=prod

# prevent the reinstallation of vendors at every changes in the source code
COPY composer.* symfony.lock ./
Expand Down Expand Up @@ -129,7 +129,7 @@ COPY docker/php/dev/opcache.ini $PHP_INI_DIR/conf.d/opcache.ini

WORKDIR /srv/sylius

ARG APP_ENV=dev
ENV APP_ENV=dev

RUN set -eux; \
composer install --prefer-dist --no-autoloader --no-interaction --no-scripts --no-progress; \
Expand All @@ -143,6 +143,8 @@ 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"]
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 6192af1

Please sign in to comment.