Dockerfile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Base stage with system dependencies and pnpm
  2. FROM node:20-slim AS base
  3. # Install system dependencies including HandBrakeCLI, SQLite, and FFmpeg
  4. RUN apt-get update && apt-get install -y \
  5. handbrake-cli \
  6. sqlite3 \
  7. ffmpeg \
  8. && rm -rf /var/lib/apt/lists/*
  9. # Install pnpm globally
  10. RUN npm install -g pnpm
  11. WORKDIR /app
  12. # Dependencies stage - install all dependencies
  13. FROM base AS dependencies
  14. # Copy package files for dependency installation
  15. COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json ./
  16. COPY apps/*/package.json ./apps/
  17. COPY packages/*/package.json ./packages/
  18. # Install all dependencies (including dev dependencies for building)
  19. RUN pnpm install --frozen-lockfile
  20. # Development stage
  21. FROM dependencies AS development
  22. # Copy all source code
  23. COPY . .
  24. # Expose ports
  25. EXPOSE 3000 3001 3002
  26. # Set the CLI as the default entrypoint for development
  27. ENTRYPOINT ["pnpm", "run", "cli"]
  28. CMD []
  29. # Builder stage - builds the applications
  30. FROM dependencies AS builder
  31. # Copy all source code
  32. COPY . .
  33. # Build all applications
  34. RUN pnpm run build
  35. # Production stage - final runtime image
  36. FROM base AS production
  37. # Copy package files for production dependencies
  38. COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json ./
  39. COPY apps/*/package.json ./apps/
  40. COPY packages/*/package.json ./packages/
  41. # Install only production dependencies
  42. RUN pnpm install --frozen-lockfile --prod
  43. # Copy built applications from builder stage
  44. COPY --from=builder /app/apps/web/.next ./apps/web/.next
  45. COPY --from=builder /app/apps/web/public ./apps/web/public
  46. COPY --from=builder /app/apps/service/dist ./apps/service/dist
  47. COPY --from=builder /app/apps/cli/dist ./apps/cli/dist
  48. # Copy necessary config files for Next.js
  49. COPY apps/web/next.config.ts apps/web/next.config.js ./apps/web/
  50. # Expose ports
  51. EXPOSE 3000 3001 3002
  52. # Default command runs all services in production
  53. CMD ["pnpm", "start"]