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..eccc807 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +# Stage 1: Install dependencies +FROM node:18-alpine AS deps +WORKDIR /app + +# Copy package.json and lock file +COPY package.json ./ +COPY package-lock.json ./ || echo "No package-lock.json file found, skipping." + +# 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 +# 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 +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..3613eb7 --- /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' + - '--no-allow-unauthenticated' # Enforces authentication + +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 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 {