Azure Container Registry Release Candidate Docker Image Deleter
A dockerised bash script using the Azure CLI to delete Release Candidate (RC) docker image tags from Azure Container Registry (ACR).
Before using the docker container in your pipeline you'll need to create aservice principle with access to ACR.
Usage
See the Environment Variables table below.
Command
The following example would check the repo regname/repo-name
for RC tags of 0.12.2
, but not delete them:
docker run -it \
-e AZURE_TENANT=000-000-000-000 \
-e AZURE_SUBSCRIPTION=000-000-000-000 \
-e REGISTRY_NAME=regname \
-e REGISTRY_USERNAME=username \
-e REGISTRY_PASSWORD=password \
-e REPO=repo-name \
-e VERSION=0.12.2 \
-e DRY_RUN=1 \
desholmes/acr-rc-deleter:0.1.0
Environment Variables
Environment Variable | Description |
---|---|
AZURE_TENANT |
Locate your Azure Account Tenant ID. |
AZURE_SUBSCRIPTION |
Locate your Azure Subscription ID. |
REGISTRY_NAME |
Locate your ACR name. |
REGISTRY_USERNAME |
The service principle username. |
REGISTRY_PASSWORD |
The service principle password. |
REPO |
The docker repo you want to check/delete the tags from |
VERSION |
The stable version of your tag, ie 0.1.0 for release candidates 0.1.0-rc.15 , 0.1.0-rc.15 |
DRY_RUN |
Boolean 1 to output the number of tags, 0 to delete the tags |
Development
The docker image tag, registry and repo are tracked in the Makefile.
Make Commands
Make commands are included in this repo to automate the repetitive tasks. Copy .env-dist to .env
and populate the details before using the commands below.
Command | Description |
---|---|
make build |
Builds the docker image. |
make build-push |
Runs make build and make push . |
make clean-dangling-images |
Removes intermediate docker images. |
make delete-image |
Removes the docker image based. |
make push |
Pushes the docker image into the registry. |
make run |
Runs the built docker image as a container bind mounts the ./app/ folder into the container for live reloading. |
make run-clean |
Runs make delete-image , make build and make run . |