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

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -58
Dockerfile CHANGED
@@ -1,79 +1,46 @@
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"]
 
1
+ FROM oven/bun:1-slim AS build
 
 
 
 
 
2
 
3
+ ARG DEBIAN_FRONTEND=noninteractive
4
+ RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates \
5
+ && rm -rf /var/lib/apt/lists/*
 
 
6
 
7
+ WORKDIR /src
8
+ ARG LUMIVERSE_REPO=https://github.com/CloudCompile/Lumiverse.git
9
+ ARG LUMIVERSE_REF=main
10
+ RUN git clone --depth 1 --branch "${LUMIVERSE_REF}" "${LUMIVERSE_REPO}" .
11
 
12
+ # Backend deps
13
+ RUN bun install --production
 
14
 
15
+ # Frontend build
16
+ WORKDIR /src/frontend
17
+ RUN bun install && bun run build
 
 
 
 
 
18
 
19
+ # ---- runtime image ----
 
 
20
  FROM oven/bun:1-slim
21
 
22
+ ARG DEBIAN_FRONTEND=noninteractive
23
+ RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates \
24
+ && update-ca-certificates \
25
+ && rm -rf /var/lib/apt/lists/*
 
 
 
 
 
 
 
 
 
 
26
 
27
  WORKDIR /app
28
 
29
+ COPY --from=build /src/node_modules ./node_modules
30
+ COPY --from=build /src/package.json ./package.json
31
+ COPY --from=build /src/src ./src
32
+ COPY --from=build /src/frontend/dist ./frontend/dist
33
 
34
+ RUN mkdir -p /data && chown -R bun:bun /data
 
 
 
 
 
 
 
 
35
 
36
  ENV NODE_ENV=production
37
  ENV PORT=7860
38
+ ENV DATA_DIR=/data
39
  ENV FRONTEND_DIR=/app/frontend/dist
40
  ENV TRUST_ANY_ORIGIN=true
41
 
42
  EXPOSE 7860
43
+ VOLUME /data
 
 
 
44
 
45
  USER bun
46
  CMD ["bun", "run", "src/index.ts"]