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.

This commit is contained in:
2025-08-15 22:41:33 +01:00
parent ba6eceefcb
commit bc481fa798

View File

@ -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