@@ -8,20 +8,41 @@ set -ex
88#  DockerHub API endpoint for vllm/vllm-openai repository
99REPO_API_URL=" https://hub.docker.com/v2/repositories/vllm/vllm-openai/tags" 
1010
11- #  Get DockerHub token  from environment
11+ #  Get DockerHub credentials  from environment
1212if  [ -z  " $DOCKERHUB_TOKEN " ;  then 
1313    echo  " Error: DOCKERHUB_TOKEN environment variable is not set" 
1414    exit  1
1515fi 
1616
17+ if  [ -z  " $DOCKERHUB_USERNAME " ;  then 
18+     echo  " Error: DOCKERHUB_USERNAME environment variable is not set" 
19+     exit  1
20+ fi 
21+ 
22+ #  Get DockerHub bearer token
23+ echo  " Getting DockerHub bearer token..." 
24+ set  +x
25+ BEARER_TOKEN=$( curl -s -X POST \
26+     -H " Content-Type: application/json"  
27+     -d " {\" username\" : \" $DOCKERHUB_USERNAME \" , \" password\" : \" $DOCKERHUB_TOKEN \" }"  
28+     " https://hub.docker.com/v2/users/login" |  jq -r ' .token' )  
29+ set  -x
30+ 
31+ if  [ -z  " $BEARER_TOKEN " ||  [ " $BEARER_TOKEN " =  " null" ;  then 
32+     echo  " Error: Failed to get DockerHub bearer token" 
33+     exit  1
34+ fi 
35+ 
1736#  Function to get all tags from DockerHub
1837get_all_tags () {
1938    local  page=1
2039    local  all_tags=" " 
2140
2241    while  true ;  do 
23-         local  response=$( curl -s -H " Authorization: Bearer $DOCKERHUB_TOKEN " 
42+         set  +x
43+         local  response=$( curl -s -H " Authorization: Bearer $BEARER_TOKEN " 
2444            " $REPO_API_URL ?page=$page &page_size=100" )  
45+         set  -x
2546
2647        #  Get both last_updated timestamp and tag name, separated by |
2748        local  tags=$( echo " $response " |  jq -r ' .results[] | select(.name | startswith("nightly-")) | "\(.last_updated)|\(.name)"' ) 
@@ -43,7 +64,9 @@ delete_tag() {
4364    echo  " Deleting tag: $tag_name " 
4465
4566    local  delete_url=" https://hub.docker.com/v2/repositories/vllm/vllm-openai/tags/$tag_name " 
46-     local  response=$( curl -s -X DELETE -H " Authorization: Bearer $DOCKERHUB_TOKEN " " $delete_url " ) 
67+     set  +x
68+     local  response=$( curl -s -X DELETE -H " Authorization: Bearer $BEARER_TOKEN " " $delete_url " ) 
69+     set  -x
4770
4871    if  echo  " $response " |  jq -e ' .detail' >  /dev/null 2>&1 ;  then 
4972        echo  " Warning: Failed to delete tag $tag_name : $( echo " $response " |  jq -r ' .detail' ) " 
0 commit comments