Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to cache M2 dependencies between agents? #1

Open
ejoncas opened this issue Oct 9, 2018 · 1 comment
Open

How to cache M2 dependencies between agents? #1

ejoncas opened this issue Oct 9, 2018 · 1 comment

Comments

@ejoncas
Copy link

ejoncas commented Oct 9, 2018

Hi there,

I'm trying to get the .m2/repository to be cached somehow so I don't need to download all the jars every time a new agent comes up. This process is quite lengthy and every morning where the instances gets created we have to wait 30 minutes for the first few builds to succeed.

After that, everything works well as long as the agent does not get killed.

Would it be possible to package the .m2/repository before killing the agents and upload it to S3 for the next morning? Downloading a few GB from S3 is quick, but not so much if download from our artifactory.

Or perhaps we should cache that within the docker image and push it to ECR?

Any suggestion/ideas?

@toolmantim
Copy link
Contributor

Good question! It looks like at the moment this example just covers a single agent, using a host mount:

https://github.com/buildkite/maven-example/blob/master/.buildkite/docker-compose.yml#L7-L8

To get this working across agents, there's basically those two options you mentioned. But perhaps the S3 option might be best, because it'd still work with this host mount setup?

In that case you could add a post-checkout repository hook and a pre-exit repository hook:
https://buildkite.com/docs/agent/v3/hooks#repository-hooks

Perhaps the post-checkout could have:

aws s3 sync "s3://some-bucket/.m2/$BUILDKITE_BRANCH" "$HOME/.m2"

And perhaps the pre-exit could have:

aws s3 sync "$HOME/.m2" s3://some-bucket/.m2

I'm not sure about concurrency issues with it, but perhaps something like that could be a good start?

You could definitely try using a Docker image as well, but given this example just uses the standard maven image you'd have a bit more work to do there. It's definitely possible though.

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

No branches or pull requests

2 participants