Replies: 2 comments 1 reply
-
You might want to look into something like this: https://docs.docker.com/compose/how-tos/startup-order/ The above uses native Docker healthchecks to ensure things are online before bringing up the next service. Also, have you considered having the image built before deploying it? With Spin Pro, I have everything built into a single Docker Image and the healthchecks defined for you already https://getspin.pro/ |
Beta Was this translation helpful? Give feedback.
-
Best way is to run the individual artisan commands that can be run during build and leave the rest to run on startup eg i am running routes, events and view caching on build config has to run on startup since env variables don't exist during build |
Beta Was this translation helpful? Give feedback.
-
I'm looking for guidance on how to effectively run Composer commands during container startup instead of during the image build process. Here's the background:
Context:
I am working with a Laravel application, and I'm using Docker to manage the environment. The project requires running specific Laravel commands such as
composer install
andphp artisan optimize
. However, these commands in my case depend on external services like Redis.Current Issue:
When building the Docker image, Redis is not available, and thus, the build process fails with the following error:
php_network_getaddresses: getaddrinfo for redis failed: Name or service not known
My Current Docker Setup:
Docker Compose File (docker-compose.yml):
Dockerfile:
99-entrypoint.sh
Desired Outcome:
Instead of running Composer commands (like php artisan optimize or composer install) during the Docker image build process, I would like these commands to be executed at container startup. This way, Redis and other services are fully available, and the Laravel app can properly interact with them.
Beta Was this translation helpful? Give feedback.
All reactions