-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (40 loc) · 1.4 KB
/
Dockerfile
File metadata and controls
54 lines (40 loc) · 1.4 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
# MemoryOS Gateway Dockerfile
FROM rust:slim-bookworm AS chef
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& cargo install cargo-chef --locked
WORKDIR /build
# Phase 1: Generate dependency recipe (changes only when Cargo.toml/lock change)
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 unless recipe changes)
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 (only recompiles your code)
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
RUN cargo build --release --bin memoryos-gateway
# Runtime image
FROM debian:bookworm-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user (DevOps red line: never run as root in containers)
RUN groupadd -r memoryos && useradd -r -g memoryos -d /app -s /sbin/nologin memoryos
WORKDIR /app
COPY --from=builder /build/target/release/memoryos-gateway /app/
RUN chown -R memoryos:memoryos /app
USER memoryos
EXPOSE 8080
HEALTHCHECK --interval=15s --timeout=5s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
CMD ["./memoryos-gateway"]