#!/bin/sh set -e # Exit immediately if a command exits with a non-zero status. # Path where the credentials file will be written inside the container CREDENTIALS_FILE_PATH="/app/vella_gcp_luan_credentials.json" # Or /tmp/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" # Write the content of the environment variable (the JSON string) to the file echo "$GCP_CREDENTIALS_JSON_CONTENT" > "$CREDENTIALS_FILE_PATH" # Export GOOGLE_APPLICATION_CREDENTIALS to point to this new file export GOOGLE_APPLICATION_CREDENTIALS="$CREDENTIALS_FILE_PATH" echo "GOOGLE_APPLICATION_CREDENTIALS set to $CREDENTIALS_FILE_PATH" else echo "Warning: GCP_CREDENTIALS_JSON_CONTENT secret not found. GCP services might not authenticate." # You could choose to exit here if credentials are absolutely mandatory: # echo "Error: GCP_CREDENTIALS_JSON_CONTENT secret is required. Exiting." >&2 # exit 1 fi # Now, execute the command passed to this script (which will be your uvicorn CMD) exec "$@"