mockery: Docker Performance Slow Compared to Brew Installation

Description

I’m trying to understand more about why running mockery seems to be so much slower than when run bare metal.

I read through the issue todo and cleaned out my go mod cache.

Mockery Version

v2.46.1

Go Version

go version go1.23.1 darwin/arm64

Installation Method

  • Binary Distribution
  • Docker
  • brew
  • go install
  • Other: [specify]

Steps to Reproduce

You can repro this in the neosync repo.

  1. go clean -modcache
  2. go mod download
  3. mockery ~ 3 seconds
  4. docker run -v "$PWD":/src -w /src vektra/mockery:v2.46.1 ~1 minute

I’ve even tried mounting only what is necessary via:

docker run \
  -v "$PWD/backend":/src/backend \
  -v "$PWD/worker":/src/worker \
  -v "$PWD/internal":/src/internal \
  -v "$PWD/.mockery.yml":/src/.mockery.yml \
  -v "$PWD/go.mod":/src/go.mod \
  -v "$PWD/go.sum":/src/go.sum \
  -v "${GOPATH:-$HOME/go}/pkg/mod":/go/pkg/mod \
  -w /src \
  vektra/mockery:v2.46.01

But the docker run still takes orders of magnitude longer than the bare metal.

Am I missing some form of cache that should be mounted into the docker container?

Expected Behavior

The docker run should be near the speed of the brew installed version.

Actual Behavior

Takes much longer.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 19 (9 by maintainers)

Most upvoted comments

@nickzelei it is very likely that you forgot to go mod download inside your docker image before run mockery in my case mockery cannot find private packages (remove --quiet option to see import errors) that makes it more than 10 times slower (order of magnitude). P.S. Also do not forget to using native docker images for your host arch. I my case https://hub.docker.com/_/golang does everything right.

I don’t believe that is the case. If you see in my original example I am mounting my go mod directory, so there shouldn’t need to be any difference there.

I run a variety of tools inside of docker and the performance is negligible. The only one that I’ve seen a slowdown on is mockery.

Yes I also believe this is not the case, I run go mod download before running mockery. Something is happening only in mockery for it to be so slow in docker, the performance difference is too big compared to other things (like even the Go compiler).

@nickzelei it is very likely that you forgot to go mod download inside your docker image before run mockery

in my case mockery cannot find private packages (remove --quiet option to see import errors) that makes it more than 10 times slower (order of magnitude).

P.S. Also do not forget to using native docker images for your host arch. I my case https://hub.docker.com/_/golang does everything right.

I don’t believe that is the case. If you see in my original example I am mounting my go mod directory, so there shouldn’t need to be any difference there.

I run a variety of tools inside of docker and the performance is negligible. The only one that I’ve seen a slowdown on is mockery.