From ba2cc09dc0e8c6c616ca96ef4911d247ed047058 Mon Sep 17 00:00:00 2001 From: Luca Date: Mon, 4 Apr 2022 01:32:16 +0200 Subject: [PATCH] Add container for running tasks --- .dockerignore | 1 + docker/Dockerfile | 25 +++++++++++++++++++++++++ docker/crontab | 2 ++ 3 files changed, 28 insertions(+) create mode 100644 docker/crontab diff --git a/.dockerignore b/.dockerignore index 542706c3..ddc9b1d5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,6 @@ # Docker config docker/ +!docker/crontab !docker/nginx/entrypoint.sh !docker/nginx/nginx.conf diff --git a/docker/Dockerfile b/docker/Dockerfile index b6046ecc..6023b96f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -27,6 +27,31 @@ COPY --from=composer /app/composer.lock /app/ RUN find /app/storage/ -type f -not -name VERSION -exec rm {} \; +# Fetch supercronic +FROM alpine as supercronic + +ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-amd64 \ + SUPERCRONIC=supercronic-linux-amd64 \ + SUPERCRONIC_SHA1SUM=048b95b48b708983effb2e5c935a1ef8483d9e3e + +RUN apk add --no-cache curl \ + && curl -fsSLO "$SUPERCRONIC_URL" \ + && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ + && chmod +x "$SUPERCRONIC" \ + && mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" + +# Build a container for running tasks +FROM php:8-cli-alpine as cron + +RUN apk add --no-cache icu-dev && \ + docker-php-ext-install intl pdo_mysql + +COPY --from=data /app/ /app +COPY --from=supercronic /usr/local/bin/supercronic-linux-amd64 /usr/local/bin/supercronic +COPY docker/crontab /etc/crontab + +ENTRYPOINT ["/usr/local/bin/supercronic"] + # Build the PHP container FROM php:8-fpm-alpine WORKDIR /var/www diff --git a/docker/crontab b/docker/crontab new file mode 100644 index 00000000..88119378 --- /dev/null +++ b/docker/crontab @@ -0,0 +1,2 @@ +# Run schedule import every minute +*/1 * * * * /app/bin/import '*'