Skip to content

Multi-platform Docker builds - #1129

Closed
kokes wants to merge 1 commit into
sourcegraph:mainfrom
kokes:kokes/universal-oci
Closed

Multi-platform Docker builds#1129
kokes wants to merge 1 commit into
sourcegraph:mainfrom
kokes:kokes/universal-oci

Conversation

@kokes

@kokes kokes commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

I noticed the built image is only for platform amd64, not the somewhat widely used arm64. The sad reality here is that there look to be CGO bits, so the cross platform build is kinda slow (20 minutes as opposed to 3 minutes currently).

Not sure if we can adjust caching to speed this up, I just tried a hot run (~30 seconds) and then changed some code and was back to 20 minutes.

If this performance (albeit only on pushes to main) is unreasonably slow for you, I fully understand if you close this. Just wanted to throw it out there for your consideration.

@keegancsmith keegancsmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no CGO bits, in fact in our Dockerfile we set CGO_ENABLED=0.

I think what you are seeing is the building of universal-ctags we ship with the image. Do you have any ideas on how we could maybe share that across builds? That should change very rarely (hasn't changed in years).

Before I approve I'm interested in if you actually use ARM + zoekt or intend to? Interesting in know more :)

@kokes

kokes commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@keegancsmith Hey Keegan, happy to elaborate

  • you're absolutely right (c), confused the ctags build for cgo, skimmed the logs way too fast
  • we can't quite share it between builds as these are native binaries, but when testing this, I realised that the slow part is not actually the C stuff (it gets cached in a docker layer pretty quickly), it's the Go builds (natively ~120 seconds, QEMU virtualized ~900 seconds) - so we could leverage Go's cross-platform builds and cache the ctags stuff, achieving pretty good performance
  • while on the subject of ctags - I actually ran into prebuilt binaries for universal ctags (statically built, so no jansson etc.) - https://github.com/universal-ctags/ctags-nightly-build/releases - maintained by the same person as the source maint - so we could leverage that for both platforms and save ourselves both the builds and the build infra (g++ etc.) while we're at it?
  • as for our use - we leverage aarch64 both on our laptops (M-series Macs) as well as kubernetes clusters (AWS Graviton) for perf/$ reasons as well as consistency between local/prod environments - hence this need for arm64 builds
    • we're not quite set on whether we want to use the zoekt server through this docker image or if we'll extract the relevant binaries from this OCI image during our docker builds

I'll send a followup PR that incorporates the ideas above and solves the multi-platform issue in a much cleaner way.

Edit: looking over the code, i'm realising now that the very new Amp Orbs setup already uses the prebuilt ctags approach, so we might want to consolidate this across the repo maybe?

@kokes

kokes commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1130, closing.

@kokes kokes closed this Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants