- Add serverExternalPackages for @elysiajs/static and elysia to prevent webpack from bundling dynamic imports that cause Html prerender error - Use output: standalone for proper Docker deployment - Comment out NODE_ENV=development in .env.example to avoid conflict with next build which requires NODE_ENV=production - Set NODE_ENV=production before build step in Dockerfile - Update runtime stage to use standalone output structure Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
58 lines
1.2 KiB
Docker
58 lines
1.2 KiB
Docker
# Stage 1: Build
|
|
FROM oven/bun:1.3 AS build
|
|
|
|
# Install build dependencies for native modules
|
|
RUN apt-get update && apt-get install -y \
|
|
python3 \
|
|
make \
|
|
g++ \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Set the working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package.json bun.lock* ./
|
|
|
|
# Install dependencies
|
|
RUN bun install --frozen-lockfile
|
|
|
|
# Copy the rest of the application code
|
|
COPY . .
|
|
|
|
# Use .env.example as default env for build
|
|
RUN cp .env.example .env
|
|
|
|
# Generate Prisma client
|
|
RUN bun x prisma generate
|
|
|
|
# Build the application frontend
|
|
ENV NODE_ENV=production
|
|
RUN bun run build
|
|
|
|
# Stage 2: Runtime
|
|
FROM oven/bun:1.3-slim AS runtime
|
|
|
|
# Set environment variables
|
|
ENV NODE_ENV=production
|
|
|
|
# Install runtime dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
postgresql-client \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Set the working directory
|
|
WORKDIR /app
|
|
|
|
# Copy necessary files from build stage (standalone output)
|
|
COPY --from=build /app/.next/standalone ./
|
|
COPY --from=build /app/.next/static ./.next/static
|
|
COPY --from=build /app/public ./public
|
|
COPY --from=build /app/prisma ./prisma
|
|
|
|
# Expose the port
|
|
EXPOSE 3000
|
|
|
|
# Start the application
|
|
CMD ["bun", "server.js"]
|