diff --git a/Dockerfile b/Dockerfile index 0173951..684ce5b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,30 +2,37 @@ FROM denoland/deno:alpine AS builder WORKDIR /app +# Install build dependencies for native modules +RUN apk add --no-cache build-base python3 + COPY . . -# Build the Fresh application -RUN deno task build +# Create node_modules directory and install dependencies +RUN deno cache -r main.ts -# Pre-cache the application dependencies -RUN deno cache 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 +# 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 including both static directories +# Copy application code COPY --from=builder /app/ /app/ # Ensure static assets directories permissions are set correctly -RUN chmod -R 755 /app/static /app/_fresh/static +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", "main.ts"] +CMD ["run", "--allow-net", "--allow-read", "--allow-env", "--node-modules-dir", "main.ts"]