Я хочу запускать команду через планировщик каждые x минут, все в порядке, но если я запускаю crontab до composer, команда установки не запускается, и если я запускаю ее после composer, команда установки выполняется, но nginx показывает 502 времени ожидания шлюза. Ниже мой docker файл:
#FROM php:7.2-fpm
FROM php:7.2-fpm
# Update packages
RUN apt-get update
# Install PHP and composer dependencies
RUN apt-get install -qq git curl libmcrypt-dev libjpeg-dev libpng-dev libfreetype6-dev libbz2-dev
# Clear out the local repository of retrieved package files
# RUN apt-get clean
# Install needed extensions
# Here you can install any other extension that you need during the test and deployment process
RUN apt-get clean; docker-php-ext-install pdo pdo_mysql zip gd pcntl opcache bcmath
RUN apt-get update && apt-get install -y libmagickwand-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
RUN printf "\n" | pecl install imagick
RUN docker-php-ext-enable imagick
# Install PHP Extension
RUN apt-get install libjpeg62-turbo-dev && apt-get install libpng-dev && apt-get install libfreetype6-dev && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-install gd
# Installs Composer to easily manage your PHP dependencies.
RUN curl --silent --show-error https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Install Node
RUN apt-get update &&\
apt-get install -y --no-install-recommends gnupg &&\
curl -sL https://deb.nodesource.com/setup_10.x | bash - &&\
apt-get update &&\
apt-get install -y --no-install-recommends nodejs &&\
npm config set registry https://registry.npm.taobao.org --global &&\
npm install --global gulp-cli
RUN echo 'memory_limit = 512M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini
# Install cron
RUN apt-get install -y cron
# Add crontab file in the cron directory
ADD schedule/crontab /etc/cron.d/cron
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/cron
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
WORKDIR /var/www
COPY . .
RUN rm -rf ./node_modules
# Run the command on container startup
CMD printenv > /etc/environment && echo "cron starting..." && (cron) && : > /var/log/cron.log && echo "display log file" && tail -f /var/log/cron.log
CMD php-fpm
RUN npm install
RUN composer install
RUN npm install cross-env -g
И следующий мой crontab
контент:
* * * * * root /usr/local/bin/php /var/www/artisan schedule:run --no-ansi >> /var/log/cron.log 2>&1
# Don't remove the empty line at the end of this file. It is required to run the cron job