apm-server icon indicating copy to clipboard operation
apm-server copied to clipboard

Document/improve Tilt setup with local version of apm-data

Open SylvainJuge opened this issue 2 years ago • 2 comments
trafficstars

When working on a local version of apm-data, as documented in the apm-data documentation, we need to make the build use a local copy of apm-data with a command similar to:

go mod edit -replace=github.com/elastic/apm-data=/path/to/your/apm-data

While this works well for a local build of apm-server, this won't work with Tilt setup which provides a very convenient end-to-end setup and makes every agent developer a "10x engineer". Because the apm-data build happens within Docker, we need to have /path/to/your/apm-data to be within a subfolder of the apm-server repository.

In order to make this work, I had to do the following:

  • within apm-server root folder, clone a copy of apm-data
  • add replace github.com/elastic/apm-data => ./apm-data to go.mod (equivalent to the go mod edit -replace above)
  • add COPY apm-data/ /src/apm-data just after COPY go.mod go.sum /src/ within packaging/docker/Dockerfile

I think we should attempt to address the following points, and fallback to document this

  • the apm-data repository is often cloned next to apm-server, not as a direct subfolder (minor, but could be annoying)
  • we need to modify the Dockerfile to make this work, otherwise the build will fail as the dockerized build can't access a folder above apm-server

SylvainJuge avatar Apr 18 '23 08:04 SylvainJuge

Also, it is not possible to use symbolic links within Dockerfile, as a consequence you can't simply symlink ~/dev/apm-server/apm-data to ~/dev/apm-data but you can still do the opposite and keep the apm-data checkout folder within ~/dev/apm-server.

SylvainJuge avatar Jul 12 '23 13:07 SylvainJuge

One option would be to change our docker image building to build the apm-server binary on the host, and copy it into the image. Then all the usual go.mod functionality would work as expected.

axw avatar Jul 13 '23 01:07 axw