From af2b2bcf95fc6064b90ee89dba1bd33e1e76ca86 Mon Sep 17 00:00:00 2001 From: Dan Noble Date: Fri, 30 Jan 2026 11:53:37 -0800 Subject: [PATCH 1/2] Added datacommons-platform dockerfile and cloud build configuration to build and deploy image to artifact registry --- build/Dockerfile | 29 +++++++++++++++++++++++++ build/cloudbuild.yaml | 12 +++++++++++ docs/deploy_artifacts.md | 46 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 build/Dockerfile create mode 100644 build/cloudbuild.yaml create mode 100644 docs/deploy_artifacts.md diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000..a75d2b7 --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,29 @@ +FROM python:3.12-slim + +# Install uv. +COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv + +# Set working directory +WORKDIR /app + +# Copy the workspace configuration files +COPY pyproject.toml uv.lock ./ + +# Copy the package directories +COPY packages/ ./packages/ + +# Install the dependencies, strictly from the lockfile +RUN uv sync --frozen --no-dev --no-install-project + +# Install the project itself +RUN uv sync --frozen --no-dev + +# Place the virtualenv in the PATH +ENV PATH="/app/.venv/bin:$PATH" + +# Expose the API port +EXPOSE 5000 + +# Set the entrypoint to the CLI +ENTRYPOINT ["datacommons", "api"] +CMD ["--host", "0.0.0.0", "--port", "5000"] diff --git a/build/cloudbuild.yaml b/build/cloudbuild.yaml new file mode 100644 index 0000000..874d364 --- /dev/null +++ b/build/cloudbuild.yaml @@ -0,0 +1,12 @@ +steps: + # Build the container image + - name: 'gcr.io/cloud-builders/docker' + args: ['build', '-t', 'gcr.io/datcom-ci/datacommons-platform:latest', '-t', 'gcr.io/datcom-ci/datacommons-platform:$COMMIT_SHA', '-f', 'build/Dockerfile', '.'] + # Push the container image to Container Registry + - name: 'gcr.io/cloud-builders/docker' + args: ['push', 'gcr.io/datcom-ci/datacommons-platform:latest'] + - name: 'gcr.io/cloud-builders/docker' + args: ['push', 'gcr.io/datcom-ci/datacommons-platform:$COMMIT_SHA'] +images: + - 'gcr.io/datcom-ci/datacommons-platform:latest' + - 'gcr.io/datcom-ci/datacommons-platform:$COMMIT_SHA' diff --git a/docs/deploy_artifacts.md b/docs/deploy_artifacts.md new file mode 100644 index 0000000..ba253a1 --- /dev/null +++ b/docs/deploy_artifacts.md @@ -0,0 +1,46 @@ +# Deploying Data Commons Platform Artifacts + +> **Internal Process Only** +> This document describes the deployment process for deploying the Data Commons Platform docker artifacts to Google's managed Artifact Registry. These instructions are not intended for general users or external deployments. + +## Prerequisites + +- [Google Cloud SDK](https://cloud.google.com/sdk/docs/install) installed and authenticated. +- Access to the `datcom-ci` GCP project. +- `docker` installed locally (optional, for local builds). + +## Building Locally + +To build the Docker image locally, you **must run the command from the repository root**, pointing to the Dockerfile in `build/`. + +```bash +docker build -f build/Dockerfile -t datacommons-platform:local . +``` + +To run the container locally: + +```bash +docker run -p 5000:5000 datacommons-platform:local +``` + +Access the API at `http://localhost:5000`. + +## Deploying via Cloud Build + +We use Google Cloud Build to build and push images to Google Container Registry (GCR). + +### Manual Deployment + +You can manually trigger a build from your local machine using the `gcloud` CLI. You must provide the `COMMIT_SHA` substitution manually. + +```bash +gcloud builds submit --config build/cloudbuild.yaml \ + --substitutions=COMMIT_SHA=$(git rev-parse HEAD) \ + --project=datcom-ci \ + . +``` + +This will: +1. Upload your current workspace (files in `.`) to Cloud Build. +2. Execute steps in `build/cloudbuild.yaml`. +3. Push images to `gcr.io/datcom-ci/datacommons-platform:latest` and `:CommitSHA`. From cf8b4b2d0afda99f9ee9d614676b4dcad8a5eb7c Mon Sep 17 00:00:00 2001 From: Dan Noble Date: Fri, 30 Jan 2026 11:56:06 -0800 Subject: [PATCH 2/2] docs --- docs/deploy_artifacts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/deploy_artifacts.md b/docs/deploy_artifacts.md index ba253a1..ae97b3b 100644 --- a/docs/deploy_artifacts.md +++ b/docs/deploy_artifacts.md @@ -1,7 +1,7 @@ # Deploying Data Commons Platform Artifacts > **Internal Process Only** -> This document describes the deployment process for deploying the Data Commons Platform docker artifacts to Google's managed Artifact Registry. These instructions are not intended for general users or external deployments. +> This document describes the process for deploying the Data Commons Platform docker artifacts to Google's managed Artifact Registry. These instructions are not intended for general users or external deployments. ## Prerequisites