File size: 1,441 Bytes
4b1daed
 
 
 
 
 
 
fcda515
4b1daed
 
 
7661e86
4b1daed
 
 
 
 
3d5d076
4b1daed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Go Build Stage
FROM golang:1.24-alpine AS go-builder
WORKDIR /app
RUN apk add --no-cache git ca-certificates
COPY go.mod go.sum ./
COPY go.work go.work.sum ./
COPY . .
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o /agent-server ./cmd/agent-server

# Rust Build Stage
FROM rust:1.83-alpine AS rust-builder
WORKDIR /app
RUN apk add --no-cache musl-dev
COPY rust-memory-service/Cargo.toml rust-memory-service/Cargo.lock ./
# Dummy build to cache deps
RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN mkdir benches && echo "fn main() {}" > benches/memory_ops.rs
RUN cargo build --release
RUN rm -rf src
COPY rust-memory-service/ .
RUN cargo build --release
RUN cp target/release/memory-server /memory-server

# Runtime Stage
FROM alpine:3.19
RUN apk add --no-cache ca-certificates tzdata
RUN adduser -D -g '' appuser
WORKDIR /app

# Copy binaries
COPY --from=go-builder /agent-server .
COPY --from=rust-builder /memory-server .

# Copy scripts and configs
COPY deployments/huggingface/start.sh .
COPY config.example.yaml ./config.yaml
COPY rust-memory-service/.env.example .env

RUN chmod +x start.sh && chown -R appuser:appuser /app

USER appuser
EXPOSE 7860

# Environment variables
ENV PORT=7860
ENV MEMORY_BIND_ADDR=127.0.0.1:9091
# Configure Go agent to use local memory service (needs env var mapping in config/env)
ENV MEMORY_SERVICE_HOST=127.0.0.1
ENV MEMORY_SERVICE_PORT=9091

CMD ["./start.sh"]