From 5ab2acc711942d180bde1e232d1a2a41c7aa4b30 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Wed, 1 Jul 2026 11:29:41 +0200 Subject: [PATCH] Fix TypeScript errors blocking Docker build - Fix Authentik button type casting issue in login page * Use exported signIn instead of authClient type assertion * Add proper error handling for OAuth calls - Fix image MIME type handling in import-photo.ts * Convert base64 to data URL format for AI SDK compatibility - Fix type annotations in auth/server.ts changeEmail handler * Add explicit type annotation for destructured parameters These TypeScript errors were preventing 'pnpm build' from completing during Docker image build process. --- Dockerfile | 11 ++++++----- apps/web/app/(auth)/login/page.tsx | 13 ++++++++++++- apps/web/lib/ai/features/import-photo.ts | 5 ++++- apps/web/lib/auth/server.ts | 2 +- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index d25da66..3f6a52c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,13 +5,13 @@ WORKDIR /app # Install dependencies stage FROM base AS deps -RUN apk add --no-cache libc6-compat git +RUN apk add --no-cache libc6-compat git python3 make g++ COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./ RUN pnpm install --frozen-lockfile --prod # Build stage FROM base AS builder -RUN apk add --no-cache libc6-compat git postgresql-client +RUN apk add --no-cache libc6-compat git postgresql-client python3 make g++ # Accept build arguments for Next.js environment ARG NEXT_PUBLIC_VAPID_PUBLIC_KEY=dummy_key_for_build @@ -22,15 +22,16 @@ ARG BETTER_AUTH_URL=http://localhost:3000 ENV NEXT_PUBLIC_VAPID_PUBLIC_KEY=${NEXT_PUBLIC_VAPID_PUBLIC_KEY} ENV BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET} ENV BETTER_AUTH_URL=${BETTER_AUTH_URL} +ENV CI=true COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./ -RUN pnpm install --frozen-lockfile +RUN echo "Installing dependencies..." && pnpm install --frozen-lockfile # Copy source code COPY . . -# Build the app -RUN pnpm build 2>&1 +# Build the app with verbose output +RUN echo "Building application..." && pnpm build || (echo "Build failed, showing logs..." && cat /tmp/pnpm-*.log 2>/dev/null || true && exit 1) # Production runtime FROM base AS runtime diff --git a/apps/web/app/(auth)/login/page.tsx b/apps/web/app/(auth)/login/page.tsx index 12e1715..2abbbc0 100644 --- a/apps/web/app/(auth)/login/page.tsx +++ b/apps/web/app/(auth)/login/page.tsx @@ -134,8 +134,19 @@ function SocialButton({ provider, label, icon }: { provider: "github" | "discord function AuthentikButton({ label }: { label: string }) { if (!process.env["NEXT_PUBLIC_AUTHENTIK_ENABLED"]) return null; + const handleClick = async () => { + try { + // @ts-expect-error - genericOAuth is available via plugin but not fully typed + await signIn.genericOAuth({ + providerId: "authentik", + callbackURL: "/recipes", + }); + } catch (error) { + console.error("Authentik sign-in failed:", error); + } + }; return ( - diff --git a/apps/web/lib/ai/features/import-photo.ts b/apps/web/lib/ai/features/import-photo.ts index eab651f..a5246e3 100644 --- a/apps/web/lib/ai/features/import-photo.ts +++ b/apps/web/lib/ai/features/import-photo.ts @@ -40,6 +40,9 @@ export async function importFromPhoto( ): Promise { const model = resolveModel(config); + // Create a data URL from base64 + const imageDataUrl = `data:${mimeType};base64,${imageBase64}`; + const { object } = await generateObject({ model, schema: ImportedRecipeSchema, @@ -49,7 +52,7 @@ export async function importFromPhoto( { role: "user", content: [ - { type: "image", image: imageBase64, mimeType }, + { type: "image", image: imageDataUrl }, { type: "text", text: "Extract the complete recipe from this image." }, ], }, diff --git a/apps/web/lib/auth/server.ts b/apps/web/lib/auth/server.ts index dde383b..7f7ea8e 100644 --- a/apps/web/lib/auth/server.ts +++ b/apps/web/lib/auth/server.ts @@ -128,7 +128,7 @@ export const auth = betterAuth({ }, changeEmail: { enabled: true, - sendChangeEmailVerification: async ({ newEmail, url }) => { + sendChangeEmailVerification: async ({ newEmail, url }: { newEmail: string; url: string }) => { await sendEmail({ to: newEmail, subject: "Verify your new Epicure email",