bagetter / BaGetter

A lightweight NuGet and symbol server
https://www.bagetter.com
MIT License
269 stars 57 forks source link

read-through caching using docker on wsl #163

Closed martenf closed 4 months ago

martenf commented 4 months ago

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
Regenhardt commented 4 months ago

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.

martenf commented 4 months ago

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