Skip to content

Commit 1fd78a1

Browse files
committed
fx secrets.
1 parent 44aada2 commit 1fd78a1

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

Dockerfile

+7-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ RUN mkdir -p characters
5757
# Add debugging and error handling to startup command
5858
CMD sh -c '\
5959
echo "Debug: Starting container" && \
60-
echo "Debug: Environment variables:" && \
61-
echo "SMALL_GOOGLE_MODEL=${SMALL_GOOGLE_MODEL}" && \
62-
echo "MEDIUM_GOOGLE_MODEL=${MEDIUM_GOOGLE_MODEL}" && \
6360
echo "Debug: AGENTS_BUCKET_NAME=${AGENTS_BUCKET_NAME}" && \
6461
echo "Debug: CHARACTER_FILE=${CHARACTER_FILE}" && \
6562
echo "Debug: Full GCS path=gs://${AGENTS_BUCKET_NAME}/${CHARACTER_FILE}" && \
@@ -71,5 +68,12 @@ CMD sh -c '\
7168
fi && \
7269
echo "Debug: Attempting to copy character file..." && \
7370
gsutil cp gs://${AGENTS_BUCKET_NAME}/${CHARACTER_FILE} characters/${CHARACTER_FILE} && \
71+
# Get secrets directly when starting the application
72+
export SMALL_GOOGLE_MODEL=$(gcloud secrets versions access latest --secret="small-google-model") && \
73+
export MEDIUM_GOOGLE_MODEL=$(gcloud secrets versions access latest --secret="medium-google-model") && \
74+
export GOOGLE_GENERATIVE_AI_API_KEY=$(gcloud secrets versions access latest --secret="google-generative-ai-key") && \
75+
echo "Debug: Environment variables:" && \
76+
echo "SMALL_GOOGLE_MODEL=${SMALL_GOOGLE_MODEL}" && \
77+
echo "MEDIUM_GOOGLE_MODEL=${MEDIUM_GOOGLE_MODEL}" && \
7478
echo "Debug: Starting application..." && \
7579
pnpm start --non-interactive --characters=characters/${CHARACTER_FILE}'

cloudbuild.yaml

+2-13
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,13 @@ steps:
8888
full_name=$(cat /workspace/full_name)
8989
version=$(cat /workspace/version)
9090
bucket_name=$(gcloud secrets versions access latest --secret="agents-bucket-name")
91-
small_google_model=$(gcloud secrets versions access latest --secret="small-google-model")
92-
medium_google_model=$(gcloud secrets versions access latest --secret="medium-google-model")
93-
google_generative_api_key=$(gcloud secrets versions access latest --secret="google-generative-ai-key")
9491
echo "Working with instance: ${full_name}"
9592
echo "Checking for existing instance..."
9693
if [[ $(gcloud compute instances list --filter="name=${full_name}" --format="get(name)") ]]; then
9794
echo "Updating existing instance ${full_name}"
9895
gcloud compute instances update-container ${full_name} \
9996
--container-image us-central1-docker.pkg.dev/$PROJECT_ID/qi-agents/${full_name}:${version} \
100-
--container-env AGENTS_BUCKET_NAME=${bucket_name},\
101-
CHARACTER_FILE=${_CHARACTER_FILE},\
102-
SMALL_GOOGLE_MODEL=${small_google_model},\
103-
MEDIUM_GOOGLE_MODEL=${medium_google_model},\
104-
GOOGLE_GENERATIVE_AI_API_KEY=${google_generative_api_key} \
97+
--container-env AGENTS_BUCKET_NAME=${bucket_name},CHARACTER_FILE=${_CHARACTER_FILE} \
10598
--zone $_ZONE || { echo "Instance update failed"; exit 1; }
10699
echo "Instance update completed"
107100
else
@@ -114,11 +107,7 @@ steps:
114107
--subnet $_SUBNET \
115108
--no-address \
116109
--boot-disk-size $_DISK_SIZE \
117-
--container-env AGENTS_BUCKET_NAME=${bucket_name},\
118-
CHARACTER_FILE=${_CHARACTER_FILE},\
119-
SMALL_GOOGLE_MODEL=${small_google_model},\
120-
MEDIUM_GOOGLE_MODEL=${medium_google_model},\
121-
GOOGLE_GENERATIVE_AI_API_KEY=${google_generative_api_key} \
110+
--container-env AGENTS_BUCKET_NAME=${bucket_name},CHARACTER_FILE=${_CHARACTER_FILE} \
122111
--metadata-from-file startup-script=startup.sh || { echo "Instance creation failed"; exit 1; }
123112
echo "Instance creation completed"
124113
fi

0 commit comments

Comments
 (0)