Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Hello. I am running a Laravel app on DO App Platform. Love the service but wish cron was easier to implement. I have followed the steps in the below article, How To Setup a Job Scheduler on DigitalOcean App Platform:
I am having a hard time wrapping my mind around the worker, and how it gets access to to the main application component. My understanding is that I need to copy my Laravel app into the worker component, so that the worker can run the required php artisan schedule:work command:
https://www.digitalocean.com/community/questions/laravel-scheduled-tasks
This is the Dockerfile code I have been working with, modified from the examples linked above:
FROM ubuntu:22.04
# Install necessary packages for Laravel, including cron and unzip
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install -y cron curl unzip libpq-dev php \
# Remove package lists for smaller image sizes
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-install pdo pdo_mysql \
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
## Set the working directory for the Laravel app
WORKDIR /workspace
# Copy the Laravel app into the container
COPY . /
# Set proper permissions for the storage and bootstrap/cache directories
RUN chown -R www-data:www-data /storage /var/www/bootstrap/cache \
&& chmod -R 755 /storage /var/www/bootstrap/cache
# Copy the crontab file and entrypoint script into the container
COPY crontab /hello-cron
COPY entrypoint.sh /entrypoint.sh
# Install the crontab and make the entrypoint script executable
RUN crontab /hello-cron \
&& chmod +x /entrypoint.sh
# Run the entrypoint script
ENTRYPOINT ["/entrypoint.sh"]
# https://manpages.ubuntu.com/manpages/trusty/man8/cron.8.html
# -f | Stay in foreground mode, don't daemonize.
# -L loglevel | Tell cron what to log about jobs (errors are logged regardless of this value) as the sum of the following values:
CMD ["cron", "-f", "-L", "2"]
According to the build logs the issue arises when the code tries to adjust permissions to the /storage file, and it returns a no such file/directory error. I understand the path would need to be adjusted for cache, etc. as well.
I have never used a Dockerfile before, having been fortunate enough to always have access to a simple cron setup.
I THINK my problem is coming from the working directory I specify. I am guessing the WORKDIR I specify is nonexistent and I am copying nothing and so that is why there is no file to change permissions on. When I pwd in the console for the component the app is hosted on, I see I am in the /workspace directory, and I can see all my laravel application files in there. I do not understand how I can access those files to copy the project over into the worker so that I can run the artisan schedule:work commands. I am really struggling to understand the concepts here - can any one clarify? Thank you.
a6309a057c3f4cb38fb2e7feb67236
KFSys
ef1ed44cc2154be3bcbb2d727878f8
Devs Neonetworks
1e6b823ea20d4cb189a34a922f5588
Telmo Valverde
erik-jan martens
Henry Mui
anthonycarreon
garantieheld
Marin