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

Cron job #1

Open
srocerer opened this issue Dec 30, 2020 · 1 comment
Open

Cron job #1

srocerer opened this issue Dec 30, 2020 · 1 comment

Comments

@srocerer
Copy link

srocerer commented Dec 30, 2020

Hey. Nice docker setup, I have used your setup for my local environment.
But I can't add cron

My cron setup:
https://github.com/cheyer/docker-cron

My Dockerfile:

FROM php:7.4-fpm

# Arguments defined in docker-compose.yml
ARG user
ARG uid
ARG GITHUB_TOKEN

ENV GITHUB_TOKEN=${GITHUB_TOKEN}

# Install system dependencies
RUN apt-get update && apt-get install -y \
    cron \
    git \
    curl \
    libjpeg-dev \
    libpng-dev \
    libonig-dev \
    libxml2-dev \
    libzip-dev \
    libc-client-dev \
    libkrb5-dev \
    zip \
    unzip \
    vim

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

RUN docker-php-ext-configure gd --with-jpeg

# Install PHP extensions
RUN docker-php-ext-install mysqli zip pdo_mysql mbstring exif pcntl bcmath gd

# IMAP extension
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
    && docker-php-ext-install imap \
    && docker-php-ext-enable imap

# Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Composer config
RUN composer config -g github-oauth.github.com ${GITHUB_TOKEN} \
    && composer config -g process-timeout 3600 \
    && composer config -g repos.packagist composer https://packagist.org


# Add crontab file in the cron directory
ADD crontab /etc/cron.d/simple-cron

# Add shell script and grant execution rights
ADD script.sh /script.sh
RUN chmod +x /script.sh

# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/simple-cron

# Create the log file to be able to run tail
RUN touch /var/log/cron.log

# Run the command on container startup
CMD cron && tail -f /var/log/cron.log


# Create system user to run Composer and Artisan Commands
RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
    chown -R $user:$user /home/$user

USER $user

Error:
cron: can't open or create /var/run/crond.pid: Permission denied

@hakankaan
Copy link

Same issue here. Could you find a solution for this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants