FROM denoland/deno:alpine AS builder WORKDIR /app # Install build dependencies for native modules RUN apk add --no-cache build-base python3 COPY . . # Create node_modules directory and install dependencies RUN deno cache -r main.ts # Pre-cache npm deps with proper node_modules setup RUN deno task npm:init || echo "No npm:init task defined, continuing" # Build Fresh application in a more controlled way (without task) RUN deno run -A dev.ts build || deno run -A --unstable-worker-options --node-modules-dir main.ts build FROM denoland/deno:alpine WORKDIR /app # Copy the Deno cache and node_modules COPY --from=builder /deno-dir/ /deno-dir/ COPY --from=builder /app/node_modules/ /app/node_modules/ # Copy application code COPY --from=builder /app/ /app/ # Ensure static assets directories permissions are set correctly RUN chmod -R 755 /app/static /app/_fresh ENV DENO_DEPLOYMENT=production EXPOSE 8000 # Run with appropriate flags for static file serving CMD ["run", "--allow-net", "--allow-read", "--allow-env", "--node-modules-dir", "main.ts"]