【问题标题】:Trying to Create a docker container with MSBuild Tools, Pyhon, pip, and Python Dependencies尝试使用 MSBuild 工具、Pyhon、pip 和 Python 依赖项创建 docker 容器
【发布时间】:2020-06-25 18:32:38
【问题描述】:

这是我最近的尝试,但没有成功。我有我正在尝试容器化的 python 脚本。问题是该脚本使用库 office365,这需要 MS Build Tools 才能使用。因此,我一直在努力寻找如何创建具有“pip”功能的 MSBuild 工具/Python 容器。有什么想法吗?!

FROM python:3.8.0-windowsservercore

ADD https://aka.ms/vs/15/release/vs_buildtools.exe C:\\Downloads\\vs_buildtools.exe ADD https://dist.nuget.org/win-x86-commandline/v4.3.0/nuget.exe C:\\Nuget\\nuget.exe

RUN C:\\Downloads\\vs_buildtools.exe --add Microsoft.VisualStudio.Workload.MSBuildTools --add Microsoft.VisualStudio.Workload.NetCoreBuildTools --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.WebBuildTools --quiet --wait RUN SETX /M Path "%Path%;C:\\Nuget;C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\Bin"

# Install Dependencies 
RUN pip install pandas 
RUN pip install datetime 
RUN pip install tqdm 
RUN pip install office365

# Add Script ADD AutoDemandLeadtime.py /

# Run CMD [ "python", "./AutoDemandLeadtime.py" ]

【问题讨论】:

    标签: python docker msbuild docker-container docker-image


    【解决方案1】:

    这实际上对我有用!!!

    # escape=`
    
    FROM mcr.microsoft.com/dotnet/framework/sdk:4.8
    
    SHELL ["cmd", "/S", "/C"]
    
    ADD https://aka.ms/vs/16/release/vs_buildtools.exe C:\Temp\vs_buildtools.exe
    ADD https://aka.ms/vs/16/release/channel C:\Temp\VisualStudio.chman
    RUN C:\Temp\vs_buildtools.exe `
        --quiet --wait --norestart --nocache `
        --installPath C:\BuildTools `
        --channelUri C:\Temp\VisualStudio.chman `
        --installChannelUri C:\Temp\VisualStudio.chman `
        --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended `
        --add Microsoft.Component.MSBuild `
     || IF "%ERRORLEVEL%"=="3010" EXIT 0
    
    RUN powershell.exe -ExecutionPolicy RemoteSigned `
      iex (new-object net.webclient).downloadstring('https://get.scoop.sh'); `
      scoop install python git
    
    # Install Dependencies
    RUN pip install pandas
    RUN pip install datetime
    RUN pip install tqdm
    RUN pip install office365
    
    # Add Script
    ADD AutoDemandLeadtime.py /
    
    ENTRYPOINT C:\BuildTools\Common7\Tools\VsDevCmd.bat &&
    CMD [ "python", "./AutoDemandLeadtime.py" ]
    

    【讨论】:

      猜你喜欢
      • 2021-04-24
      • 2019-03-05
      • 2019-04-13
      • 2010-11-25
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多