-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (30 loc) · 1.12 KB
/
Dockerfile
File metadata and controls
46 lines (30 loc) · 1.12 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
FROM oven/bun:alpine AS base
WORKDIR /app
COPY package.json bun.lock ./
FROM base AS dependencies
# Install all dependencies (including dev) for building.
RUN bun install --frozen-lockfile
FROM base AS prod-dependencies
# Install production-only dependencies for the release image.
RUN bun install --frozen-lockfile --production
FROM base AS builder
# Copy only the necessary files for building the application.
COPY --from=dependencies /app/node_modules ./node_modules
# Copy the rest of the application source code.
COPY . .
# Build the application (webpack bundles dist/main.js and resolves @ aliases).
RUN bun run build
FROM base AS release
WORKDIR /app
# Copy production dependencies, the webpack bundle, and proto assets.
COPY --from=prod-dependencies /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/proto ./proto
# Use a non-privileged user for security.
# Bun image already includes user "bun", so we switch to it.
USER bun
# Expose the desired port.
EXPOSE ${PORT}
# Start the application.
CMD ["bun", "run", "dist/main.js"]