尝试使用MSBuild工具,Pyhon,pip和Python依赖关系创建docker容器

问题描述 投票:1回答:1

这是我最近的尝试,但未成功。我有要尝试容器化的python脚本。问题在于该脚本使用的库Office365需要MS Build Tools才能使用。因此,我一直在努力寻找如何创建具有“ pip”功能的MSBuild Tools / 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个回答
0
投票

这实际上对我有用!!

# 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" ]
© www.soinside.com 2019 - 2024. All rights reserved.