mirror of
https://github.com/PragmaticMachineLearning/probly.git
synced 2026-01-09 21:37:56 -05:00
This commit adds Docker support for easy deployment and improves browser compatibility: - Add Dockerfile and docker-compose.yml for containerized deployment - Fix Pyodide integration to work properly in browser-only mode - Add mock implementation for server-side rendering - Clean up markdown formatting in analysis output - Update README with Docker deployment instructions - Add platform-specific keyboard shortcuts (Mac/Windows) - Ensure public directory exists in Docker build - Fix TypeScript type definitions for Pyodide The application now properly handles the browser/server environment difference, with Python analysis running exclusively in the browser while the server provides API proxying and static file serving.
61 lines
1.3 KiB
Docker
61 lines
1.3 KiB
Docker
FROM node:20-alpine AS base
|
|
|
|
# Install dependencies only when needed
|
|
FROM base AS deps
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package.json package-lock.json* ./
|
|
RUN npm ci
|
|
|
|
# Install missing dependency
|
|
RUN npm install class-variance-authority
|
|
|
|
# Rebuild the source code only when needed
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
# Ensure public directory exists
|
|
RUN mkdir -p ./public
|
|
|
|
# Set environment variables with build-time defaults
|
|
ARG OPENAI_API_KEY
|
|
ENV OPENAI_API_KEY=$OPENAI_API_KEY
|
|
|
|
# Build the application
|
|
RUN npm run build
|
|
|
|
# Production image, copy all the files and run next
|
|
FROM base AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV production
|
|
|
|
# Create a non-root user
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN adduser --system --uid 1001 nextjs
|
|
|
|
# Create public directory if it doesn't exist
|
|
RUN mkdir -p ./public
|
|
# Set proper permissions
|
|
RUN chown -R nextjs:nodejs ./public
|
|
|
|
# Switch to non-root user
|
|
USER nextjs
|
|
|
|
# Copy necessary files from builder
|
|
COPY --from=builder /app/.next/standalone ./
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
COPY --from=builder /app/public ./public
|
|
|
|
# Set environment variables with runtime defaults
|
|
ENV PORT 3000
|
|
ENV HOSTNAME "0.0.0.0"
|
|
|
|
# Expose the port the app will run on
|
|
EXPOSE 3000
|
|
|
|
# Start the application
|
|
CMD ["node", "server.js"] |