# Build stage FROM oven/bun:1 AS src # Set build arguments ARG BETTER_AUTH_SECRET ARG DATABASE_URL ARG REDIS_URL # Set environment variables for build ENV BETTER_AUTH_SECRET=$BETTER_AUTH_SECRET ENV DATABASE_URL=$DATABASE_URL ENV REDIS_URL=$REDIS_URL WORKDIR /app # Copy package files COPY package.json bun.lock* ./ # Install dependencies RUN bun install --frozen-lockfile # Install lightningcss for Linux # RUN bun add -D lightningcss-linux-x64-gnu # Copy source code COPY . . # Build the application RUN bun run nitro:build # Production stage FROM oven/bun:1-slim WORKDIR /app # Copy built application # 01 - Drizzle DB COPY --from=src /app/database ./database # 02 - Dependencies COPY --from=src /app/node_modules ./node_modules # 03 - Static content COPY --from=src /app/public ./public # 04 - Application COPY --from=src /app/src ./src # 05 - Utilities COPY --from=src /app/utils ./utils # 06 - Package COPY --from=src /app/package.json ./package.json # 07 - Output COPY --from=src /app/.output ./.output # Set runtime environment variables ENV NODE_ENV=production ENV PORT=3000 EXPOSE 3000 # Start the application CMD ["bun", "run", "nitro:serve"]