From da6d625b2cefab1288da1979a9be80efe03d799f Mon Sep 17 00:00:00 2001 From: Fadi Al Zuabi Date: Fri, 25 Jul 2025 05:01:50 -0700 Subject: [PATCH 1/5] deploy info --- .dockerignore | 6 ++++++ Dockerfile | 32 ++++++++++++++++++++++++++++++++ LICENSE | 21 +++++++++++++++++++++ cloudbuild.yaml | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 cloudbuild.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..13e1d97 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +Dockerfile +.dockerignore +node_modules +.git +.next +README.md \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a07b160 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +# Stage 1: Install dependencies +FROM node:18-alpine AS deps +WORKDIR /app + +# Copy package.json and lock file +COPY package.json package-lock.json* ./ + +# Install dependencies +RUN npm install + +# Stage 2: Build the application +FROM node:18-alpine AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +# Build the Next.js application +RUN npm run build + +# Stage 3: Production image +FROM node:18-alpine AS runner +WORKDIR /app + +ENV NODE_ENV=production + +COPY --from=builder /app/public ./public +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/package.json ./package.json + +EXPOSE 3000 +CMD ["npm", "start"] \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..53bccbb --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Fadi Al Zuabi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/cloudbuild.yaml b/cloudbuild.yaml new file mode 100644 index 0000000..9103ef2 --- /dev/null +++ b/cloudbuild.yaml @@ -0,0 +1,34 @@ +steps: + # 1. Build the container image + - name: 'gcr.io/cloud-builders/docker' + args: + - 'build' + - '-t' + - '${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO_NAME}/${_SERVICE_NAME}:$COMMIT_SHA' + - '.' + + # 2. Push the container image to Artifact Registry + - name: 'gcr.io/cloud-builders/docker' + args: + - 'push' + - '${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO_NAME}/${_SERVICE_NAME}:$COMMIT_SHA' + + # 3. Deploy new revision to Cloud Run + - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk' + entrypoint: gcloud + args: + - 'run' + - 'deploy' + - '${_SERVICE_NAME}' + - '--image=${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO_NAME}/${_SERVICE_NAME}:$COMMIT_SHA' + - '--region=${_REGION}' + - '--platform=managed' + - '--allow-unauthenticated' # Allows public access + +images: + - '${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO_NAME}/${_SERVICE_NAME}:$COMMIT_SHA' + +substitutions: + _SERVICE_NAME: 'toico' + _REPO_NAME: 'toico-repo' + _REGION: 'us-central1' # Use the same region as your Artifact Registry \ No newline at end of file From 1fc5f4911103c4cb3b76821d2729790fbdc34146 Mon Sep 17 00:00:00 2001 From: Fadi Al Zuabi <32167833+zzfadi@users.noreply.github.com> Date: Fri, 25 Jul 2025 05:08:53 -0700 Subject: [PATCH 2/5] 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 a07b160..bebae18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ ENV NODE_ENV=production COPY --from=builder /app/public ./public COPY --from=builder /app/.next ./.next -COPY --from=builder /app/node_modules ./node_modules +# node_modules is not copied from the builder stage as production dependencies are installed directly COPY --from=builder /app/package.json ./package.json EXPOSE 3000 From 4a8fc4f98fde43a27df98b516bc856a236425c6d Mon Sep 17 00:00:00 2001 From: Fadi Al Zuabi <32167833+zzfadi@users.noreply.github.com> Date: Fri, 25 Jul 2025 05:09:01 -0700 Subject: [PATCH 3/5] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bebae18..eccc807 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,8 @@ FROM node:18-alpine AS deps WORKDIR /app # Copy package.json and lock file -COPY package.json package-lock.json* ./ +COPY package.json ./ +COPY package-lock.json ./ || echo "No package-lock.json file found, skipping." # Install dependencies RUN npm install From a700e9524a5bc91f53cc609a948ef9149e7458bc Mon Sep 17 00:00:00 2001 From: Fadi Al Zuabi <32167833+zzfadi@users.noreply.github.com> Date: Fri, 25 Jul 2025 05:09:08 -0700 Subject: [PATCH 4/5] 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 9103ef2..3613eb7 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -23,7 +23,7 @@ steps: - '--image=${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO_NAME}/${_SERVICE_NAME}:$COMMIT_SHA' - '--region=${_REGION}' - '--platform=managed' - - '--allow-unauthenticated' # Allows public access + - '--no-allow-unauthenticated' # Enforces authentication images: - '${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO_NAME}/${_SERVICE_NAME}:$COMMIT_SHA' From aaf1bdad5a9c26379b9c972ce535d046c26feea9 Mon Sep 17 00:00:00 2001 From: Fadi Al Zuabi Date: Fri, 25 Jul 2025 05:18:40 -0700 Subject: [PATCH 5/5] hotfix --- src/app/utils/imageToSvg.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/app/utils/imageToSvg.ts b/src/app/utils/imageToSvg.ts index f47368e..3872278 100644 --- a/src/app/utils/imageToSvg.ts +++ b/src/app/utils/imageToSvg.ts @@ -78,10 +78,9 @@ export async function convertImageToSvg( * Process SVG files for optimization and multi-size generation */ async function processSvgToSvg( - file: File, - sizes: number[], - // @ts-expect-error - options is not used in this function - _options: SvgConversionOptions + file: File, + sizes: number[], + options: SvgConversionOptions = {} ): Promise> { const svgContent = await readFileAsText(file); const elements: Array<{ size: number; element: string; viewBox: string }> = []; @@ -331,7 +330,6 @@ function readFileAsText(file: File): Promise { export async function convertImageToIndividualSvgs( file: File, selectedSizes: number[], - // @ts-expect-error - options is not used in this function _options: SvgConversionOptions = {} ): Promise> { try {