-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
121 lines (96 loc) · 3.71 KB
/
Dockerfile
File metadata and controls
121 lines (96 loc) · 3.71 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# ============================================================================
# Betterbase Monorepo Dockerfile
#
# This Dockerfile builds the entire Betterbase monorepo including:
# - @betterbase/cli
# - @betterbase/core
# - @betterbase/client
# - @betterbase/shared
#
# Usage:
# docker build -t betterbase:local .
# docker run -p 3000:3000 betterbase:local
# ============================================================================
# ----------------------------------------------------------------------------
# Stage 1: Base
# ----------------------------------------------------------------------------
FROM oven/bun:1.3.9-debian AS base
LABEL maintainer="Betterbase Team"
LABEL description="AI-Native Backend-as-a-Service Platform"
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
# For sharp image processing
vips-tools \
fftw3 \
libvips \
# For PostgreSQL client
libpq-dev \
# For build tools
make \
gcc \
g++ \
git \
&& rm -rf /var/lib/apt/lists/*
# ----------------------------------------------------------------------------
# Stage 2: Dependencies
# ----------------------------------------------------------------------------
FROM base AS deps
WORKDIR /app
# Copy package files
COPY package.json bun.lock ./
COPY turbo.json ./
# Copy workspace package.json files
COPY packages/cli/package.json packages/cli/
COPY packages/core/package.json packages/core/
COPY packages/client/package.json packages/client/
COPY apps/test-project/package.json apps/test-project/
# Install dependencies
RUN bun install --frozen-lockfile
# ----------------------------------------------------------------------------
# Stage 3: Builder
# ----------------------------------------------------------------------------
FROM deps AS builder
WORKDIR /app
# Copy all source code
COPY packages/ packages/
COPY apps/ apps/
# Build all packages using turbo
RUN bun run build
# ----------------------------------------------------------------------------
# Stage 4: Production Runner
# ----------------------------------------------------------------------------
FROM base AS runner
WORKDIR /app
# Create non-root user for security
RUN addgroup --system --gid 1001 appgroup && \
adduser --system --uid 1001 appuser
# Copy package files for production
COPY package.json bun.lock ./
COPY turbo.json ./
# Install only production dependencies
RUN bun install --frozen-lockfile --production
# Copy built packages from builder
COPY --from=builder /app/packages/core/dist ./node_modules/@betterbase/core/dist
COPY --from=builder /app/packages/cli/dist ./node_modules/@betterbase/cli/dist
COPY --from=builder /app/packages/client/dist ./node_modules/@betterbase/client/dist
COPY --from=builder /app/packages/shared/dist ./node_modules/@betterbase/shared/dist
# Copy source files for runtime (needed for dynamic imports)
COPY --from=builder /app/packages/core/src ./node_modules/@betterbase/core/src
COPY --from=builder /app/packages/cli/src ./node_modules/@betterbase/cli/src
COPY --from=builder /app/packages/client/src ./node_modules/@betterbase/client/src
COPY --from=builder /app/packages/shared/src ./node_modules/@betterbase/shared/src
# Copy package.json files to access exports
COPY packages/core/package.json ./node_modules/@betterbase/core/
COPY packages/cli/package.json ./node_modules/@betterbase/cli/
COPY packages/client/package.json ./node_modules/@betterbase/client/
COPY packages/shared/package.json ./node_modules/@betterbase/shared/
# Switch to non-root user
USER appuser
# Set environment
ENV NODE_ENV=production
ENV PORT=3000
# Expose port
EXPOSE 3000
# Default command (should be overridden by project-specific Dockerfiles)
CMD ["bun", "run", "src/index.ts"]