22# MindX Docker Image — Alpine (musl) base, matches musl-cross compiled binary
33# =============================================================================
44# Build:
5- # 1. Pre-compile: CGO_ENABLED=1 CC=x86_64-linux-musl-gcc GOOS=linux \
6- # GOARCH=amd64 go build -o runtime/bin/mindx .
7- # 2. docker compose build
5+ # Local: make docker → pre-compile + docker compose build
6+ # CI: build job → cross-compile artifacts → docker build-push
87#
9- # Version injection (optional):
10- # docker build --build-arg VERSION=v2.2.0 --build-arg COMMIT=abc1234 .
8+ # Binary source: runtime/bin/mindx (pre-compiled, NOT built inside Docker)
119# =============================================================================
1210
13- # ---- Build stage (optional: compile from source) ----
14- FROM golang:1.26-alpine AS builder
15-
16- WORKDIR /src
17- COPY go.mod go.sum ./
18- RUN go mod download
19- COPY . .
20-
21- ARG VERSION=dev
22- ARG COMMIT=unknown
23- ARG BUILD_TIME=unknown
24-
25- RUN CGO_ENABLED=0 go build \
26- -trimpath \
27- -ldflags="-s -w \
28- -X github.com/DotNetAge/mindx/cmd.Version=${VERSION#v} \
29- -X github.com/DotNetAge/mindx/cmd.Commit=${COMMIT} \
30- -X github.com/DotNetAge/mindx/cmd.BuildTime=${BUILD_TIME}" \
31- -o /mindx .
32-
33- # ---- Runtime stage ----
11+ # ---- Runtime image ----
3412FROM alpine:3.19
3513
3614LABEL maintainer="DotNetAge <ray@dotnetage.com>"
@@ -57,19 +35,20 @@ RUN adduser -D -s /bin/bash mindx
5735USER mindx
5836WORKDIR /home/mindx
5937
60- # Deploy runtime environment + binary (prefer pre-built, fallback to builder)
38+ # Deploy runtime environment + pre-built binary
6139COPY --chown=mindx:mindx runtime/ /home/mindx/.mindx/
62- COPY --from=builder --chown=mindx:mindx /mindx /home/mindx/.mindx/bin/mindx
6340
6441# Ensure binary is executable
65- RUN chmod +x /home/mindx/.mindx/bin/mindx 2>/dev/null || true
42+ RUN [ -f /home/mindx/.mindx/bin/mindx ] && chmod +x /home/mindx/.mindx/bin/mindx || true
6643
6744# Runtime directories
6845RUN mkdir -p /home/mindx/.mindx/logs \
6946 /home/mindx/.mindx/sessions
7047
7148# Python venv
7249RUN python3 -m venv /home/mindx/.mindx/.venv
50+ RUN /home/mindx/.mindx/.venv/bin/pip freeze > /home/mindx/.mindx/requirements.txt
51+ RUN /home/mindx/.mindx/.venv/bin/pip install -r /home/mindx/.mindx/requirements.txt
7352
7453# Fix venv path in mindx.json for container
7554RUN sed -i 's|/Users/ray/.mindx/.venv|/home/mindx/.mindx/.venv|g' \
0 commit comments