klesh opened a new pull request, #9291: URL: https://github.com/apache/devlake/pull/9291
### Summary Stacked on #9288 (base branch `feat/single-binary`), because it needs the generated plugin registry to have anything to link in. `make build` now means `build-server`: the framework, the API and every plugin in `plugins/all` link into a single `bin/lake`. The image build stops producing `.so` files entirely. **How the image builds now** | Stage | Before | After | |---|---|---| | `build` | `make all` → `build-plugin` (47 × `go build -buildmode=plugin`) then `build-server` | `make all` → `build-server` → one `go build ./server` | | payload | `/app/bin/lake` + `/app/bin/plugins/*/*.so` | `/app/bin/lake` | | runtime copy | `COPY --from=build /app/bin /app/bin` | `COPY --from=build /app/bin/lake /app/bin/lake` | The runtime stage gets an empty `/app/bin/plugins` as the sideload mount point. It is created as root, before the `chgrp -R 0 /app`, because the stage otherwise runs as the `devlake` user and could not create it. **Measured** ``` core-only, stripped 58.4 MB full binary, stripped 106.6 MB (plugins add 48.2 MB) full binary, unstripped 148.9 MB ``` So the Go payload goes from ~2.75 GB to ~107 MB. Against the current `apache/devlake:main_*` image (3.06 GB, of which the `:base` stage is 306 MB) the image should land around **~415 MB**, roughly 7× smaller. The base stage is now the largest single piece. **Also in here** - `build-server.sh` gains `-trimpath` and `-s -w`. A `DEVLAKE_DEBUG=1` build keeps the symbols so `make debug` still works. - Dropped `COPY --from=build /go/bin /usr/bin`. `mockery` and `swag` are build tools; nothing at runtime uses them. - `dev`, `godev` and `build` no longer build plugins. `build-plugin` stays for sideload and core-only builds. - `plugins-registry` clears `GOOS`/`GOARCH`. `backend/Dockerfile` exports them to cross-compile the server, and `go run` would otherwise build the generator for the target platform and fail with `exec format error` on an amd64 host building the arm64 image. `GO_PLUGINS` keeps working: it reaches the registry generator, so it now chooses which plugins are **compiled in** rather than which `.so` files are built. `GO_PLUGINS=none` yields a core-only binary. ### Does this close any open issues? Part of #9276. ### Other Information Verified locally: ``` VERSION=test@local scripts/build-server.sh # bin/lake, 102 MB, stripped, no bin/plugins created go build -tags devlake_external_plugins # 58.4 MB, core only GOOS=linux GOARCH=arm64 make plugins-registry # no "exec format error" ``` The arm64 image build itself is not exercised on PRs (`.github/workflows/build.yml` runs on `main` and tags), so that path needs a careful look at merge time. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
