Spaces:
Running
Running
File size: 973 Bytes
84ffb7a | 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 | # ---- build stage ----
FROM golang:1.26-alpine AS build
WORKDIR /src
# Cache dependencies first.
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Everything (templates, static assets, migrations) is embedded at compile
# time, so the output is a single self-contained static binary.
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/markitdown ./cmd/server
RUN mkdir /data
# ---- runtime stage: distroless, no shell, non-root, ~15MB image ----
FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=build /out/markitdown /markitdown
COPY --from=build --chown=nonroot:nonroot /data /data
# Hugging Face Spaces (Docker SDK) requires the container to listen on 7860.
# These are defaults only: HF Space secrets and `docker run --env-file .env`
# override them (local .env uses PORT=8909).
ENV PORT=7860
ENV DATABASE_URL=file:/data/markitdown.db?_busy_timeout=5000&_foreign_keys=on
EXPOSE 7860
USER nonroot:nonroot
ENTRYPOINT ["/markitdown"]
|