-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.worker
More file actions
46 lines (34 loc) · 1.09 KB
/
Dockerfile.worker
File metadata and controls
46 lines (34 loc) · 1.09 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
# MemoryOS Worker Dockerfile
FROM rust:slim-bookworm AS chef
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/* \
&& cargo install cargo-chef --locked
WORKDIR /build
# Phase 1: Generate dependency recipe
FROM chef AS planner
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
RUN cargo chef prepare --recipe-path recipe.json
# Phase 2: Build dependencies (cached)
FROM chef AS builder
COPY --from=planner /build/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
# Phase 3: Build application
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
RUN cargo build --release --bin memoryos-worker
# Runtime image
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -r memoryos && useradd -r -g memoryos -d /app -s /sbin/nologin memoryos
WORKDIR /app
COPY --from=builder /build/target/release/memoryos-worker /app/
RUN chown -R memoryos:memoryos /app
USER memoryos
CMD ["./memoryos-worker"]