forked from Pasta-Devs/Marinara-Engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
102 lines (83 loc) · 3.69 KB
/
Copy pathDockerfile
File metadata and controls
102 lines (83 loc) · 3.69 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
# ──────────────────────────────────────────────
# Marinara Engine — Multi-stage Docker Build
# ──────────────────────────────────────────────
# ── Stage 1: Build ──
FROM node:24-slim AS builder
ARG BUILD_COMMIT
WORKDIR /app
# Copy workspace config first (layer cache for deps)
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
COPY packages/shared/package.json packages/shared/
COPY packages/server/package.json packages/server/
COPY packages/client/package.json packages/client/
# Enable corepack — version is read from the packageManager field in package.json
RUN corepack enable && corepack install
# Install all dependencies (including dev for building)
# Use cache mount to avoid storing pnpm store in image
RUN --mount=type=cache,target=/app/.pnpm-store \
pnpm install --frozen-lockfile
# Copy source code
COPY tsconfig.base.json ./
COPY packages/shared/ packages/shared/
COPY packages/server/ packages/server/
COPY packages/client/ packages/client/
# Build everything: shared → server + client in parallel
# Increase heap for ARM64 emulation (QEMU) where memory pressure is high
ENV NODE_OPTIONS="--max-old-space-size=4096"
RUN pnpm build
# Bake the git commit into build-meta.json so the app can display it.
# __dirname in build-info.js resolves to packages/server/dist/config/
RUN if [ -n "$BUILD_COMMIT" ]; then \
echo "{\"commit\":\"$BUILD_COMMIT\"}" > packages/server/dist/config/build-meta.json; \
fi
# ── Stage 2: Production ──
FROM node:24-slim AS production
WORKDIR /app
# llama-server dynamically links these at runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
libssl3 \
libgomp1 \
libvulkan1 \
python3 \
python3-venv \
&& rm -rf /var/lib/apt/lists/*
# Copy workspace config
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
COPY packages/shared/package.json packages/shared/
COPY packages/server/package.json packages/server/
COPY packages/client/package.json packages/client/
# Enable corepack — version is read from the packageManager field in package.json
RUN corepack enable && corepack install
# Install production deps only
# Use cache mount to avoid storing pnpm store in image
# Strip onnxruntime-web WASM blobs, uses onnxruntime-node (native)
RUN --mount=type=cache,target=/app/.pnpm-store \
pnpm install --frozen-lockfile --prod && \
rm -rf /app/node_modules/.pnpm/onnxruntime-web@*
# Copy built artifacts from builder
COPY --from=builder /app/packages/shared/dist packages/shared/dist
COPY --from=builder /app/packages/server/dist packages/server/dist
COPY --from=builder /app/packages/client/dist packages/client/dist
COPY scripts/docker-entrypoint.mjs /usr/local/bin/marinara-docker-entrypoint.mjs
COPY scripts/install-backgroundremover.mjs scripts/install-backgroundremover.mjs
# Ensure /app/data exists for runtime use (file storage, uploads, generated assets)
RUN mkdir -p /app/data && \
chown node:node /app/data
# Point the server at /app/data regardless of working directory
ENV DATA_DIR=/app/data
ENV FILE_STORAGE_DIR=/app/data/storage
# File-native storage + user uploads live in /app/data at runtime.
# Mount a volume here for persistence.
VOLUME /app/data
# Default port
ENV PORT=7860
ENV HOST=0.0.0.0
ENV NODE_ENV=production
ENV MARINARA_DOCKER=true
ENV MARINARA_DOCKER_USER=node
ENV MARINARA_DOCKER_GROUP=node
EXPOSE 7860
USER root
# Run the server (serves both API and client SPA)
ENTRYPOINT ["node", "/usr/local/bin/marinara-docker-entrypoint.mjs"]
CMD ["node", "packages/server/dist/index.js"]