Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (61 loc) · 2.87 KB
/
Copy pathDockerfile
File metadata and controls
77 lines (61 loc) · 2.87 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
# Stage 1: Build the application
FROM oven/bun:1.4.4 AS builder
WORKDIR /app
ARG APP_VERSION=dev
ARG TARGETPLATFORM
ENV APP_VERSION=${APP_VERSION}
# Copy root package files
COPY package.json bun.lock ./
# Copy package-specific package.json files
COPY packages/backend/package.json ./packages/backend/
COPY packages/cli/package.json ./packages/cli/
COPY packages/frontend/package.json ./packages/frontend/
COPY packages/shared/package.json ./packages/shared/
# Copy scripts needed by the prepare hook
COPY scripts/ ./scripts/
# Install dependencies
RUN bun install --frozen-lockfile --ignore-scripts --linker hoisted
# Copy the rest of the source code
COPY . .
# Bun's compiled workspace resolution expects dependencies at the workspace path.
RUN mkdir -p packages/shared/node_modules \
&& ln -s /app/node_modules/zod packages/shared/node_modules/zod
# Build the frontend and compile everything into a single self-contained binary.
# Frontend assets (HTML, JS, CSS, images) and migration SQL files are all embedded
# inside the binary via `bun build --compile` — no runtime file copies needed.
# Use TARGETPLATFORM to select the correct build target (e.g., linux/amd64, linux/arm64).
# BuildKit sets this automatically; deploy-staging.ts also passes it explicitly as --build-arg.
RUN case "${TARGETPLATFORM}" in \
linux/arm64) bun run compile:linux-arm64 && mv plexus-linux-arm64 plexus ;; \
linux/amd64) bun run compile:linux-amd64 && mv plexus-linux-amd64 plexus ;; \
*) echo "Unsupported platform: ${TARGETPLATFORM}" && exit 1 ;; \
esac
# Stage 2: Production image with local MCP runtime tooling.
# Includes Bun/bunx and uv/uvx so Plexus can manage local HTTP MCP servers.
FROM oven/bun:1.4.4
WORKDIR /app
# Install local MCP runtime tooling (uv/uvx for Python MCP servers).
# IMPORTANT: This RUN must stay ABOVE any ARG/ENV for APP_VERSION. BuildKit
# invalidates the cache of a RUN instruction whenever an in-scope ARG changes
# value — even if the ARG is not referenced in that RUN. Since APP_VERSION
# changes on every release, declaring it before this layer would re-run the
# full apt-get + uv install on every build. Keeping it after lets this layer
# cache stably across all version tags.
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl git python3 build-essential \
&& curl -LsSf https://astral.sh/uv/install.sh | sh \
&& ln -sf /root/.local/bin/uv /usr/local/bin/uv \
&& ln -sf /root/.local/bin/uvx /usr/local/bin/uvx \
&& rm -rf /var/lib/apt/lists/*
# Copy the compiled binary from the builder stage.
COPY --from=builder /app/plexus ./plexus
EXPOSE 4000
# Environment variables
ENV PORT=4000
ENV LOG_LEVEL=info
ENV DATA_DIR=/app/data
ENV DATABASE_URL=sqlite:///app/data/plexus.db
ARG APP_VERSION=dev
ENV APP_VERSION=${APP_VERSION}
# ADMIN_KEY must be provided at runtime (no default for security)
CMD ["./plexus"]