Package cache for hex.pm?

,

We have had some problems in the past where hex.pm is down or even just a specific package isn’t working for some reason or another. These problems are usually dealt with within a day but while it is happening we can’t deploy anything.

I was looking at mini_repo but it seems I either have to whitelist every package I use or it will download over 53k versions of packages to our datastore. That’s really excessive. To even demo it on my laptop to see if it will work I’ll have to mirror the entirety of hex.pm.

Other languages have package proxies that just download on demand and store the package artifacts in case you ever need them again, which is perfect for our use case. I’m having trouble googling for alternatives because there are thousands of tutorials on building a cache in elixir.

What do people use for this? Maybe there is a more generic solution that others use?

1 Like

There are a few mirrors you can use: https://hex.pm/docs/mirrors

2 Likes

I mean I can change our gitlab CI to do something like mix deps.get || env HEX_MIRROR=foobar mix deps.get. That’s better than nothing I guess. I wish there were a better solution.

1 Like

You can cache ~/.hex/packages/hexpm for this.

Aside from that my plan has been to have a repo that acts both as a private repo you can publish to and as a proxy that will mirror only the packages you fetch that it can’t yet find and is configured to go look for in global hex (or any other hex really).

I started doing it in its own project, mirrormaster, but I think now that mini_repo is out it would be good to become a feature of it instead.

4 Likes

I offered the caching of the .hex directory as a solution but was shot down by devops for unspecified reasons. I guess I will just shoulder it until some solution arises that I can make use of.

Agreed, that’d be a great feature to have in mini_repo.

4 Likes