ACR-SyncTool 1.2.16

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global ACR-SyncTool --version 1.2.16                
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.16                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=ACR-SyncTool&version=1.2.16                
nuke :add-package ACR-SyncTool --version 1.2.16                

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.17 286 10/11/2024
1.2.16 105 10/9/2024
1.2.15 3,723 4/12/2023
1.2.14 425 3/31/2023
1.2.13 312 3/31/2023
1.2.12 387 3/28/2023
1.2.11 355 3/28/2023
1.2.10 274 3/27/2023
1.2.9 294 3/27/2023
1.2.8 344 3/27/2023
1.2.7 453 3/11/2023
1.2.6 745 1/20/2023
1.2.5 1,541 8/23/2022
1.2.4 1,474 4/6/2022
1.2.3 667 3/24/2022
1.2.2 1,741 11/10/2021
1.2.1 584 11/8/2021
1.2.0 1,199 10/12/2021
1.1.0 847 10/1/2021
1.0.2 536 9/30/2021
1.0.1 583 9/30/2021
1.0.0 706 9/23/2021
1.0.0-alpha.13 240 9/22/2021
1.0.0-alpha.12 261 9/20/2021
1.0.0-alpha.11 350 9/14/2021
1.0.0-alpha.10 384 9/10/2021
1.0.0-alpha.9 270 9/9/2021
1.0.0-alpha.8 322 9/3/2021
1.0.0-alpha.7 278 8/30/2021
1.0.0-alpha.6 178 8/30/2021
1.0.0-alpha.5 181 8/30/2021
1.0.0-alpha.4 195 8/30/2021
1.0.0-alpha.3 199 8/30/2021
1.0.0-alpha.2 219 8/29/2021
1.0.0-alpha.1 200 8/29/2021