-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (33 loc) · 1.13 KB
/
Dockerfile
File metadata and controls
52 lines (33 loc) · 1.13 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
# Memtrace — multi-tenant memory layer for AI agents (Go)
# Multi-stage build for minimal image size
ARG VERSION=dev
# ---------- Build stage ----------
FROM golang:1.25-alpine AS builder
RUN apk add --no-cache gcc musl-dev
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
ARG VERSION
RUN CGO_ENABLED=1 GOOS=linux go build \
-ldflags="-s -w -X main.version=${VERSION}" \
-o memtrace ./cmd/memtrace/
# ---------- Production stage ----------
FROM alpine:3.21
ARG VERSION
RUN apk add --no-cache ca-certificates curl
# Create non-root user
RUN adduser -D -u 1000 memtrace && \
mkdir -p /app/data && \
chown -R memtrace:memtrace /app
WORKDIR /app
COPY --from=builder --chown=memtrace:memtrace /build/memtrace .
COPY --chown=memtrace:memtrace memtrace.toml .
# Persist version inside the image for diagnostics
RUN echo "${VERSION}" > VERSION && chown memtrace:memtrace VERSION
USER memtrace
VOLUME ["/app/data"]
EXPOSE 9100
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD curl -f http://127.0.0.1:9100/health || exit 1
ENTRYPOINT ["./memtrace"]