From c5d20a42c72ea97ddf05b06fd6174c8d5e61412c Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 25 Jul 2025 11:40:12 +0000 Subject: [PATCH 1/7] feat: Add Google Cloud deployment documentation This commit adds the necessary files and documentation to deploy the application to Google Cloud Platform. It includes: - A `Dockerfile` to containerize the application. - A `.dockerignore` file to optimize the Docker build. - A `cloudbuild.yaml` file to define the build and deployment pipeline for Google Cloud Build. - A `DEPLOY.md` file with detailed instructions on how to deploy the application to Google Cloud Run. --- .dockerignore | 19 ++++++++++++++++++ DEPLOY.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 35 +++++++++++++++++++++++++++++++++ cloudbuild.yaml | 25 ++++++++++++++++++++++++ 4 files changed, 131 insertions(+) create mode 100644 .dockerignore create mode 100644 DEPLOY.md create mode 100644 Dockerfile create mode 100644 cloudbuild.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e48fb8b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,19 @@ +# Dependencies +node_modules + +# Next.js build output +.next + +# Docker +Dockerfile +.dockerignore + +# Git +.git +.gitignore + +# Other +README.md +.github +docs +tests diff --git a/DEPLOY.md b/DEPLOY.md new file mode 100644 index 0000000..cd6e86f --- /dev/null +++ b/DEPLOY.md @@ -0,0 +1,52 @@ +# Deploying to Google Cloud + +This guide will walk you through deploying the application to Google Cloud using Google Cloud Build and Google Cloud Run. + +## Prerequisites + +1. **Google Cloud Project:** You need a Google Cloud project with billing enabled. +2. **gcloud CLI:** You need to have the `gcloud` command-line tool installed and configured for your project. +3. **Enable APIs:** Enable the Cloud Build, Cloud Run, and Container Registry APIs for your project. You can do this with the following commands: + + ```bash + gcloud services enable cloudbuild.googleapis.com + gcloud services enable run.googleapis.com + gcloud services enable containerregistry.googleapis.com + ``` + +## Deployment Steps + +1. **Clone the repository:** + + ```bash + git clone https://github.com/zzfadi/toico.git + cd toico + ``` + +2. **Set your Project ID:** + + Replace `[YOUR_PROJECT_ID]` with your Google Cloud project ID. + + ```bash + export PROJECT_ID=[YOUR_PROJECT_ID] + ``` + +3. **Run Cloud Build:** + + This command will use the `cloudbuild.yaml` file to build the Docker image, push it to Google Container Registry, and deploy it to Google Cloud Run. + + ```bash + gcloud builds submit --config cloudbuild.yaml . + ``` + +4. **Access your application:** + + Once the deployment is complete, you will see the URL of your deployed application in the output. You can also find the URL in the Google Cloud Console under Cloud Run. + +## Continuous Deployment (Optional) + +You can set up a trigger in Google Cloud Build to automatically deploy the application whenever you push changes to your Git repository. + +1. Go to the Cloud Build section in the Google Cloud Console. +2. Go to the "Triggers" tab and click "Create trigger". +3. Connect your repository and configure the trigger to use the `cloudbuild.yaml` file for the build configuration. diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..17a2ad9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# Stage 1: Build the Next.js application +FROM node:20-alpine AS builder + +# Set working directory +WORKDIR /app + +# Copy package.json and package-lock.json +COPY package.json package-lock.json ./ + +# Install dependencies +RUN npm install + +# Copy the rest of the application files +COPY . . + +# Build the Next.js application +RUN npm run build + +# Stage 2: Create the production image +FROM node:20-alpine AS runner + +# Set working directory +WORKDIR /app + +# Copy the built application from the builder stage +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/public ./public +COPY --from=builder /app/package.json ./package.json +COPY --from=builder /app/next.config.ts ./next.config.ts + +# Expose the port the app runs on +EXPOSE 3000 + +# Start the Next.js application +CMD ["npm", "start"] diff --git a/cloudbuild.yaml b/cloudbuild.yaml new file mode 100644 index 0000000..85bfb62 --- /dev/null +++ b/cloudbuild.yaml @@ -0,0 +1,25 @@ +steps: + # Build the container image + - name: 'gcr.io/cloud-builders/docker' + args: ['build', '-t', 'gcr.io/$PROJECT_ID/toico:$COMMIT_SHA', '.'] + + # Push the container image to Container Registry + - name: 'gcr.io/cloud-builders/docker' + args: ['push', 'gcr.io/$PROJECT_ID/toico:$COMMIT_SHA'] + + # Deploy container image to Cloud Run + - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk' + entrypoint: gcloud + args: + - 'run' + - 'deploy' + - 'toico' + - '--image' + - 'gcr.io/$PROJECT_ID/toico:$COMMIT_SHA' + - '--region' + - 'us-central1' + - '--platform' + - 'managed' + - '--allow-unauthenticated' +images: + - 'gcr.io/$PROJECT_ID/toico:$COMMIT_SHA' From 15bb9cf514dd878957b7cdb9fa148140c775d0b7 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 25 Jul 2025 11:58:47 +0000 Subject: [PATCH 2/7] feat: Add Google Cloud deployment documentation This commit adds the necessary files and documentation to deploy the application to Google Cloud Platform. It includes: - A `Dockerfile` to containerize the application. - A `.dockerignore` file to optimize the Docker build. - A `cloudbuild.yaml` file to define the build and deployment pipeline for Google Cloud Build. - A `DEPLOY.md` file with detailed instructions on how to deploy the application to Google Cloud Run, including instructions for mapping a custom domain. --- DEPLOY.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/DEPLOY.md b/DEPLOY.md index cd6e86f..27ed3d3 100644 --- a/DEPLOY.md +++ b/DEPLOY.md @@ -43,6 +43,19 @@ This guide will walk you through deploying the application to Google Cloud using Once the deployment is complete, you will see the URL of your deployed application in the output. You can also find the URL in the Google Cloud Console under Cloud Run. +## Mapping a Custom Domain + +To map a custom domain like `tools.definedbyjenna.com` to your Cloud Run service, follow these steps: + +1. **Go to the Cloud Run section** in the Google Cloud Console. +2. **Click on your service** (e.g., `toico`). +3. **Click on "Manage custom domains"**. +4. **Click "Add mapping"**. +5. **Select your verified domain** from the dropdown list. If you haven't verified your domain with Google Cloud yet, you will be prompted to do so. +6. **Enter the subdomain** you want to use (e.g., `tools`). +7. **Click "Continue"** and follow the instructions to update your DNS records. This will typically involve adding a `CNAME` or `A` record to your DNS provider's configuration (e.g., Squarespace). +8. **Wait for the DNS changes to propagate**. This can take up to 24 hours. Once the propagation is complete, your application will be available at your custom domain. + ## Continuous Deployment (Optional) You can set up a trigger in Google Cloud Build to automatically deploy the application whenever you push changes to your Git repository. From 82b788e1669bd573e036dff8e5b0996c84ca37d1 Mon Sep 17 00:00:00 2001 From: Fadi Al Zuabi <32167833+zzfadi@users.noreply.github.com> Date: Fri, 25 Jul 2025 05:06:59 -0700 Subject: [PATCH 3/7] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- cloudbuild.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 85bfb62..132a3dc 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -1,11 +1,11 @@ steps: # Build the container image - name: 'gcr.io/cloud-builders/docker' - args: ['build', '-t', 'gcr.io/$PROJECT_ID/toico:$COMMIT_SHA', '.'] + args: ['build', '-t', 'gcr.io/$PROJECT_ID/$_SERVICE_NAME:$COMMIT_SHA', '.'] # Push the container image to Container Registry - name: 'gcr.io/cloud-builders/docker' - args: ['push', 'gcr.io/$PROJECT_ID/toico:$COMMIT_SHA'] + args: ['push', 'gcr.io/$PROJECT_ID/$_SERVICE_NAME:$COMMIT_SHA'] # Deploy container image to Cloud Run - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk' From ea61e22975dcf9d598bc96a22b8a1ecb2bf504b7 Mon Sep 17 00:00:00 2001 From: Fadi Al Zuabi <32167833+zzfadi@users.noreply.github.com> Date: Fri, 25 Jul 2025 05:07:07 -0700 Subject: [PATCH 4/7] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- cloudbuild.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 132a3dc..87a586c 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -20,6 +20,6 @@ steps: - 'us-central1' - '--platform' - 'managed' - - '--allow-unauthenticated' +# 23: - '--allow-unauthenticated' images: - 'gcr.io/$PROJECT_ID/toico:$COMMIT_SHA' From 13497db296b2400c27ee9aad439d9ab955852dfb Mon Sep 17 00:00:00 2001 From: Fadi Al Zuabi <32167833+zzfadi@users.noreply.github.com> Date: Fri, 25 Jul 2025 05:07:17 -0700 Subject: [PATCH 5/7] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 17a2ad9..ba94427 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ WORKDIR /app COPY package.json package-lock.json ./ # Install dependencies -RUN npm install +RUN npm ci --only=production # Copy the rest of the application files COPY . . From f8240ce2b61fe44d1ca8d6dcddcbf48ac309fc64 Mon Sep 17 00:00:00 2001 From: Fadi Al Zuabi <32167833+zzfadi@users.noreply.github.com> Date: Fri, 25 Jul 2025 05:07:22 -0700 Subject: [PATCH 6/7] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index ba94427..6df7ffb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,7 @@ WORKDIR /app COPY --from=builder /app/.next ./.next COPY --from=builder /app/public ./public COPY --from=builder /app/package.json ./package.json +COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/next.config.ts ./next.config.ts # Expose the port the app runs on From 5d1f39ab486a7b962ad328f33e56daa17e9d3cda Mon Sep 17 00:00:00 2001 From: Fadi Al Zuabi <32167833+zzfadi@users.noreply.github.com> Date: Fri, 25 Jul 2025 05:20:27 -0700 Subject: [PATCH 7/7] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6df7ffb..77dfb5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ WORKDIR /app COPY package.json package-lock.json ./ # Install dependencies -RUN npm ci --only=production +RUN npm ci # Copy the rest of the application files COPY . .