-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.cpu
More file actions
52 lines (40 loc) · 1.52 KB
/
Copy pathDockerfile.cpu
File metadata and controls
52 lines (40 loc) · 1.52 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
# Dockerfile.cpu
# CPU-only build - smallest, fastest, runs everywhere
#
# Build:
# docker build -f Dockerfile.cpu -t longbow:cpu .
#
# Build with io_uring (Linux 5.1+):
# docker build -f Dockerfile.cpu -t longbow:cpu-iouring . --build-arg ENABLE_IOURING=true
# -------------------------------------------------------------------
# Stage 1: Build
# -------------------------------------------------------------------
FROM golang:1.26.3-bookworm AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG ENABLE_IOURING=false
ARG BUILD_TAGS=linux
ENV GOAMD64=v3
# Build longbow, longbow-cli, and bench-tool
RUN if [ "$ENABLE_IOURING" = "true" ]; then \
CGO_ENABLED=1 go build -tags="${BUILD_TAGS},iouring" -ldflags="-s -w -checklinkname=0" -o longbow ./cmd/longbow; \
else \
CGO_ENABLED=0 go build -tags=${BUILD_TAGS} -ldflags="-s -w" -o longbow ./cmd/longbow; \
fi
RUN CGO_ENABLED=0 go build -tags=${BUILD_TAGS} -ldflags="-s -w" -o longbow-cli ./cmd/cli
RUN CGO_ENABLED=0 go build -tags=${BUILD_TAGS} -ldflags="-s -w" -o bench-tool ./cmd/bench-tool
# -------------------------------------------------------------------
# Stage 2: Minimal runtime
# -------------------------------------------------------------------
FROM scratch
COPY --from=builder /app/longbow /longbow
COPY --from=builder /app/longbow-cli /longbow-cli
COPY --from=builder /app/bench-tool /bench-tool
VOLUME /data
ENV LONGBOW_GPU_ENABLED=false
ENV LONGBOW_STORAGE_USE_IOURING=false
ENV GOGC=75
EXPOSE 3000 3001 9090
ENTRYPOINT ["/longbow"]