luanpoppe commited on
Commit
1b5678f
·
1 Parent(s): 2bdce13

fix credential do google

Browse files
Files changed (1) hide show
  1. entrypoint.sh +12 -9
entrypoint.sh CHANGED
@@ -1,23 +1,26 @@
1
  #!/bin/sh
2
  set -e # Exit immediately if a command exits with a non-zero status.
3
 
4
- # Path where the credentials file will be written inside the container
5
- CREDENTIALS_FILE_PATH="/app/vella_gcp_luan_credentials.json" # Or /tmp/vella_gcp_luan_credentials.json
6
 
7
  # Check if the GCP_CREDENTIALS_JSON_CONTENT secret is provided
8
  if [ -n "$GCP_CREDENTIALS_JSON_CONTENT" ]; then
9
  echo "GCP_CREDENTIALS_JSON_CONTENT secret found. Writing to $CREDENTIALS_FILE_PATH"
10
- # Write the content of the environment variable (the JSON string) to the file
11
- echo "$GCP_CREDENTIALS_JSON_CONTENT" > "$CREDENTIALS_FILE_PATH"
12
- # Export GOOGLE_APPLICATION_CREDENTIALS to point to this new file
13
  export GOOGLE_APPLICATION_CREDENTIALS="$CREDENTIALS_FILE_PATH"
14
  echo "GOOGLE_APPLICATION_CREDENTIALS set to $CREDENTIALS_FILE_PATH"
 
 
 
 
 
 
 
 
 
15
  else
16
  echo "Warning: GCP_CREDENTIALS_JSON_CONTENT secret not found. GCP services might not authenticate."
17
- # You could choose to exit here if credentials are absolutely mandatory:
18
- # echo "Error: GCP_CREDENTIALS_JSON_CONTENT secret is required. Exiting." >&2
19
- # exit 1
20
  fi
21
 
22
- # Now, execute the command passed to this script (which will be your uvicorn CMD)
23
  exec "$@"
 
1
  #!/bin/sh
2
  set -e # Exit immediately if a command exits with a non-zero status.
3
 
4
+ CREDENTIALS_FILE_PATH="/app/vella_gcp_luan_credentials.json"
 
5
 
6
  # Check if the GCP_CREDENTIALS_JSON_CONTENT secret is provided
7
  if [ -n "$GCP_CREDENTIALS_JSON_CONTENT" ]; then
8
  echo "GCP_CREDENTIALS_JSON_CONTENT secret found. Writing to $CREDENTIALS_FILE_PATH"
9
+ # Use printf to preserve newlines and special characters correctly
10
+ printf "%s" "$GCP_CREDENTIALS_JSON_CONTENT" > "$CREDENTIALS_FILE_PATH"
 
11
  export GOOGLE_APPLICATION_CREDENTIALS="$CREDENTIALS_FILE_PATH"
12
  echo "GOOGLE_APPLICATION_CREDENTIALS set to $CREDENTIALS_FILE_PATH"
13
+
14
+ # Optional: Add a check to see if the file looks like JSON (basic check)
15
+ if command -v jq >/dev/null && jq -e . "$CREDENTIALS_FILE_PATH" >/dev/null 2>&1; then
16
+ echo "Credentials file appears to be valid JSON."
17
+ else
18
+ echo "Warning: Credentials file may not be valid JSON. Content:"
19
+ cat "$CREDENTIALS_FILE_PATH" # Print the content for debugging
20
+ fi
21
+
22
  else
23
  echo "Warning: GCP_CREDENTIALS_JSON_CONTENT secret not found. GCP services might not authenticate."
 
 
 
24
  fi
25
 
 
26
  exec "$@"