ACR-SyncTool 1.2.15

dotnet tool install --global ACR-SyncTool --version 1.2.15
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local ACR-SyncTool --version 1.2.15
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=ACR-SyncTool&version=1.2.15
nuke :add-package ACR-SyncTool --version 1.2.15

ACR-SyncTool

Nuget Nuget)

What is this for?

It is common practice to have the Azure Container Registry behind a firewall and inaccessable from the outside world. Additionally, it is common practice to prevent AKS from loading images from public Docker Repositories. These two practices make it difficult to deploy images to the AKS cluster.

This tool aims to make this process easier by allowing you to sync images from a Docker Registry to the private Azure Container Registries.

How it works

This tool is split into 3 different steps:

  • ExportExistingImages
    • The first step is meant to be ran on your private Azure DevOps agents which have access to the Azure Container Registry. This step will export all the image names and tags to a json file. Your CI/CD pipeline should save this file to the Pipeline Artifacts and make it accessible to the next step.
  • PullAndSaveMissingImages
    • The second step is meant to be ran on the Microsoft Hosted Azure DevOps agents and will pull all the images and tags from the Docker Registries that you are missing and save them to a tar file. Your CI/CD pipeline should save this file to the Pipeline Artifacts and make it accessible to the next step.
  • LoadAndPushImages
    • This final mode is meant to be ran on your private Azure DevOps agents. It will load the image tar from the previous step, re tag them and push them to your private Azure Container Registry.

How to use

  • Install .Net 6

  • dotnet tool install --global acr-synctool

  • Create appsettings.json and fill out the details

    • MaxSyncSizeGB
      • Max total image size to sync. Once reached the rest will be skipped.
    • AzureContainerRegistries
      • List of Azure Container Registries with Service Principle Credentials
    • Registries
      • List of Docker Registries and credentials
      • If a registry doesn't require credentials, you can exclude it from this list
      • AuthType can be Basic, PasswordOAuth or AnonymousOAuth
    • SyncedImages
      • List of Docker Images to sync
      • Image
        • Full image name ie registry.hub.docker.com/library/busybox
      • Semver
        • Semver rule, if it doesn't match, the Tag will not be synced
      • Regex
        • Regex rule, if it doesn't match, the Tag will not be synced
      • Tags
        • Array of specific tags to sync
  • {
      "MaxSyncSizeGB": "5",
      "AzureContainerRegistries": [
        {
          "Host": "ijtestacr.azurecr.io",
          "TenantId": "f4ba3f29-303f-4c8b-a487-991dc21962c0",
          "ClientId": "7c06291c-13bc-4321-ae27-34948ecc1eec",
          "Secret": "mysecret"
        }
      ],
      "Registries": [
        {
          "Host": "ghcr.io",
          "AuthType": "PasswordOAuth", 
          "Username": "ivanjosipovic",
          "Password": "Pat Token"
        },
        {
          "Host": "registry.hub.docker.com",
          "AuthType": "PasswordOAuth",
          "Username": "ivanjosipovic",
          "Password": "Access Tokens"
        }
      ],
      "SyncedImages": [
        {
          "Image": "ghcr.io/fluxcd/helm-controller",
          "Semver": ">=0.11.0"
        },
        {
          "Image": "ghcr.io/fluxcd/image-automation-controller",
          "Semver": ">=0.14.0"
        },
        {
          "Image": "ghcr.io/fluxcd/image-reflector-controller",
          "Semver": ">=0.11.0"
        },
        {
          "Image": "ghcr.io/fluxcd/kustomize-controller",
          "Semver": ">=0.14.0"
        },
        {
          "Image": "ghcr.io/fluxcd/notification-controller",
          "Semver": ">=0.16.0"
        },
        {
          "Image": "ghcr.io/fluxcd/source-controller",
          "Semver": ">=0.15.0"
        },
        {
          "Image": "registry.hub.docker.com/nginx/nginx-ingress",
          "Tags": [
            "1.12.0"
          ]
        }
      ]
    }
    

Example Command Lines (execute in folder containing appsettings.json)

  • acr-synctool --Action ExportExistingImages --ACRHostName ijtestacr.azurecr.io --JsonExportFilePath acr-export.json
  • acr-synctool --Action PullAndSaveMissingImages --ImagesTarFilePath images.tar --JsonExportFilePath acr-export.json
  • acr-synctool --Action LoadAndPushImages --ACRHostName ijtestacr.azurecr.io --ImagesTarFilePath images.tar

Local Testing

  • dotnet pack
  • dotnet tool install --global --add-source ./src/bin/Debug/ acr-synctool
  • dotnet tool uninstall -g acr-synctool
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
1.2.15 2,776 4/12/2023
1.2.14 357 3/31/2023
1.2.13 245 3/31/2023
1.2.12 321 3/28/2023
1.2.11 294 3/28/2023
1.2.10 214 3/27/2023
1.2.9 230 3/27/2023
1.2.8 282 3/27/2023
1.2.7 389 3/11/2023
1.2.6 672 1/20/2023
1.2.5 1,475 8/23/2022
1.2.4 1,403 4/6/2022
1.2.3 597 3/24/2022
1.2.2 1,662 11/10/2021
1.2.1 507 11/8/2021
1.2.0 1,120 10/12/2021
1.1.0 776 10/1/2021
1.0.2 463 9/30/2021
1.0.1 510 9/30/2021
1.0.0 628 9/23/2021
1.0.0-alpha.13 197 9/22/2021
1.0.0-alpha.12 219 9/20/2021
1.0.0-alpha.11 305 9/14/2021
1.0.0-alpha.10 339 9/10/2021
1.0.0-alpha.9 224 9/9/2021
1.0.0-alpha.8 280 9/3/2021
1.0.0-alpha.7 236 8/30/2021
1.0.0-alpha.6 137 8/30/2021
1.0.0-alpha.5 142 8/30/2021
1.0.0-alpha.4 148 8/30/2021
1.0.0-alpha.3 158 8/30/2021
1.0.0-alpha.2 176 8/29/2021
1.0.0-alpha.1 160 8/29/2021