# syntax=docker/dockerfile:1 # Stage 1: Install dependencies FROM oven/bun:1.3.14-alpine AS deps WORKDIR /app # Copy only package files to leverage Docker layer caching COPY package.json bun.lock ./ # Install dependencies RUN --mount=type=cache,target=/root/.bun/install/cache \ bun install --frozen-lockfile # Stage 2: Build the application FROM oven/bun:1.3.14-alpine AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . # Build Next.js RUN --mount=type=cache,target=/app/.next/cache \ bun run build # Stage 3: Production runner FROM oven/bun:1.3.14-alpine AS runner WORKDIR /app ENV NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED=1 # Copy built assets and dependencies from builder stage COPY --from=builder /app/public ./public COPY --from=builder /app/.next ./.next COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/package.json ./package.json EXPOSE 3000 CMD ["bun", "start"] # Stage 4: Scheduled video upload worker FROM builder AS video-upload-worker COPY scripts/video-upload-crontab /etc/crontabs/root ENTRYPOINT ["crond", "-f", "-l", "2", "-L", "/dev/stdout"]