Skip to content

Reduce binary size by replacing heavyweight transitive dependencies #4741

@Raudbjorn

Description

@Raudbjorn

Summary

The Supabase CLI binary is significantly larger than necessary due to several heavyweight dependencies that are used for minimal functionality. I've identified three dependencies that collectively add ~50MB to the binary while providing very little actual value.

Analysis

Dependency Transitive Deps Used For Proposed Solution
github.com/containers/common 130+ Single error constant (ErrNetworkExists) Inline stub
github.com/ethereum/go-ethereum 50+ secp256k1.S256() curve Use decred/dcrd/dcrec/secp256k1 directly
github.com/docker/compose/v2 195+ service.Pull() for image pulling Direct Docker API calls

Measurements

Testing with Go 1.22+ on Linux amd64:

Metric Before After Reduction
Binary size ~96 MB ~48 MB 50%
Indirect deps in go.sum 396 309 87 packages
Build time ~3m ~2m ~33%

Notable removed transitive dependencies

  • k8s.io/api, k8s.io/client-go (pulled in via compose)
  • github.com/aws/aws-sdk-go-v2/*
  • github.com/docker/buildx
  • github.com/moby/buildkit

Proposed PRs

I'd like to submit this as three separate PRs, ordered by risk/complexity:

  1. Replace containers/common with stub - Trivial change, ~15 lines
  2. Replace go-ethereum with lightweight stub - Small change, ~30 lines
  3. Replace docker/compose/v2 with direct Docker API - Medium change, ~50 lines

Questions for maintainers

Before I submit PRs:

  1. Is there a reason docker/compose/v2 is preferred over direct Docker API calls? Any planned features that would require it?
  2. Are there other uses of these dependencies I might have missed?
  3. Any concerns with the decred/dcrd/dcrec/secp256k1 library as a replacement for go-ethereum's curve implementation?

Happy to discuss the approach or provide more details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions