Ctrl K
ComunidadGuías…

Dockerfile

Rama main · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
# Build stage — run on the build host's native arch for speed, cross-compile for target
FROM --platform=$BUILDPLATFORM golang:1.27.3-alpine3.24 AS builder

ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT

WORKDIR /app

# Download dependencies first for better layer caching
COPY go.mod go.sum ./
RUN go mod download

# Copy source and cross-compile for the target platform
COPY . .
ARG VERSION=dev
ARG COMMIT=none
ARG DATE=unknown
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${TARGETVARIANT#v} go build \
	-ldflags="-s -w -X github.com/enterpilot/gomodel/internal/version.Version=${VERSION} -X github.com/enterpilot/gomodel/internal/version.Commit=${COMMIT} -X github.com/enterpilot/gomodel/internal/version.Date=${DATE}" \
	-o /gomodel ./cmd/gomodel

# Create .cache and data directories for runtime (with placeholder for COPY)
RUN mkdir -p /app/.cache /app/data && touch /app/.cache/.keep /app/data/.keep

# Runtime stage
FROM gcr.io/distroless/static-debian12:nonroot

# Ownership proof for the MCP Registry; must match the name in server.json
LABEL io.modelcontextprotocol.server.name="io.github.ENTERPILOT/gomodel"

# Copy binary and runtime config
COPY --from=builder /gomodel /gomodel
COPY --from=builder /app/config/*.yaml /app/config/

# Create writable .cache and data directories for nonroot user (UID=65532)
COPY --from=builder --chown=65532:65532 /app/.cache /app/.cache
COPY --from=builder --chown=65532:65532 /app/data /app/data

WORKDIR /app

EXPOSE 8080

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 CMD ["/gomodel", "--health"]

ENTRYPOINT ["/gomodel"]