Refactor Docker setup for frontend-only builds by removing server-side API files, creating mock APIs, and updating health check notes. Adjusted Vite configuration for browser compatibility and refined API handling in various components to improve user experience and maintainability.

This commit is contained in:
2025-08-15 22:35:15 +01:00
parent f7dc75d514
commit 7d100e7e0f
16 changed files with 224 additions and 124 deletions

View File

@ -25,7 +25,68 @@ ENV VITE_APP_NAME=$VITE_APP_NAME
ENV VITE_APP_URL=$VITE_APP_URL
ENV VITE_ANALYTICS_ENABLED=$VITE_ANALYTICS_ENABLED
# Build the application
# Remove problematic server-side API files for frontend-only build
RUN rm -rf src/lib/api || true
RUN rm -rf src/lib/db || true
# Create mock API layer for frontend demo
RUN mkdir -p src/lib/api src/lib/db
RUN echo "export const db = {}; export * from './mock';" > src/lib/db/index.ts
RUN echo "export const users = {}; export const scripts = {};" > src/lib/db/schema.ts
RUN echo "export * from './mock';" > src/lib/api/index.ts
# Create mock API files
RUN cat > src/lib/api/auth.ts << 'EOF'
export const authApi = {
login: async () => ({ token: 'demo', user: { id: '1', username: 'demo' } }),
register: async () => ({ token: 'demo', user: { id: '1', username: 'demo' } }),
};
EOF
RUN cat > src/lib/api/scripts.ts << 'EOF'
export const scriptsApi = {
getScripts: async () => ({ scripts: [], total: 0 }),
getScript: async () => null,
createScript: async () => ({}),
updateScript: async () => ({}),
deleteScript: async () => ({}),
moderateScript: async () => ({}),
};
EOF
RUN cat > src/lib/api/ratings.ts << 'EOF'
export const ratingsApi = {
submitRating: async () => ({}),
getUserRating: async () => null,
getScriptRatingStats: async () => ({ averageRating: 0, totalRatings: 0 }),
};
EOF
RUN cat > src/lib/api/analytics.ts << 'EOF'
export const analyticsApi = {
trackEvent: async () => ({}),
getAnalytics: async () => ({ views: [], downloads: [] }),
};
EOF
RUN cat > src/lib/api/collections.ts << 'EOF'
export const collectionsApi = {
getCollections: async () => [],
createCollection: async () => ({}),
updateCollection: async () => ({}),
deleteCollection: async () => ({}),
};
EOF
RUN cat > src/lib/api/users.ts << 'EOF'
export const usersApi = {
getUser: async () => null,
updateUser: async () => ({}),
updateUserPermissions: async () => ({}),
};
EOF
# Build the application (frontend only with mocks)
RUN npm run build
# Verify build output exists