Skip to content

Hosting nuget.org's v3 services

Loïc Sharma edited this page Jul 12, 2018 · 5 revisions

⚠️ This guide does not cover how to setup the search service

⚠️ This guide is a work in progress. Please report any issues you encounter here: https://github.com/NuGet/NuGetGallery/issues

To setup nuget.org's v3 services you will need to:

  1. Setup an Azure Blob Storage account with the following containers:
    1. "index" - Hosts the service index
    2. "packages" - The Gallery's copy of NuGet packages, used by v3's ingestion pipeline
    3. "catalog" - This hosts the catalog resource
    4. "registration" - This hosts the metadata resource
    5. "flat-container" - This hosts the package content resource
    6. "auditing" - This stores package deletions from Gallery, used to populate the catalog
  2. Run the Gallery
    1. Configure StorageType to be AzureStorage here
    2. Configure the Gallery to point to the "packages" container here
    3. Configure the Gallery to point to the "auditing" container here
  3. Build NuGet.Services.Metadata
  4. Deploy the built ng.exe and all of its DLLs to your machine
  5. Run the feed2catalog job to populate the catalog resource:
Ng.exe feed2catalog ^
    -gallery https://yourgalleryurl.com/api/v2 ^
    -storageBaseAddress <https://azure.bob.storage.url.com>/catalog ^
    -storageType azure ^
    -storageAccountName <Blob Storage account name here> ^
    -storageKeyValue <Azure Blob Storage account key here> ^
    -storageContainer catalog ^
    -storageTypeAuditing azure ^
    -storageAccountNameAuditing <Blob Storage account name here> ^
    -storageKeyValueAuditing <Azure Blob Storage account key here> ^
    -storageContainerAuditing auditing ^
    -storagePathAuditing package
    -verbose true ^
    -interval 30
  1. Run the catalog2registration job to populate the metadata resource
Ng.exe catalog2registration ^
    -source <https://azure.bob.storage.url.com>/catalog/index.json ^
    -contentBaseAddress <https://azure.blob.storage.url.com>/flat-container/ ^
    -storageBaseAddress <https://azure.blob.storage.url.com>/registration/ ^
    -storageType azure ^
    -storageAccountName <Azure Blob Storage account name here> ^
    -storageKeyValue <Azure Blob Storage account key here> ^
    -storageContainer registration ^
    -useCompressedStorage false ^
    -verbose true ^
    -interval 30
  1. Run the catalog2dnx job to populate the package content resource
Ng.exe catalog2dnx ^
    -source <https://azure.blob.storage.url.com>/catalog/index.json ^
    -contentBaseAddress <https://azure.blob.storage.url.com>/packages ^
    -storageBaseAddress <https://azure.blob.storage.url.com>/flat-container ^
    -storageType azure ^
    -storageAccountName <Azure Blob Storage account name here> ^
    -storageKeyValue <Azure Blob Storage account key here> ^
    -storageContainer flat-container ^
    -verbose true ^
    -interval 30 ^
    -httpClientTimeoutInSeconds 900
  1. Upload a file index.json to the "index" container containing the following JSON:
{
"version": "3.0.0",
"resources": [
    {
        "@id": "<https://azure.blob.storage.url.com>/registration",
        "@type": "RegistrationsBaseUrl",
        "comment": "Base URL of Azure storage where NuGet package registration info is stored"
    },
    {
        "@id": "<https://azure.blob.storage.url.com>/flat-container/",
        "@type": "PackageBaseAddress/3.0.0",
        "comment": "Base URL of where NuGet packages are stored"
    },
    {
        "@id": "https://yourgalleryurl.com/api/v2",
        "@type": "LegacyGallery"
    },
    {
        "@id": "https://yourgalleryurl.com/api/v2/package",
        "@type": "PackagePublish/2.0.0"
    },
    {
        "@id": "https://yourgalleryurl.com/packages/{id}/{version}/ReportAbuse",
        "@type": "ReportAbuseUriTemplate/3.0.0-rc",
        "comment": "URI template used by NuGet Client to construct Report Abuse URL for packages used by RC clients"
    },
    {
        "@id": "<https://azure.blob.storage.url.com>/registration/{id-lower}/index.json",
        "@type": "PackageDisplayMetadataUriTemplate/3.0.0-rc",
        "comment": "URI template used by NuGet Client to construct display metadata for Packages using ID"
    },
    {
        "@id": "<https://azure.blob.storage.url.com>/registration/{id-lower}/{version-lower}.json",
        "@type": "PackageVersionDisplayMetadataUriTemplate/3.0.0-rc",
        "comment": "URI template used by NuGet Client to construct display metadata for Packages using ID, Version"
    },
    {
        "@id": "<https://azure.blob.storage.url.com>/catalog/index.json",
        "@type": "Catalog/3.0.0",
        "comment": "Index of the NuGet package catalog."
    }
    ],
    "@context": {
        "@vocab": "http://schema.nuget.org/services#",
        "comment": "http://www.w3.org/2000/01/rdf-schema#comment"
    }
}
  1. Use the source <https://azure.blob.storage.url.com/index/index.json to restore packages. Done!