bagetter/BaGetter

read-through caching using docker on wsl

Closed this issue · 2 comments

I'm trying to run BaGetter as a docker container using docker compose on wsl.
I can't seam to mount the appsettings.json file to a volume and so I tried as a temporary solution to enable read-through caching in the appsettings.json file. When I do that and restart the docker container I still can't find any nuget.org packages in the web interface.

volumes:
  data:

services:
  bagetter:
    image: bagetter/bagetter:latest
    environment:
    - ApiKey=APIKEY
    restart: unless-stopped
    volumes:
    - data:/data
    ports:
    - 5000:8080

  • For docker use it would be very convenient to have the settings files in a separate settings folder and not inside the app folder.
  • Is it possible to enable read-through caching with an environmental variable?
  • With the docker compose code above should the read-through caching work after enabling it in the appsettings.json or am I missing something?

Hi, first: the read-through cache does not mirror the search index, only downloads and caches specific packages that you request. You set up BaGetter as primary package source and nuget.org as secondary, then search/install your nuget.org packages from nuget.org. Any time you restore packages in a project, nuget will first request the packages from BaGetter, which will return them from the cache.

For configuration, you can use environment variables for that, which will work for any asp.net core application like that.

This will set the database type to Sqlite for example:

Database__Type=Sqlite

Database is the outer object you can see in the appsettings file (same level as ApiKey), Type is the property inside that. Note that they are connected using two underscores (_).

So read-through caching to nuget.org would look like this in an env file:

Mirror__Enabled=true
Mirror__PackageSource=https://api.nuget.org/v3/index.json

So add those to your environment array and you should be good to go.

You can get more specifics about configuration via environment variables from the official documentation.

You can see a simple example for running the docker image with an env file in the BaGetter documentation.

We're still working on the helm chart, so maybe there'll be an example for that soon too.

Ok thanks. I misunderstood how the mirror source was supposed to work.