CJHauser commited on
Commit
d937b37
·
verified ·
1 Parent(s): e8d914e

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +79 -0
Dockerfile ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # =============================================================================
2
+ # Lumiverse Backend — Multi-stage Docker Build
3
+ # =============================================================================
4
+ # Base: Debian slim (not Alpine — LanceDB requires glibc, no musl bindings)
5
+ # Supports: linux/amd64, linux/arm64
6
+ # =============================================================================
7
+
8
+ # ---------------------------------------------------------------------------
9
+ # Stage 1: Build frontend (Vite + TypeScript)
10
+ # ---------------------------------------------------------------------------
11
+ FROM oven/bun:1-slim AS frontend-build
12
+ WORKDIR /app/frontend
13
+
14
+ # Install dependencies first (cache layer)
15
+ COPY frontend/package.json frontend/bun.lock* ./
16
+ RUN bun install --frozen-lockfile 2>/dev/null || bun install
17
+
18
+ # Build frontend
19
+ COPY frontend/ ./
20
+ RUN bun run build
21
+
22
+ # ---------------------------------------------------------------------------
23
+ # Stage 2: Install backend production dependencies
24
+ # ---------------------------------------------------------------------------
25
+ FROM oven/bun:1-slim AS backend-deps
26
+ WORKDIR /app
27
+
28
+ COPY package.json bun.lock* ./
29
+ RUN bun install --production --frozen-lockfile 2>/dev/null || bun install --production
30
+
31
+ # ---------------------------------------------------------------------------
32
+ # Stage 3: Runtime
33
+ # ---------------------------------------------------------------------------
34
+ FROM oven/bun:1-slim
35
+
36
+ # Keep TLS root CAs fresh (helps with provider cert issues)
37
+ ARG CA_REFRESH=unset
38
+ RUN echo "ca-refresh: ${CA_REFRESH}" \
39
+ && apt-get update \
40
+ && apt-get install --no-install-recommends --no-install-suggests -y \
41
+ git \
42
+ ca-certificates \
43
+ && update-ca-certificates \
44
+ && apt-get clean \
45
+ && rm -rf /var/lib/apt/lists/*
46
+
47
+ LABEL org.opencontainers.image.title="Lumiverse"
48
+ LABEL org.opencontainers.image.description="AI chat application server"
49
+ LABEL org.opencontainers.image.source="https://github.com/CloudCompile/Lumiverse"
50
+
51
+ WORKDIR /app
52
+
53
+ # Backend dependencies
54
+ COPY --from=backend-deps /app/node_modules ./node_modules
55
+
56
+ # Built frontend
57
+ COPY --from=frontend-build /app/frontend/dist ./frontend/dist
58
+
59
+ # Backend source
60
+ COPY package.json ./
61
+ COPY src/ ./src/
62
+
63
+ # Persistent data dir
64
+ RUN mkdir -p /app/data && chown -R bun:bun /app/data
65
+
66
+ ENV NODE_ENV=production
67
+ ENV PORT=7860
68
+ ENV DATA_DIR=/app/data
69
+ ENV FRONTEND_DIR=/app/frontend/dist
70
+ ENV TRUST_ANY_ORIGIN=true
71
+
72
+ EXPOSE 7860
73
+ VOLUME /app/data
74
+
75
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
76
+ CMD bun -e "fetch('http://localhost:' + (Bun.env.PORT || '7860')).then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"
77
+
78
+ USER bun
79
+ CMD ["bun", "run", "src/index.ts"]