-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.project
More file actions
115 lines (89 loc) · 3.03 KB
/
Dockerfile.project
File metadata and controls
115 lines (89 loc) · 3.03 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
# ============================================================================
# Betterbase Project Dockerfile
#
# This is the recommended Dockerfile for deploying a Betterbase project
# created with `bb init my-project`
#
# Usage:
# 1. Copy this to your project root
# 2. Customize environment variables
# 3. Build and run:
# docker build -t my-betterbase-app .
# docker run -p 3000:3000 my-betterbase-app
# ============================================================================
# ----------------------------------------------------------------------------
# Stage 1: Base
# ----------------------------------------------------------------------------
FROM oven/bun:1.3.10-debian AS base
LABEL maintainer="Betterbase Team"
LABEL description="Betterbase Project - AI-Native Backend Platform"
WORKDIR /app
# Install system dependencies for image processing and database
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 \
curl \
&& rm -rf /var/lib/apt/lists/*
# ----------------------------------------------------------------------------
# Stage 2: Dependencies
# ----------------------------------------------------------------------------
FROM base AS deps
WORKDIR /app
# Copy package files
COPY package.json bun.lock ./
# Install dependencies
RUN bun install --frozen-lockfile
# ----------------------------------------------------------------------------
# Stage 3: Builder
# ----------------------------------------------------------------------------
FROM deps AS builder
WORKDIR /app
# Copy source code
COPY . .
# Generate database migrations
# NOTE: Ensure DATABASE_URL is set in your build args or environment
# RUN bunx drizzle-kit generate
# Build the application
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
COPY package.json bun.lock ./
# Install only production dependencies
RUN bun install --frozen-lockfile --production
# Copy built artifacts
COPY --from=builder /app/dist ./dist
# Copy necessary source files for runtime
COPY --from=builder /app/src ./src
COPY --from=builder /app/betterbase.config.* ./
COPY --from=builder /app/drizzle.config.* ./
# Create storage directory
RUN mkdir -p ./storage && chown -R appuser:appgroup ./storage
# Switch to non-root user
USER appuser
# Set environment variables
ENV NODE_ENV=production \
PORT=3000 \
HOST=0.0.0.0
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
# Start the application
CMD ["bun", "run", "start"]