Use tsx to run TypeScript directly in production environments
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
Replace esbuild compilation with tsx execution in the Dockerfile to resolve module resolution errors by allowing TypeScript files to be run directly. 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
This commit is contained in:
+12
-15
@@ -14,27 +14,24 @@ FROM base AS build
|
||||
COPY --from=dependencies /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# Build the client application
|
||||
# Build the client application (frontend only)
|
||||
RUN npm run build
|
||||
|
||||
# Build server files separately (without bundling) - only production files
|
||||
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
|
||||
|
||||
# Build shared schema file
|
||||
RUN npx esbuild shared/schema.ts --platform=node --packages=external --format=esm --outdir=shared
|
||||
|
||||
# Production stage
|
||||
FROM base AS production
|
||||
|
||||
# Install production dependencies only
|
||||
COPY --from=dependencies /tmp/prod_node_modules ./node_modules
|
||||
# Install ALL dependencies (including tsx for running TypeScript in production)
|
||||
COPY --from=dependencies /app/node_modules ./node_modules
|
||||
|
||||
# Copy built application
|
||||
COPY --from=build /app/dist ./dist
|
||||
COPY --from=build /app/shared/schema.js ./shared/
|
||||
# Copy built frontend
|
||||
COPY --from=build /app/dist/public ./dist/public
|
||||
|
||||
# Copy server source files (TypeScript)
|
||||
COPY --from=build /app/server ./server
|
||||
COPY --from=build /app/shared ./shared
|
||||
COPY --from=build /app/drizzle.config.ts ./
|
||||
COPY --from=build /app/package.json ./
|
||||
COPY --from=build /app/tsconfig.json ./
|
||||
|
||||
# Set environment variables
|
||||
ENV NODE_ENV=production
|
||||
@@ -47,5 +44,5 @@ EXPOSE 5000
|
||||
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"]
|
||||
# Start the application using tsx to run TypeScript directly
|
||||
CMD ["npx", "tsx", "server/index.ts"]
|
||||
|
||||
Reference in New Issue
Block a user