#!/bin/sh set -e # Exit immediately if a command exits with a non-zero status. CREDENTIALS_FILE_PATH="/app/vella_gcp_luan_credentials.json" # Check if the GCP_CREDENTIALS_JSON_CONTENT secret is provided if [ -n "$GCP_CREDENTIALS_JSON_CONTENT" ]; then echo "GCP_CREDENTIALS_JSON_CONTENT secret found. Writing to $CREDENTIALS_FILE_PATH" # Use printf to preserve newlines and special characters correctly printf "%s" "$GCP_CREDENTIALS_JSON_CONTENT" > "$CREDENTIALS_FILE_PATH" export GOOGLE_APPLICATION_CREDENTIALS="$CREDENTIALS_FILE_PATH" echo "GOOGLE_APPLICATION_CREDENTIALS set to $CREDENTIALS_FILE_PATH" # Optional: Add a check to see if the file looks like JSON (basic check) if command -v jq >/dev/null && jq -e . "$CREDENTIALS_FILE_PATH" >/dev/null 2>&1; then echo "Credentials file appears to be valid JSON." else echo "Warning: Credentials file may not be valid JSON. Content:" # cat "$CREDENTIALS_FILE_PATH" # Print the content for debugging fi else echo "Warning: GCP_CREDENTIALS_JSON_CONTENT secret not found. GCP services might not authenticate." fi exec "$@"