-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (45 loc) 路 1.67 KB
/
Copy pathDockerfile
File metadata and controls
65 lines (45 loc) 路 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# syntax=docker/dockerfile:1.4
FROM oven/bun:1-alpine AS base
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json bun.lockb* ./
COPY prisma ./prisma/
# Use BuildKit cache mount for faster dependency installs
RUN --mount=type=cache,target=/root/.bun/install/cache \
bun install --frozen-lockfile
FROM oven/bun:1.3.2-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Build argument for Better Auth Secret (validation only during build)
ARG BETTER_AUTH_SECRET
ENV BETTER_AUTH_SECRET=$BETTER_AUTH_SECRET
RUN bunx --bun prisma generate
# Build argument for NEXT_PUBLIC_URL (baked into client bundle at build time)
ARG NEXT_PUBLIC_URL
ENV NEXT_PUBLIC_URL=$NEXT_PUBLIC_URL
ENV NEXT_TELEMETRY_DISABLED=1
# Use BuildKit cache mount for Next.js build cache
RUN --mount=type=cache,target=/app/.next/cache \
bun run build
FROM oven/bun:1.3.2-alpine AS runner
WORKDIR /app
RUN apk add --no-cache curl libc6-compat
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
# In bun images, the user is 'bun' (uid 1000)
# We'll stick with the standard bun user for simplicity
RUN mkdir .next && chown bun:bun .next
COPY --from=builder /app/package.json ./package.json
COPY --from=builder --chown=bun:bun /app/.next/standalone ./
COPY --from=builder --chown=bun:bun /app/.next/static ./.next/static
COPY --from=builder --chown=bun:bun /app/public ./public
COPY --chown=bun:bun prisma ./prisma/
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=builder /app/node_modules/@prisma/client ./node_modules/@prisma/client
USER bun
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["bun", "server.js"]