Files
task-manager/Dockerfile
T
paul-nothaft e0512aa412
continuous-integration/drone/push Build is passing
Fix Vite module not found error in production Docker deployments
Update Dockerfile to compile server files separately without bundling, preventing Vite dependency issues in production. Includes troubleshooting documentation for the Vite module error.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: ceced2fc-aa46-458d-ba87-ddd4b7bb1518
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/659922a9-0087-461c-90dd-6d9a58b81d4d/ceced2fc-aa46-458d-ba87-ddd4b7bb1518/SBF5OKZ
2025-10-23 15:00:04 +00:00

48 lines
1.3 KiB
Docker

# Base stage with Node.js
FROM node:20-alpine AS base
WORKDIR /app
# Dependencies stage
FROM base AS dependencies
COPY package.json package-lock.json ./
RUN npm ci --only=production && \
cp -R node_modules /tmp/prod_node_modules && \
npm ci
# Build stage
FROM base AS build
COPY --from=dependencies /app/node_modules ./node_modules
COPY . .
# Build the client application
RUN npm run build
# Build server files separately (without bundling)
RUN npx esbuild server/index.ts server/routes.ts server/storage.ts server/db.ts server/static.ts --platform=node --packages=external --format=esm --outdir=dist
# Production stage
FROM base AS production
# Install production dependencies only
COPY --from=dependencies /tmp/prod_node_modules ./node_modules
# Copy built application
COPY --from=build /app/dist ./dist
COPY --from=build /app/shared ./shared
COPY --from=build /app/drizzle.config.ts ./
COPY --from=build /app/package.json ./
# Set environment variables
ENV NODE_ENV=production
ENV PORT=5000
# Expose the application port
EXPOSE 5000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:5000/api/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# Start the application
CMD ["node", "dist/index.js"]