From cbf63acc6bf991486072c9685534edbf6152f471 Mon Sep 17 00:00:00 2001 From: vcorre Date: Thu, 19 Dec 2024 12:36:59 +0100 Subject: [PATCH] Refactor .env file creation in docker entrypoint Moved .env file creation logic to execute earlier in the script for better clarity and structure. Ensures .env is generated before running subsequent commands, improving maintainability. --- docker-entrypoint.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index d4c3fad89..57dbb588a 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,5 +1,10 @@ #!/bin/sh set -e +# Create .env file if it doesn't exist +if [ ! -f .env ]; then + echo "Creating .env file from environment variables..." + envsubst < .env.dist > .env +fi if [ "$1" != 'php' ] && [ "$1" != 'sh' ]; then # Install dependencies if not already installed if [ ! -d 'vendor/' ]; then @@ -7,11 +12,6 @@ if [ "$1" != 'php' ] && [ "$1" != 'sh' ]; then composer install --prefer-dist --no-progress --no-interaction fi - # Create .env file if it doesn't exist - if [ ! -f .env ]; then - echo "Creating .env file from environment variables..." - envsubst < .env.dist > .env - fi # Check and wait for the database to be ready if grep -q ^DB_HOST= .env; then