Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy under Windows. #12435

Closed
nanoric opened this issue Jul 15, 2020 · 4 comments
Closed

Proxy under Windows. #12435

nanoric opened this issue Jul 15, 2020 · 4 comments

Comments

@nanoric
Copy link
Contributor

nanoric commented Jul 15, 2020

Sorry for asking this question again and again.
I have tried the following(enable_global_proxy.bat):

netsh winhttp set proxy proxy-server="socks=192.168.0.201:2000"
setx all_proxy socks5h://192.168.0.201:2000/
setx https_proxy http://192.168.0.201:2001/
setx http_proxy http://192.168.0.201:2001/

This USED to work about a month ago. But for now it does'nt work.

vcpkg strucks at the first invoke of install, when downloading
https://github.com/PowerShell/PowerShell/releases/download/v6.2.1/PowerShell-6.2.1-win-x86.zip

MyCode(Dockerfile):

FROM mcr.microsoft.com/windows/servercore:1809-amd64

# Choco
RUN powershell -ExecutionPolicy Unrestricted -Command $env:chocolateyUseWindowsCompression = 'true'; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

# Download the Build Tools bootstrapper.
RUN mkdir C:\\TEMP
COPY ./vs_community__1592069024.1584505823.exe C:/TEMP

# Install Build Tools excluding workloads and components with known issues.
RUN C:/TEMP/vs_community__1592069024.1584505823.exe --quiet --wait --norestart --nocache \
    --add Microsoft.VisualStudio.Workload.NativeDesktop \
    --add Microsoft.VisualStudio.Component.VC.CLI.Support \
    --add Microsoft.VisualStudio.Component.VC.ATLMFC \
    --add Microsoft.VisualStudio.Component.VC.ATL \
	--add Microsoft.VisualStudio.Component.Windows10SDK.18362 \
    --add Microsoft.Component.VC.Runtime.UCRTSDK \
	--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64	\
 || IF "%ERRORLEVEL%"=="3010" EXIT 0
 
# Enable Proxy
COPY ./proxy C:/proxy
RUN C:/proxy/enable_global_proxy

# Msys2
RUN choco install -y --accept-license msys2 --params "/NoUpdate /InstallDir:C:/msys64" || exit 0
RUN cd C:/Users/Administrator/AppData/Local/Temp\
  && del /S /Q *\
  && setx PATH "C:/msys64/usr/bin;%PATH%"
RUN pacman -S --noconfirm vim unzip nasm yasm

# Python3
RUN choco install -y --accept-license python3 --params "/InstallDir:C:\python3"\
  && cd C:/Users/Administrator/AppData/Local/Temp\
  && del /S /Q *\
  && cp C:/python3/python.exe C:/python3/python3.exe


# Git
RUN choco install -y --accept-license git --params "/GitOnlyOnPath /NoShellIntegration /NoGuiHereIntegration /NoCredentialManager"\
  && cd C:/Users/Administrator/AppData/Local/Temp\
  && del /S /Q *

# CMake
RUN choco install --force -y --accept-license cmake --installargs "ADD_CMAKE_TO_PATH=System DESKTOP_SHORTCUT_REQUESTED=0 ALLUSERS=1"\
  && cd C:/Users/Administrator/AppData/Local/Temp\
  && del /S /Q *

# vcpkg
WORKDIR C:/
RUN git clone https://github.com/microsoft/vcpkg\
  && cd vcpkg\
  && bootstrap-vcpkg.bat\
  && vcpkg integrate install
  
ENV VCPKG_CMAKE_TOOLCHAIN_FILE C:/vcpkg/scripts/buildsystems/vcpkg.cmake
ENV VCPKG_ROOT C:/vcpkg

# common libs
WORKDIR C:/vcpkg
RUN vcpkg --triplet x64-windows install --x-use-aria2 --clean-after-build\
    boost

RUN vcpkg --triplet x64-windows install --clean-after-build\
    openssl
	
RUN vcpkg --triplet x64-windows install --clean-after-build\
	spdlog
	
RUN vcpkg --triplet x64-windows install --clean-after-build\
	tbb yaml-cpp gtest range-v3 fmt date scnlib
	
RUN vcpkg --triplet x64-windows install --clean-after-build\
    --head cppzmq cli11

RUN C:/proxy/disable_global_proxy

# Clear C:/TEMP, C:\Users\Administrator\AppData\Local\Temp
WORKDIR C:/TEMP
RUN del /S /Q *

WORKDIR C:/
ADD ./call_vcvars64.bat C:/

# some tools
COPY tools/ C:/tools
RUN setx PATH "C:/tools;%PATH%"

ENTRYPOINT ["CMD.exe", "/S", "/C", "call C:/call_vcvars64.bat && powershell.exe -NoLogo -ExecutionPolicy Bypass"]

CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]

@MVoz
Copy link
Contributor

MVoz commented Jul 15, 2020

https://docs.docker.com/config/daemon/systemd/

setx https_proxy http://192.168.0.201:2001/
setx http_proxy http://192.168.0.201:2001/

setx https_proxy http**S**://192.168.0.201:2001/ ?

@nanoric
Copy link
Contributor Author

nanoric commented Jul 15, 2020

https://docs.docker.com/config/daemon/systemd/

setx https_proxy http://192.168.0.201:2001/
setx http_proxy http://192.168.0.201:2001/

setx https_proxy http**S**://192.168.0.201:2001/ ?

for the http schema:
I don't have a https proxy(which needs certificates).
I don't know if it is necessary to use a https proxy to access a https site. But I can use a http proxy to access https site in chrome.(And, you know, the proxy i'm using in chrome is just the one I set in this script.). So maybe it is not a problem.

I don't know much about how docker manager its network access.
I only know the proxy setting of docker daemon effects how docker pulls images,
Does it still effect how its container accessing network (by using WinHTTP)?

@nanoric
Copy link
Contributor Author

nanoric commented Jul 15, 2020

Maybe the script enabling proxy never works.
The reason I build image succeed a month ago is maybe just because I can access github without proxy at that time.

@nanoric
Copy link
Contributor Author

nanoric commented Jul 15, 2020

And finally I turn to another solution
To avoid vcpkg to download these and fails, download/install them manually is a better solution.

All the tools are listed in scripts/vcpkgTools.xml
And by just set environment variable VCPKG_FORCE_SYSTEM_BINARIES, Pre-download/install all the tools that vcpkg needs is possible. #4501 (comment)

@nanoric nanoric closed this as completed Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants