forked from microclaw/microclaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (46 loc) · 1.58 KB
/
Dockerfile
File metadata and controls
65 lines (46 loc) · 1.58 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
# syntax=docker/dockerfile:1
# Stage 1: Build tools
FROM rust:1.88-slim-bookworm AS chef
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
libsqlite3-dev \
build-essential \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/microclaw
# Install cargo-chef to improve dependency layer caching
RUN cargo install cargo-chef --locked
# Stage 2: Prepare dependency recipe
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
# Stage 3: Build
FROM chef AS builder
COPY --from=planner /usr/src/microclaw/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
# Build the binary in release mode
RUN cargo build --release --locked --bin microclaw
# Stage 4: Run
FROM debian:bookworm-slim
# Install runtime certificates and libraries
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
libsqlite3-0 \
&& rm -rf /var/lib/apt/lists/*
# Run as non-root by default
RUN useradd --create-home --home-dir /home/microclaw --uid 10001 --shell /usr/sbin/nologin microclaw
WORKDIR /app
# Copy the compiled binary
COPY --from=builder /usr/src/microclaw/target/release/microclaw /usr/local/bin/
# Copy necessary runtime directories
COPY --from=builder /usr/src/microclaw/web ./web
COPY --from=builder /usr/src/microclaw/skills ./skills
COPY --from=builder /usr/src/microclaw/scripts ./scripts
RUN mkdir -p /home/microclaw/.microclaw /app/tmp \
&& chown -R microclaw:microclaw /home/microclaw /app
ENV HOME=/home/microclaw
USER microclaw
CMD ["microclaw"]