|
12 | 12 | # about a gigabyte of a single object in memory, is OOM-killed under the 512Mi |
13 | 13 | # limit the S3 deployment gets from its resources preset, and the client sees |
14 | 14 | # the response cut off tens of megabytes in: |
15 | | -# https://github.com/cozystack/cozystack/issues/3782. Upstream carries the same |
16 | | -# defect on master, tracked as seaweedfs/seaweedfs#11672; drop the patch on the |
17 | | -# first release that carries a fix. |
18 | | - |
19 | | -# Keep in step with the chart appVersion pulled by `make update`, and with the |
20 | | -# base image below: the patched binary replaces this version's, so building it |
21 | | -# from another tag would run one version's weed against the rest of another's |
22 | | -# image. |
| 15 | +# https://github.com/cozystack/cozystack/issues/3782. Upstream fixed it in |
| 16 | +# seaweedfs/seaweedfs#11674 after 4.48; drop the patch on the first vendored |
| 17 | +# release that carries it. |
| 18 | +# |
| 19 | +# `make update` re-pins VERSION from the vendored chart, SOURCE_SHA256 from the |
| 20 | +# source archive of that tag, UPSTREAM_DIGEST from the upstream image of that |
| 21 | +# tag and the builder from upstream's docker/Dockerfile.go_build, and checks |
| 22 | +# that the patches still apply. |
23 | 23 | ARG VERSION=4.45 |
| 24 | +ARG SOURCE_SHA256=800a91693e2a4e974ef0e2a157b6a04eff9f4df507303b1cff31b0601081fc30 |
| 25 | +ARG UPSTREAM_DIGEST=sha256:fc9f76fa993ad69966ffeb2f65d0318fcae39c6f8e20cf68ef7b3a5cb97769e5 |
24 | 26 |
|
25 | | -FROM --platform=$BUILDPLATFORM golang:1.26@sha256:eb36c1664dd974cde625f736e02c204383deebe03977365caaec5bf49f794348 AS builder |
| 27 | +# The Go toolchain of upstream's builder (docker/Dockerfile.go_build), which |
| 28 | +# compiles the upstream weed. |
| 29 | +FROM --platform=$BUILDPLATFORM golang:1.26-alpine@sha256:3082400e369fa24d5fc60bca20edab3f6d604e0c5a690ec66b295eff4dd87ade AS builder |
26 | 30 | ARG GOPROXY |
27 | 31 | ARG VERSION |
28 | | -ARG TARGETOS |
29 | | -ARG TARGETARCH |
| 32 | +ARG SOURCE_SHA256 |
| 33 | + |
| 34 | +RUN apk add --no-cache git curl |
30 | 35 |
|
31 | | -WORKDIR /workspace |
| 36 | +WORKDIR /go/src/github.com/seaweedfs/seaweedfs |
32 | 37 |
|
33 | | -RUN curl -sSL https://github.com/seaweedfs/seaweedfs/archive/refs/tags/${VERSION}.tar.gz | tar -xzf- --strip=1 |
| 38 | +RUN curl -fsSL -o /tmp/source.tar.gz https://github.com/seaweedfs/seaweedfs/archive/refs/tags/${VERSION}.tar.gz && \ |
| 39 | + echo "${SOURCE_SHA256} /tmp/source.tar.gz" | sha256sum -c - && \ |
| 40 | + tar -xzf /tmp/source.tar.gz --strip-components=1 && rm /tmp/source.tar.gz |
34 | 41 |
|
35 | 42 | COPY patches /patches |
36 | 43 | RUN git apply /patches/*.diff |
37 | 44 |
|
| 45 | +ENV CGO_ENABLED=0 |
| 46 | + |
38 | 47 | # go build never compiles a _test.go, so nothing else runs the tests the |
39 | 48 | # patches carry. The list is read into a variable first: a for loop drops the |
40 | 49 | # exit status of a command substitution, so a patch git cannot read would leave |
41 | 50 | # the list empty and the step green. |
42 | 51 | RUN files=$(git apply --numstat /patches/*.diff) || exit 1; \ |
43 | 52 | for dir in $(printf '%s\n' "$files" | cut -f3 | grep '\.go$' | xargs -r -n1 dirname | sort -u); do \ |
44 | | - go test -race "./$dir" || exit 1; \ |
| 53 | + go test "./$dir" || exit 1; \ |
45 | 54 | done |
46 | 55 |
|
47 | | -RUN cd weed && GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -o /workspace/weed-bin . |
| 56 | +# Declared after the tests so they run once on the build platform rather than |
| 57 | +# once per target platform. |
| 58 | +ARG TARGETOS |
| 59 | +ARG TARGETARCH |
| 60 | + |
| 61 | +# The source archive carries no git history for upstream's `git rev-parse`, so |
| 62 | +# the commit field of `weed version` names this build instead. |
| 63 | +RUN cd weed && GOOS=$TARGETOS GOARCH=$TARGETARCH go build \ |
| 64 | + -ldflags "-X github.com/seaweedfs/seaweedfs/weed/util/version.COMMIT=cozystack-patched" \ |
| 65 | + -o /out/weed . |
48 | 66 |
|
49 | | -FROM chrislusf/seaweedfs:${VERSION}@sha256:fc9f76fa993ad69966ffeb2f65d0318fcae39c6f8e20cf68ef7b3a5cb97769e5 |
50 | | -COPY --from=builder /workspace/weed-bin /usr/bin/weed |
| 67 | +FROM chrislusf/seaweedfs:${VERSION}@${UPSTREAM_DIGEST} |
| 68 | +COPY --from=builder /out/weed /usr/bin/weed |
0 commit comments