-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
86 lines (66 loc) · 2.2 KB
/
Copy pathDockerfile
File metadata and controls
86 lines (66 loc) · 2.2 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
# Simplified approach - just ensure we copy everything needed
FROM ubuntu:24.04 AS deps
# Install build dependencies
RUN apt-get update && apt-get install -y \
python3 \
make \
g++ \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Install Bun manually on Ubuntu
RUN apt-get update && apt-get install -y curl unzip && \
curl -fsSL https://bun.sh/install | bash && \
ln -s /root/.bun/bin/bun /usr/local/bin/bun
WORKDIR /app
# Copy workspace files
COPY package.json .
COPY bun.lock .
# Install dependencies
RUN bun install --frozen-lockfile
RUN rm -f bun.lock
FROM ubuntu:24.04 AS builder
WORKDIR /app
# Copy everything from deps stage
COPY --from=deps /app/ ./
# Copy source code
COPY . .
# Copy Bun installation to a location accessible by all users
COPY --from=deps /root/.bun /usr/local/bun
RUN ln -s /usr/local/bun/bin/bun /usr/local/bin/bun
RUN chmod -R 755 /usr/local/bun && chmod +x /usr/local/bin/bun
# Build the application - don't bundle native modules
RUN bun build src/index.ts --outdir ./dist --target bun --external @xmtp/node-bindings --external postgres
FROM ubuntu:24.04 AS runner
WORKDIR /app
# Install runtime dependencies and debugging tools as root
RUN apt-get update && apt-get install -y \
bash \
iputils-ping \
dnsutils \
curl \
libc6 \
libgcc-s1 \
libstdc++6 \
&& rm -rf /var/lib/apt/lists/*
ENV NODE_ENV=production
# Copy the built application
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/bun.lock ./bun.lock
# IMPORTANT: Copy the full node_modules to ensure native bindings are available
COPY --from=builder /app/node_modules ./node_modules
# Copy Bun installation to a location accessible by all users
COPY --from=builder /usr/local/bun /usr/local/bun
RUN ln -s /usr/local/bun/bin/bun /usr/local/bin/bun
RUN chmod -R 755 /usr/local/bun && chmod +x /usr/local/bin/bun
# # Copy additional files
# COPY --from=builder /app/entrypoint.sh ./
# COPY --from=builder /app/.env.production ./
# Make script executable
# RUN chmod +x ./entrypoint.sh
# MOUNT XMTP DB PATH
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
# ENTRYPOINT ["./entrypoint.sh"]
CMD ["bun", "run", "start"]