Skip to content

Commit 663d2aa

Browse files
chore: update Dockerfile to fetch binary, and parameterize Cloud Build variables with $PROJECT_ID
1 parent 01bc25b commit 663d2aa

2 files changed

Lines changed: 15 additions & 27 deletions

File tree

Dockerfile

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
1-
# --- Stage 1: Build the binary from source (Latest Nightly) ---
2-
FROM golang:1.25 AS builder
1+
# --- Final Runtime Image ---
2+
# Using python:3.11 as the base image to support evaluations that require Python,
3+
# while still running the pre-compiled Go binary for the toolbox server.
4+
FROM python:3.11
35

4-
WORKDIR /build
5-
6-
# Clone the official genai-toolbox source code (always latest main branch)
7-
RUN git clone --depth 1 https://github.com/googleapis/genai-toolbox.git .
8-
9-
# Compile the binary with CGO ENABLED to support all upstream database drivers (Oracle, etc.)
10-
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o toolbox .
11-
12-
# --- Stage 2: Final Lightweight Runtime Image ---
13-
# Using the exact same image (golang:1.25) for runtime to perfectly match GLIBC versions
14-
FROM golang:1.25
15-
16-
17-
# Install necessary runtime certificates and standard C libraries for CGO binary
18-
RUN apt-get update && apt-get install -y ca-certificates libc6 && rm -rf /var/lib/apt/lists/*
6+
# Install necessary runtime certificates, standard C libraries, and curl
7+
RUN apt-get update && apt-get install -y ca-certificates libc6 curl && rm -rf /var/lib/apt/lists/*
198

209
WORKDIR /app
2110

22-
# Copy the freshly compiled binary from the builder stage
23-
COPY --from=builder /build/toolbox /app/toolbox
11+
# Dynamically fetch the latest version and download the binary
12+
RUN LATEST_VERSION=$(curl -s https://api.github.com/repos/googleapis/mcp-toolbox/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') && \
13+
curl -L https://storage.googleapis.com/mcp-toolbox-for-databases/${LATEST_VERSION}/linux/amd64/toolbox -o /app/toolbox
2414
RUN chmod +x /app/toolbox
2515

2616
# Copy the extension's skills and configuration into the container
@@ -32,5 +22,3 @@ RUN touch tools.yaml
3222

3323
# Expose HTTP API and UI endpoints to successfully pass Cloud Run health checks
3424
ENTRYPOINT ["/app/toolbox", "--prebuilt", "cloud-sql-postgres", "--address=0.0.0.0", "--port=8080", "--enable-api", "--ui"]
35-
36-

cloudbuild.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ steps:
55
args:
66
- 'build'
77
- '-t'
8-
- 'us-central1-docker.pkg.dev/omkar-playground/toolbox-evals/cloud-sql-postgresql:latest'
8+
- 'us-central1-docker.pkg.dev/$PROJECT_ID/toolbox-evals/cloud-sql-postgresql:latest'
99
- '.'
1010

1111
- name: 'gcr.io/cloud-builders/docker'
1212
args:
1313
- 'push'
14-
- 'us-central1-docker.pkg.dev/omkar-playground/toolbox-evals/cloud-sql-postgresql:latest'
14+
- 'us-central1-docker.pkg.dev/$PROJECT_ID/toolbox-evals/cloud-sql-postgresql:latest'
1515

1616
# --- STEP 2: Deploy to Cloud Run ---
1717
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
@@ -20,23 +20,23 @@ steps:
2020
- 'run'
2121
- 'deploy'
2222
- 'cloud-sql-postgresql-server'
23-
- '--image=us-central1-docker.pkg.dev/omkar-playground/toolbox-evals/cloud-sql-postgresql:latest'
23+
- '--image=us-central1-docker.pkg.dev/$PROJECT_ID/toolbox-evals/cloud-sql-postgresql:latest'
2424
- '--region=us-central1'
2525
- '--allow-unauthenticated'
2626
- '--port=8080'
2727
- '--timeout=300'
28-
- '--set-env-vars=CLOUD_SQL_POSTGRES_PROJECT=omkar-playground,CLOUD_SQL_POSTGRES_INSTANCE=omkar-demo-postgres-1,CLOUD_SQL_POSTGRES_REGION=us-central1,CLOUD_SQL_POSTGRES_DATABASE=postgres,CLOUD_SQL_POSTGRES_USER=postgres,CLOUD_SQL_POSTGRES_PASSWORD=[PASSWORD],CLOUD_SQL_POSTGRES_IP_TYPE=PUBLIC'
28+
- '--set-env-vars=CLOUD_SQL_POSTGRES_PROJECT=$PROJECT_ID,CLOUD_SQL_POSTGRES_INSTANCE=omkar-demo-postgres-1,CLOUD_SQL_POSTGRES_REGION=us-central1,CLOUD_SQL_POSTGRES_DATABASE=postgres,CLOUD_SQL_POSTGRES_USER=postgres,CLOUD_SQL_POSTGRES_PASSWORD=[PASSWORD],CLOUD_SQL_POSTGRES_IP_TYPE=PUBLIC'
2929

3030
# --- STEP 3: Fully Integrated Evaluation to Persist Results ---
31-
- name: 'us-central1-docker.pkg.dev/omkar-playground/toolbox-evals/eval_server:latest'
31+
- name: 'us-central1-docker.pkg.dev/$PROJECT_ID/toolbox-evals/eval_server:latest'
3232
entrypoint: 'bash'
3333
args:
3434
- '-c'
3535
- |
3636
set -e
3737
cd /evalbench
3838
39-
export EVAL_GCP_PROJECT_ID=omkar-playground
39+
export EVAL_GCP_PROJECT_ID=$PROJECT_ID
4040
export EVAL_GCP_PROJECT_REGION=us-central1
4141
4242
echo "Compiling protobuf files..."

0 commit comments

Comments
 (0)