mirror of
https://github.com/nickyeoman/docker-compose-cookbooks.git
synced 2026-09-04 02:46:23 +00:00
Builder Changes to get Mariadb working
This commit is contained in:
+11
-18
@@ -8,12 +8,14 @@ process_env_vars() {
|
||||
# Loop through each environment variable
|
||||
while IFS= read -r env_var; do
|
||||
# Split into name and value parts based on '='
|
||||
var_name="${env_var%%=*}" # Variable name
|
||||
var_value="${env_var#*=}" # Variable value
|
||||
var_name="${env_var%%:*}" # Variable name (split by colon for YAML)
|
||||
var_value="${env_var#*: }" # Variable value (remove leading space)
|
||||
|
||||
# Check if the variable value contains a reference to another variable with the format ${VAR_NAME:-default}
|
||||
if [[ "$var_value" == *'${'*':'*'}'* ]]; then
|
||||
# Extract the variable inside the ${} braces
|
||||
# Handle variables without existing braces (not previously processed)
|
||||
if [[ "$var_value" != *'${'* ]]; then
|
||||
modified_var="${var_name}: \${${APP_NAME}_${var_name}:-${var_value}}"
|
||||
else
|
||||
# Handle variables already having ${} and possible default
|
||||
ref_var="${var_value#\$\{}"
|
||||
ref_var="${ref_var%%[:-]*}"
|
||||
|
||||
@@ -23,20 +25,11 @@ process_env_vars() {
|
||||
|
||||
# Check if the reference variable already contains APP_NAME_ prefix
|
||||
if [[ "$ref_var" == ${APP_NAME}_* ]]; then
|
||||
# If it already contains the prefix, use it as is
|
||||
modified_var="${var_name}=\${${ref_var}:-${default_value}}"
|
||||
# Use the reference variable as is if it already contains the prefix
|
||||
modified_var="${var_name}: \${${ref_var}:-${default_value}}"
|
||||
else
|
||||
# If not, add the APP_NAME_ prefix
|
||||
modified_var="${var_name}=\${${APP_NAME}_${ref_var}:-${default_value}}"
|
||||
fi
|
||||
else
|
||||
# For variables without ${VAR_NAME} references
|
||||
if [[ "$var_name" == ${APP_NAME}_* ]]; then
|
||||
# If the variable name already starts with APP_NAME_, do not prefix again
|
||||
modified_var="${var_name}=${var_value}"
|
||||
else
|
||||
# Add APP_NAME_ prefix for consistency
|
||||
modified_var="${var_name}=\${${APP_NAME}_${var_name}:-${var_value}}"
|
||||
# Add APP_NAME_ prefix to reference variable
|
||||
modified_var="${var_name}: \${${APP_NAME}_${ref_var}:-${default_value}}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user