forked from microclaw/microclaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
74 lines (50 loc) · 1.69 KB
/
Dockerfile
File metadata and controls
74 lines (50 loc) · 1.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
# syntax=docker/dockerfile:1
ARG NODE_VERSION=20
ARG RUST_VERSION=1.93.1
# Stage 1: Build embedded web assets so the binary does not depend on checked-in dist files.
FROM node:${NODE_VERSION}-bookworm-slim AS web-builder
WORKDIR /usr/src/microclaw/web
COPY web/package.json web/package-lock.json ./
RUN npm ci
COPY web ./
RUN npm run build
# Stage 2: Build tools
FROM rust:${RUST_VERSION}-slim-bookworm AS chef
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
RUN cargo install cargo-chef --locked
# Stage 3: Prepare dependency recipe
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
# Stage 4: 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 . .
COPY --from=web-builder /usr/src/microclaw/web/dist ./web/dist
RUN cargo build --release --locked --bin microclaw
# Stage 5: Run
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
libsqlite3-0 \
&& rm -rf /var/lib/apt/lists/*
RUN useradd --create-home --home-dir /home/microclaw --uid 10001 --shell /usr/sbin/nologin microclaw
WORKDIR /app
COPY --from=builder /usr/src/microclaw/target/release/microclaw /usr/local/bin/
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
EXPOSE 10961
USER microclaw
ENTRYPOINT ["microclaw"]
CMD ["start"]