-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathDockerfile.debian
More file actions
126 lines (112 loc) · 5.01 KB
/
Copy pathDockerfile.debian
File metadata and controls
126 lines (112 loc) · 5.01 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# syntax=docker/dockerfile:1.7
# ── Stage 0: Frontend build ─────────────────────────────────────
FROM node:22-alpine AS web-builder
WORKDIR /web
COPY web/package.json web/package-lock.json* ./
RUN npm ci --ignore-scripts 2>/dev/null || npm install --ignore-scripts
COPY web/ .
RUN npm run build
# Dockerfile.debian — Shell-equipped variant of the R.A.I.N. container.
#
# The default Dockerfile produces a distroless "release" image with no shell,
# which is ideal for minimal attack surface but prevents the agent from using
# shell-based tools (pwd, ls, git, curl, etc.).
#
# This variant uses debian:bookworm-slim as the runtime base and ships
# essential CLI tools so the agent can operate as a full coding assistant.
#
# Build:
# docker build -f Dockerfile.debian -t R.A.I.N.:debian .
#
# Or with docker compose:
# docker compose -f docker-compose.yml -f docker-compose.debian.yml up
# ── Stage 1: Build (match runtime glibc baseline) ───────────
FROM rust:1.94-bookworm AS builder
WORKDIR /app
ARG R.A.I.N._CARGO_FEATURES="memory-postgres"
# Install build dependencies
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# 1. Copy manifests to cache dependencies
COPY Cargo.toml Cargo.lock ./
# Include every workspace member: Cargo.lock is generated for the full workspace.
# Previously we used sed to drop `crates/robot-kit`, which made the manifest disagree
# with the lockfile and caused `cargo --locked` to fail (Cargo refused to rewrite the lock).
COPY crates/robot-kit/ crates/robot-kit/
# Create dummy targets declared in Cargo.toml so manifest parsing succeeds.
RUN mkdir -p src benches \
&& echo "fn main() {}" > src/main.rs \
&& echo "" > src/lib.rs \
&& echo "fn main() {}" > benches/agent_benchmarks.rs
RUN --mount=type=cache,id=R.A.I.N.-cargo-registry,target=/usr/local/cargo/registry,sharing=locked \
--mount=type=cache,id=R.A.I.N.-cargo-git,target=/usr/local/cargo/git,sharing=locked \
--mount=type=cache,id=R.A.I.N.-target,target=/app/target,sharing=locked \
if [ -n "$R.A.I.N._CARGO_FEATURES" ]; then \
cargo build --release --locked --features "$R.A.I.N._CARGO_FEATURES"; \
else \
cargo build --release --locked; \
fi
RUN rm -rf src benches
# 2. Copy only build-relevant source paths (avoid cache-busting on docs/tests/scripts)
COPY src/ src/
COPY benches/ benches/
COPY --from=web-builder /web/dist web/dist
RUN touch src/main.rs
RUN --mount=type=cache,id=R.A.I.N.-cargo-registry,target=/usr/local/cargo/registry,sharing=locked \
--mount=type=cache,id=R.A.I.N.-cargo-git,target=/usr/local/cargo/git,sharing=locked \
--mount=type=cache,id=R.A.I.N.-target,target=/app/target,sharing=locked \
if [ -n "$R.A.I.N._CARGO_FEATURES" ]; then \
cargo build --release --locked --features "$R.A.I.N._CARGO_FEATURES"; \
else \
cargo build --release --locked; \
fi && \
cp target/release/R.A.I.N. /app/R.A.I.N. && \
strip /app/R.A.I.N.
RUN size=$(stat -c%s /app/R.A.I.N.) && \
if [ "$size" -lt 1000000 ]; then echo "ERROR: binary too small (${size} bytes), likely dummy build artifact" && exit 1; fi
# Prepare runtime directory structure and default config inline (no extra stage)
RUN mkdir -p /R.A.I.N.-data/.R.A.I.N. /R.A.I.N.-data/workspace && \
printf '%s\n' \
'workspace_dir = "/R.A.I.N.-data/workspace"' \
'config_path = "/R.A.I.N.-data/.R.A.I.N./config.toml"' \
'api_key = ""' \
'default_provider = "openrouter"' \
'default_model = "anthropic/claude-sonnet-4-20250514"' \
'default_temperature = 0.7' \
'' \
'[gateway]' \
'port = 42617' \
'host = "[::]"' \
'allow_public_bind = true' \
> /R.A.I.N.-data/.R.A.I.N./config.toml && \
chown -R 65534:65534 /R.A.I.N.-data
# ── Stage 2: Runtime (Debian with shell) ─────────────────────
FROM debian:bookworm-slim AS runtime
# Install essential tools for agent shell operations
RUN apt-get update && apt-get install -y --no-install-recommends \
bash \
ca-certificates \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/R.A.I.N. /usr/local/bin/R.A.I.N.
COPY --from=builder /R.A.I.N.-data /R.A.I.N.-data
# Environment setup
# Ensure UTF-8 locale so CJK / multibyte input is handled correctly
ENV LANG=C.UTF-8
ENV R.A.I.N._WORKSPACE=/R.A.I.N.-data/workspace
ENV HOME=/R.A.I.N.-data
# Default provider and model are set in config.toml, not here,
# so config file edits are not silently overridden
ENV R.A.I.N._GATEWAY_PORT=42617
# API_KEY must be provided at runtime!
WORKDIR /R.A.I.N.-data
USER 65534:65534
EXPOSE 42617
HEALTHCHECK --interval=60s --timeout=10s --retries=3 --start-period=10s \
CMD ["R.A.I.N.", "status", "--format=exit-code"]
ENTRYPOINT ["R.A.I.N."]
CMD ["daemon"]