forked from rancher/hyperkube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.windows
67 lines (65 loc) · 3.1 KB
/
Dockerfile.windows
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
ARG SERVERCORE_VERSION
FROM mcr.microsoft.com/windows/servercore:${SERVERCORE_VERSION} as builder
SHELL ["powershell", "-NoLogo", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN if (-not (Get-Command Expand-7Zip -ErrorAction Ignore)) { \
Install-PackageProvider -Name NuGet -Force -Verbose; \
Install-Module -Name 7Zip4Powershell -Repository PSGallery -Force -Verbose; \
if(-not $?) { \
Write-Error "Failed to install package"; \
Exit 1; \
} \
}
ENV K8S_VERSION v1.20.5
RUN $URL = ('https://dl.k8s.io/{0}/kubernetes-node-windows-amd64.tar.gz' -f $env:K8S_VERSION); \
\
function Expand-GZip ($inFile, $outFile) { \
$input = New-Object System.IO.FileStream $inFile, ([IO.FileMode]::Open), ([IO.FileAccess]::Read), ([IO.FileShare]::Read); \
$output = New-Object System.IO.FileStream $outFile, ([IO.FileMode]::Create), ([IO.FileAccess]::Write), ([IO.FileShare]::None); \
$gzipStream = New-Object System.IO.Compression.GzipStream $input, ([IO.Compression.CompressionMode]::Decompress); \
try { \
if (!$input -or !$output -or !$gzipStream) { \
Write-Error "Failed to Unzip the archive"; \
Exit 1; \
} \
$buffer = New-Object byte[](1024); \
while ($true) { \
$read = $gzipstream.Read($buffer, 0, 1024); \
if ($read -le 0 ) { \
break; \
} \
$output.Write($buffer, 0, $read); \
} \
} finally { \
$gzipStream.Close(); \
$output.Close(); \
$input.Close(); \
} \
}; \
\
Write-Host ('Downloading Kubernetes from {0} ...' -f $URL); \
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
Invoke-WebRequest -UseBasicParsing -OutFile c:\kubernetes.tar.gz -Uri $URL; \
\
Write-Host 'Expanding ...'; \
Expand-GZip c:\kubernetes.tar.gz c:\kubernetes.tar; \
Expand-7Zip c:\kubernetes.tar c:\; \
\
Write-Host 'Complete.'
FROM mcr.microsoft.com/powershell:nanoserver-${SERVERCORE_VERSION}
USER ContainerAdministrator
SHELL ["pwsh.exe", "-NoLogo", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN $URL = 'https://github.com/rancher/azure-cli/releases/download/v0.0.2/dist.azure-cli.zip'; \
\
Write-Host ('Downloading azure-cli from {0} ...' -f $URL); \
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
Invoke-WebRequest -UseBasicParsing -OutFile c:\azure-cli.zip -Uri $URL; \
\
Write-Host 'Expanding ...'; \
Expand-Archive -Force -Path c:\azure-cli.zip -DestinationPath c:\azure-cli; \
Remove-Item -Force -Path c:\azure-cli.zip; \
\
Write-Host 'Complete.'
COPY --from=builder /Windows/System32/netapi32.dll /Windows/System32/
COPY --from=builder /kubernetes/node/bin/kubectl.exe /Windows
COPY --from=builder /kubernetes/node/bin/kubelet.exe /kubernetes/node/bin/kube-proxy.exe /etc/kubernetes/bin/
COPY windows/entrypoint.ps1 /usr/bin/