Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docker] - Enable cron container to wait for migrations #860

Merged
merged 3 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 "$@"