sintonia docker fix: dev container startup
This commit is contained in:
parent
f17ee781a2
commit
18ad58fd68
7 changed files with 223 additions and 103 deletions
58
tools/populate-laravel-env-file.sh
Normal file
58
tools/populate-laravel-env-file.sh
Normal file
|
@ -0,0 +1,58 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Check if yq is installed
|
||||
if ! command -v yq >/dev/null 2>&1; then
|
||||
echo "yq is not installed. Install it first (e.g., sudo apt-get install yq)."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Input YAML file
|
||||
YAML_FILE="$1"
|
||||
|
||||
# Output .env file
|
||||
ENV_FILE="$2"
|
||||
|
||||
# Extract values from YAML using yq
|
||||
DB_HOST=$(yq '.database.host // "postgres"' "$YAML_FILE")
|
||||
DB_PORT=$(yq '.database.port // "5432"' "$YAML_FILE")
|
||||
DB_USER=$(yq '.database.user // "libretime"' "$YAML_FILE")
|
||||
DB_PASSWORD=$(yq '.database.password // "libretime"' "$YAML_FILE")
|
||||
DB_DATABASE=$(yq '.database.database // "libretime"' "$YAML_FILE")
|
||||
|
||||
MAIL_HOST=$(yq '.email.host // "localhost"' "$YAML_FILE")
|
||||
MAIL_PORT=$(yq '.email.port // "25"' "$YAML_FILE")
|
||||
MAIL_USERNAME=$(yq '.email.user // ""' "$YAML_FILE")
|
||||
MAIL_PASSWORD=$(yq '.email.password // ""' "$YAML_FILE")
|
||||
MAIL_ENCRYPTION=$(yq '.email.encryption // ""' "$YAML_FILE")
|
||||
|
||||
# Function to update or add a variable in the .env file
|
||||
update_env_var() {
|
||||
local key="$1"
|
||||
local value="$2"
|
||||
if grep -q "^$key=" "$ENV_FILE"; then
|
||||
# Update existing variable
|
||||
sed -i.bak "s|^$key=.*|$key=$value|" "$ENV_FILE"
|
||||
else
|
||||
# Add new variable
|
||||
echo "$key=$value" >> "$ENV_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
# Create or update the .env file with extracted values
|
||||
update_env_var "DB_CONNECTION" "postgres"
|
||||
update_env_var "DB_HOST" "$DB_HOST"
|
||||
update_env_var "DB_PORT" "$DB_PORT"
|
||||
update_env_var "DB_DATABASE" "$DB_DATABASE"
|
||||
update_env_var "DB_USERNAME" "$DB_USER"
|
||||
update_env_var "DB_PASSWORD" "$DB_PASSWORD"
|
||||
|
||||
update_env_var "MAIL_MAILER" "smtp"
|
||||
update_env_var "MAIL_HOST" "$MAIL_HOST"
|
||||
update_env_var "MAIL_PORT" "$MAIL_PORT"
|
||||
update_env_var "MAIL_USERNAME" "$MAIL_USERNAME"
|
||||
update_env_var "MAIL_PASSWORD" "$MAIL_PASSWORD"
|
||||
update_env_var "MAIL_ENCRYPTION" "$MAIL_ENCRYPTION"
|
||||
update_env_var "MAIL_FROM_ADDRESS" "\"hello@example.com\""
|
||||
update_env_var "MAIL_FROM_NAME" "${APP_NAME}"
|
||||
|
||||
echo ".env file has been created/updated successfully."
|
Loading…
Add table
Add a link
Reference in a new issue