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MuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJidWlsZGVyLXRva2VuLWdrOWtwIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImJ1aWxkZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI3MDhjZjgwZC02ZDMzLTExZWMtODBmMC0wMDUwNTZiNGU2NDUiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6eWltYXRvbmc6YnVpbGRlciJ9.ls_1gcThiU1zw-t9VzAOudgpjOBSwttboMjkK5rbAmZRCA4gMEm8xlqcNCq4Zfmy7Zn1tno-eUZdGulN0UrGuhZHOPsYuSpZ_-El_Z9in3b5GdE77WlvqXXz8bBN5DutMZLa6LN7tcaPSD9wAjmIz-YCqcUEn6ehvtNOR8hgG3JuO6dlBhPD4P3V5E83iYZ6XAQFxC_GSW_u2v29m9SGX9va0oqgpdFOE71Dwvq3c66wSuLbB4EOdNO0b-bCUHE-nRBQppv-y-4F9jHbvCf_rDEi90t-VzdUX5dYcWP0nqInz4ka-uGVAwQu0abxv0Ha3h2EdWSjWUO3tNE6JN8d-w
 TARGET=aiot-fe-prod
 PROJECTNAME_TEST=yimatong

if [ $? -ne 0 ];then
    echo "构建失败!"
else
  docker build --platform=linux/amd64 -f Dockerfile -t ${TARGET}:latest . 
  #  &&  docker tag ${TARGET} docker-registry-default.app.eazytec.intra/${PROJECTNAME_TEST}/${TARGET}:latest && docker login -p ${DOCKER_TOKEN_TEST} -u unused docker-registry-default.app.eazytec.intra && docker push docker-registry-default.app.eazytec.intra/${PROJECTNAME_TEST}/${TARGET}
fi
