-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (51 loc) · 1.52 KB
/
Copy pathDockerfile
File metadata and controls
70 lines (51 loc) · 1.52 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
65
66
67
68
69
70
# Multi-stage build for Bun app with TypeScript
# Stage 1: Dependencies
FROM oven/bun:latest AS deps
WORKDIR /app
# Copy package files
COPY package.json bun.lockb* ./
# Install dependencies
RUN bun install --frozen-lockfile
# Stage 2: Build and test
FROM oven/bun:latest AS test
WORKDIR /app
# Copy dependencies from deps stage
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/bun.lockb ./
# Copy package and source code
COPY package.json ./
COPY src ./src
# Run tests to verify build
RUN bun test
# Stage 3: Development image
FROM oven/bun:latest AS development
WORKDIR /app
# Copy dependencies from deps stage
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/bun.lockb ./
# Copy package and source code
COPY package.json ./
COPY src ./src
# Expose port
EXPOSE 3000
# Start server with watch mode
CMD ["bun", "--watch", "run", "src/admin-ui/cli.ts"]
# Stage 4: Production image
FROM oven/bun:latest AS production
WORKDIR /app
# Copy dependencies from deps stage
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/bun.lockb ./
# Copy package and source code
COPY package.json ./
COPY src ./src
# Create non-root user for security
RUN useradd -m -u 1001 bunapp
USER bunapp
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD bun -e "const res = await fetch('http://localhost:3000/health'); if (res.status !== 200) throw new Error(res.status);"
# Expose port
EXPOSE 3000
# Start server
CMD ["bun", "run", "src/admin-ui/cli.ts"]