[英]How to use Code from another Repository in Azure Devops Docker Build
[英]Build Docker image from GitHub repository
我正在嘗試使用docker api python client從GitHub存儲庫構建docker映像。
這是我嘗試過的方法: 來自views.py
if request.method == 'POST':
post_data = request.POST.copy()
post_data.update({'user': request.user.pk})
form = TarFromGithubForm(post_data)
if form.is_valid():
deployment = gitHubModel()
deployment.name = form.cleaned_data['name']
deployment.user = request.user
deployment.archive = form.cleaned_data['archive']
dpath = deployment.archive
print(deployment.archive)
deployment.save()
tag = deployment.name.lower()
client = docker.from_env()
client.images.build(path=dpath, tag=tag)
messages.success(request, 'Your deployment from github repository has been created successfully!')
return HttpResponseRedirect(reverse('users:deployments:repo'))
在這里,在歸檔輸入字段中,用戶將提供github存儲庫URL。
它拋出一個錯誤:
在/ user / deployment / new / github上的APIError 500服務器錯誤:內部服務器錯誤(“檢測遠程https://github.com/Abdul-Rehman-yousaf/testing的內容類型錯誤:不支持的內容類型“ text / html; charset = utf-8“”)請求方法:POST請求URL: http : //127.0.0.1 :8000/user/deployment/new/github Django版本:1.11.3異常類型:APIError異常值:
500服務器錯誤:內部服務器錯誤(“檢測遠程https://github.com/Abdul-Rehman-yousaf/testing的內容類型時出錯:不支持的內容類型“ text / html; charset = utf-8””)異常位置:create_api_error_from_http_exception中的/Users/abdul/IstioVirEnv/lib/python3.6/site-packages/docker/errors.py,第31行Python可執行文件:/ Users / abdul / IstioVirEnv / bin / python Python版本:3.6.1
detecting content type for remote
unsupported Content-Type "text/html; charset=utf-8""
detecting content type for remote
unsupported Content-Type "text/html; charset=utf-8""
您確定傳遞正確的URL嗎?如果在這種情況下,您想要Dockerfile,它將位於: https:// raw。 githubusercontent.com/Abdul-Rehman-yousaf/testing/master/Dockerfile
您可以使用wget
發出一個簡單的http請求,以確保您傳遞正確的url:
wget https://raw.githubusercontent.com/Abdul-Rehman yousaf/testing/master/Dockerfile
所以看來您傳遞的是錯誤的URL,另一種方法是克隆存儲庫並將代碼傳遞給Dockerfile,它將內容過程通過將所需的文件或文件夾復制到容器等來進行....
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.