File: Dockerfile.nanoserver

package info (click to toggle)
azure-cli 2.82.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,359,416 kB
  • sloc: python: 1,910,381; sh: 1,343; makefile: 406; cs: 145; javascript: 74; sql: 37; xml: 21
file content (86 lines) | stat: -rw-r--r-- 3,262 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
FROM mcr.microsoft.com/windows/servercore:1709 AS base

ARG CLI_VERSION

# Metadata as defined at http://label-schema.org
ARG BUILD_DATE
LABEL maintainer="Microsoft" \
      org.label-schema.schema-version="1.0" \
      org.label-schema.vendor="Microsoft" \
      org.label-schema.name="Azure CLI 2.0" \
      org.label-schema.version=$CLI_VERSION \
      org.label-schema.license="MIT" \
      org.label-schema.description="The Azure CLI 2.0 is the new Azure CLI and is applicable when you use the Resource Manager deployment model." \
      org.label-schema.url="https://learn.microsoft.com/cli/azure/overview" \
      org.label-schema.usage="https://learn.microsoft.com/cli/azure/install-az-cli2#docker" \
      org.label-schema.build-date=$BUILD_DATE \
      org.label-schema.vcs-url="https://github.com/Azure/azure-cli.git" \
      org.label-schema.docker.cmd="docker run -v $HOME\.azure:C:\Users\ContainerUser\.azure -it mcr.microsoft.com/azure-cli:$CLI_VERSION"

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ENV PYTHON_VERSION 3.6.5
ENV PYTHON_HASH 9e96c934f5d16399f860812b4ac7002b
ENV DESTINATION_FOLDER C:\\tools

RUN $python_url = ('https://www.python.org/ftp/python/{0}/python-{0}-amd64.exe' -f $env:PYTHON_VERSION); \
    Write-Host ('Downloading {0}...' -f $python_url); \
    mkdir tmp > $null; \
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
    (New-Object System.Net.WebClient).DownloadFile($python_url, 'c:\tmp\python-installer.exe'); \
    Write-Host ('Checking hash...' -f $python_url); \
    if ((Get-FileHash c:\tmp\python-installer.exe -Algorithm md5).Hash -ne $env:PYTHON_HASH) { Write-Host 'Python installer checksum verification failed!'; exit 1; }; \
    $install_folder = Join-Path -Path $env:DESTINATION_FOLDER -ChildPath 'python'; \
    Write-Host ('Installing into {0}...' -f $install_folder); \
    Start-Process c:\tmp\python-installer.exe -Wait -ArgumentList @('/quiet', 'InstallAllUsers=1', 'TargetDir={0}' -f $install_folder, 'PrependPath=1', 'Shortcuts=0', 'Include_doc=0','Include_pip=1', 'Include_test=0'); \
    Remove-Item tmp -Recurse -Force;

FROM mcr.microsoft.com/powershell:6.0.2-nanoserver

COPY --from=base ["tools", "tools"]

USER ContainerAdministrator

RUN setx /M PATH %PATH%;c:\tools\python\;c:\tools\python\Scripts\;

COPY . /azure-cli

WORKDIR azure-cli

USER ContainerUser

RUN python -m pip install --upgrade pip
RUN pip install wheel

SHELL ["pwsh.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

RUN $folder = @(); \
foreach($i in Get-ChildItem 'src\\' -Exclude 'azure-cli-testsdk') \
{ \
    $folder += Join-Path 'src\\' $i.Name \
} \
$wheels = Join-Path $pwd 'wheels'; \
Write-Host 'Building python packages...'; \
foreach($f in $folder) \
{ \
    try { \
        Push-Location $f; \
        & python.exe setup.py bdist_wheel -d $wheels; \
    } \
    finally { \
        Pop-Location \
    } \
}\ 
Write-Host 'Installing python packages...'; \
Push-Location $wheels; \
$modules = (Get-ChildItem *.whl -Name); \
foreach($m in $modules) \
{ \
    & pip install --no-cache-dir $m; \
}\
Pop-Location; \
Write-Host 'Done'; 

WORKDIR /

CMD pwsh.exe