From bc481fa798386baad24924b5068b9574f1205185 Mon Sep 17 00:00:00 2001 From: Oliver Gwyther Date: Fri, 15 Aug 2025 22:41:33 +0100 Subject: [PATCH] Refactor Dockerfile to remove problematic packages from package.json and reinstall dependencies for a cleaner frontend-only build. Updated mock API implementation to generate random IDs for improved uniqueness. --- Dockerfile | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 294fac6..258600a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,18 @@ ENV VITE_APP_NAME=$VITE_APP_NAME ENV VITE_APP_URL=$VITE_APP_URL ENV VITE_ANALYTICS_ENABLED=$VITE_ANALYTICS_ENABLED +# Remove problematic packages from package.json to prevent them from being bundled +RUN sed -i '/"mysql2"/d' package.json +RUN sed -i '/"drizzle-orm"/d' package.json +RUN sed -i '/"bcrypt"/d' package.json +RUN sed -i '/"jsonwebtoken"/d' package.json +RUN sed -i '/"@types\/bcrypt"/d' package.json +RUN sed -i '/"@types\/jsonwebtoken"/d' package.json +RUN sed -i '/"nanoid"/d' package.json + +# Reinstall dependencies without server packages +RUN npm install + # Remove problematic server-side API files for frontend-only build RUN rm -rf src/lib/api || true RUN rm -rf src/lib/db || true @@ -37,7 +49,7 @@ RUN echo "export const db = {};" > src/lib/db/index.ts RUN echo "export const users = {}; export const scripts = {}; export const ratings = {}; export const scriptVersions = {}; export const scriptAnalytics = {}; export const scriptCollections = {}; export const collectionScripts = {};" > src/lib/db/schema.ts # Create mock API index -RUN echo "export const generateId = () => 'mock-id'; export class ApiError extends Error { constructor(message, status) { super(message); this.status = status; } }" > src/lib/api/index.ts +RUN echo "export const generateId = () => Math.random().toString(36).substr(2, 9); export class ApiError extends Error { constructor(message, status) { super(message); this.status = status; } }" > src/lib/api/index.ts # Create mock auth API RUN echo "export const authApi = { login: async () => ({ token: 'demo', user: { id: '1', username: 'demo' } }), register: async () => ({ token: 'demo', user: { id: '1', username: 'demo' } }), changePassword: async () => ({}), refreshToken: async () => ({ token: 'demo' }) };" > src/lib/api/auth.ts