-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (31 loc) · 1.11 KB
/
Dockerfile
File metadata and controls
44 lines (31 loc) · 1.11 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
# Use a lightweight base image with Bun
ARG BUN_VERSION=1.2.11
FROM oven/bun:${BUN_VERSION}-alpine AS deps
WORKDIR /app
# Only copy lockfile and manifest to leverage Docker layer caching
COPY bun.lock package.json ./
# Install only dependencies
RUN bun install --frozen-lockfile --ignore-scripts
# Build stage
FROM oven/bun:${BUN_VERSION}-alpine AS builder
WORKDIR /app
# Copy dependencies from deps stage
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/package.json ./package.json
COPY --from=deps /app/bun.lock ./bun.lock
# Copy the rest of the app and build
COPY . .
RUN bun run build
# Final slim image to serve the app
FROM oven/bun:${BUN_VERSION}-alpine AS runner
WORKDIR /app
# Optionally use a non-root user (ensure your app supports it)
USER bun
# Copy built output and any runtime dependencies
COPY --from=builder /app/.output ./.output
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/bun.lock ./bun.lock
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/drizzle ./drizzle
EXPOSE 3000/tcp
CMD ["bun", "run", ".output/server/index.mjs"]