-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (42 loc) · 1.92 KB
/
Copy pathDockerfile
File metadata and controls
57 lines (42 loc) · 1.92 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
# ── Stage 1: Build the SvelteKit frontend ──────────────────
FROM --platform=$BUILDPLATFORM node:22-slim AS frontend-builder
WORKDIR /build/frontend
COPY cptr/frontend/package.json cptr/frontend/package-lock.json ./
RUN npm ci
COPY cptr/frontend/ ./
RUN npm run build
# ── Stage 2: Install Python dependencies & build wheel ─────
FROM --platform=$BUILDPLATFORM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS backend-builder
WORKDIR /build
COPY pyproject.toml uv.lock LICENSE README.md CHANGELOG.md ./
COPY cptr/ cptr/
# Drop the pre-built frontend into the package tree
COPY --from=frontend-builder /build/frontend/build cptr/frontend/build
# Build the wheel (includes frontend build as an artifact via hatch)
RUN uv build --wheel --out-dir /dist
# ── Stage 3: Minimal runtime image ─────────────────────────
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS runtime
LABEL org.opencontainers.image.source="https://github.com/open-webui/computer"
LABEL org.opencontainers.image.description="cptr: your computer, from anywhere"
# Runtime deps: git for git operations, tini for PID 1
RUN apt-get update && \
apt-get install -y --no-install-recommends git tini && \
rm -rf /var/lib/apt/lists/*
# Create non-root user and writable data directory
RUN useradd --create-home --shell /bin/bash cptr && \
mkdir -p /data && \
chown -R cptr:cptr /data
USER cptr
WORKDIR /home/cptr
# Install the wheel into an isolated venv
COPY --chown=cptr:cptr --from=backend-builder /dist/*.whl /tmp/
RUN uv venv /home/cptr/.venv && \
set -- /tmp/*.whl && \
uv pip install --python /home/cptr/.venv/bin/python "$1[all]" && \
rm /tmp/*.whl
ENV PATH="/home/cptr/.venv/bin:$PATH"
ENV CPTR_DATA_DIR="/data"
EXPOSE 8000
VOLUME ["/data"]
ENTRYPOINT ["tini", "--"]
CMD ["cptr", "run", "--host", "0.0.0.0", "--port", "8000", "--headless"]