11
11
FROM microsoft/windowsservercore:ltsc2016
12
12
#Needed to just work
13
13
ENV PYTHONIOENCODING='UTF-8'
14
- ENV CHOCO_URL=https://chocolatey.org/install.ps1
15
- #All the variables used for salt
16
- ENV SALT_SRC_PATH='C:/temp/salt/'
17
- ENV SALT_GIT_URL=https://github.com/saltstack/salt
18
- ENV SALT_CHECKOUT=v2018.11
19
- #All the variables used for hubble
20
- ARG HUBBLE_CHECKOUT=v4.0.0
21
- ARG HUBBLE_GIT_URL=https://github.com/hubblestack/hubble.git
22
- ENV HUBBLE_SRC_PATH='C:/temp/hubble/'
23
14
ENV _HOOK_DIR='./pkg/'
24
15
ENV NSIS_LOC='C:/Program Files (x86)/NSIS'
25
16
#Create location for build environment and set as working dir
26
17
RUN powershell.exe -Command New-Item c:/temp -ItemType Directory; \
27
18
New-Item C:/data -ItemType Directory;
28
19
WORKDIR C:/temp
29
20
VOLUME C:/data
30
- #Copy local files to working directory
31
- COPY pyinstaller-requirements.txt c:/temp/
32
- COPY hubble.conf C:/temp/
33
- #install Chocolatey, then git and osquery
21
+ #############
22
+ # Installing Python 3.5.3
23
+ #############
24
+
25
+ SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
26
+
27
+ ENV PYTHON_VERSION 3.5.3
28
+ ENV PYTHON_RELEASE 3.5.3
29
+
30
+ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env:PYTHON_RELEASE, $env:PYTHON_VERSION); \
31
+ Write-Host ('Downloading {0} ...' -f $url); \
32
+ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
33
+ Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \
34
+ \
35
+ Write-Host 'Installing ...'; \
36
+ # https://docs.python.org/3.5/using/windows.html#installing-without-ui
37
+ Start-Process python.exe -Wait \
38
+ -ArgumentList @( \
39
+ '/quiet', \
40
+ 'InstallAllUsers=1', \
41
+ 'TargetDir=C:\Python35', \
42
+ 'PrependPath=1', \
43
+ 'Shortcuts=0', \
44
+ 'Include_doc=0', \
45
+ 'Include_pip=0', \
46
+ 'Include_test=0' \
47
+ ); \
48
+ \
49
+ # the installer updated PATH, so we should refresh our local value
50
+ $env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \
51
+ \
52
+ Write-Host 'Verifying install ...'; \
53
+ Write-Host ' python --version'; python --version; \
54
+ \
55
+ Write-Host 'Removing ...'; \
56
+ Remove-Item python.exe -Force; \
57
+ \
58
+ Write-Host 'Complete.'
59
+
60
+ # if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
61
+ ENV PYTHON_PIP_VERSION 20.0.2
62
+ # https://github.com/pypa/get-pip
63
+ ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/d59197a3c169cef378a22428a3fa99d33e080a5d/get-pip.py
64
+ ENV PYTHON_GET_PIP_SHA256 421ac1d44c0cf9730a088e337867d974b91bdce4ea2636099275071878cc189e
65
+
66
+ RUN Write-Host ('Downloading get-pip.py ({0}) ...' -f $env:PYTHON_GET_PIP_URL); \
67
+ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
68
+ Invoke-WebRequest -Uri $env:PYTHON_GET_PIP_URL -OutFile 'get-pip.py'; \
69
+ Write-Host ('Verifying sha256 ({0}) ...' -f $env:PYTHON_GET_PIP_SHA256); \
70
+ if ((Get-FileHash 'get-pip.py' -Algorithm sha256).Hash -ne $env:PYTHON_GET_PIP_SHA256) { \
71
+ Write-Host 'FAILED!'; \
72
+ exit 1; \
73
+ }; \
74
+ \
75
+ Write-Host ('Installing pip=={0} ...' -f $env:PYTHON_PIP_VERSION); \
76
+ python get-pip.py \
77
+ --disable-pip-version-check \
78
+ --no-cache-dir \
79
+ ('pip=={0}' -f $env:PYTHON_PIP_VERSION) \
80
+ ; \
81
+ Remove-Item get-pip.py -Force; \
82
+ \
83
+ Write-Host 'Verifying pip install ...'; \
84
+ pip --version; \
85
+ \
86
+ Write-Host 'Complete.'
87
+
88
+ #############
89
+
90
+ ENV CHOCO_URL=https://chocolatey.org/install.ps1
91
+ ##install Chocolatey, then git and osquery
34
92
RUN powershell.exe -Command Set-ExecutionPolicy Bypass -Scope Process -Force; \
35
93
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'; \
36
94
iex ((New-Object System.Net.WebClient).DownloadString("$env:CHOCO_URL"));
37
95
RUN powershell.exe -Command choco install git nssm -y;
38
96
RUN powershell.exe -Command choco install osquery --version 3.4.0 -y;
39
97
40
98
#RUN powershell.exe $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
99
+ #All the variables used for salt
100
+ ENV SALT_SRC_PATH='C:/temp/salt/'
101
+ ENV SALT_GIT_URL=https://github.com/saltstack/salt
102
+ ENV SALT_CHECKOUT=v2018.11
41
103
#Git clone salt and run packages
42
104
RUN powershell.exe -Command git clone "$env:SALT_GIT_URL"; \
43
105
Push-Location salt/pkg/windows; \
44
106
git checkout "$env:SALT_CHECKOUT"; \
45
107
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'; \
46
- C:/temp/salt/pkg/windows/build_env_2 .ps1 -Silent;
108
+ C:/temp/salt/pkg/windows/build_env_3 .ps1 -Silent;
47
109
#more salt installs
48
110
RUN powershell.exe -Command Push-Location salt; \
49
- test-path . /setup.py; \
50
- python . /setup.py --quiet install --force; \
111
+ test-path C:/temp/salt /setup.py; \
112
+ python C:/temp/salt /setup.py --quiet install --force; \
51
113
pop-location;
114
+ #All the variables used for hubble
115
+ ARG HUBBLE_CHECKOUT=4.0-pkg-fix
116
+ ARG HUBBLE_GIT_URL=https://github.com/jettero/hubble.git
117
+ ENV HUBBLE_SRC_PATH='C:/temp/hubble/'
52
118
#Clone Hubble
53
119
RUN powershell.exe -Command git clone "$env:HUBBLE_GIT_URL"; \
54
120
Push-Location hubble; \
55
121
git checkout "$env:HUBBLE_CHECKOUT"; \
56
122
pop-location;
57
123
124
+ #Copy local files to working directory
125
+ COPY pyinstaller-requirements.txt c:/temp/
126
+ COPY hubble.conf C:/temp/
127
+
58
128
#Use pip to install hubble dependencies
59
129
RUN powershell.exe -Command pip install -r pyinstaller-requirements.txt;
60
130
61
- # Modify gitfs fix for incorrect path variables until fix has been upstreamed
62
- RUN powershell.exe -Command If (!(Test-Path C:/Python27 /Lib/site-packages/salt)) {Copy-Item C:/temp/salt/salt -Destination C:/Python27 /Lib/site-packages/ -Recurse -Force}; \
63
- $gitfsFile = Get-Content C:\Python27 \Lib\site-packages\salt\utils\gitfs.py; \
131
+ #Modify gitfs fix for incorrect path variables until fix has been upstreamed
132
+ RUN If (!(Test-Path C:/Python35 /Lib/site-packages/salt)) { Copy-Item C:/temp/salt/salt -Destination C:/Python35 /Lib/site-packages/ -Recurse -Force}; \
133
+ $gitfsFile = Get-Content C:\Python35 \Lib\site-packages\salt\utils\gitfs.py; \
64
134
$gitfsFile = $gitfsFile -replace 'files.add\\(add_mountpoint\\(relpath\\(repo_path\\)\\)\\)','files.add("/".join(repo_path.partition(".:\\")[2].split(os.sep)))'; \
65
- Set-Content -Path C:\Python27\Lib\site-packages\salt\utils\gitfs.py -Value $gitfsFile -Force
135
+ Set-Content -Path C:\Python35\Lib\site-packages\salt\utils\gitfs.py -Value $gitfsFile -Force
136
+
66
137
#Get vcredist prereq for hubble
67
- RUN powershell.exe -Command \
68
- $ProgressPreference = 'SilentlyContinue'; \
138
+ RUN $ProgressPreference = 'SilentlyContinue'; \
69
139
Invoke-WebRequest -Uri 'http://repo.saltstack.com/windows/dependencies/64/vcredist_x64_2008_mfc.exe' -OutFile "C:/temp/hubble/pkg/windows/vcredist.exe"
70
- #Create pyionstaller spec and edit it to work with windows
71
- CMD powershell.exe -Command Push-Location C:/temp/hubble; \
140
+
141
+ #Create pyinstaller spec and edit it to work with windows
142
+ CMD Push-Location C:/temp/hubble; \
143
+ # Copy-Item C:/data/hook-salt.py -Destination C:/temp/hubble/pkg/hook-salt.py; \
144
+ # Copy-Item C:/data/salt.grains.core.patch -Destination C:/temp/hubble/pkg/salt.grains.core.patch; \
72
145
pyi-makespec --additional-hooks-dir=$env:_HOOK_DIR ./hubble.py; \
73
146
$specFile = Get-Content 'C:/temp/hubble/hubble.spec'; \
74
- $specFile = $specFile -replace 'a.binaries','a.binaries + [(''libeay32.dll'', ''C:\Python27 \libeay32.dll'', ''BINARY'')]'; \
147
+ $specFile = $specFile -replace 'a.binaries','a.binaries + [(''libeay32.dll'', ''C:\Python35 \libeay32.dll'', ''BINARY'')]'; \
75
148
Set-Content -Path ./hubble.spec -Value $specFile -Force; \
76
149
pyinstaller ./hubble.spec; \
77
150
Pop-Location; \
78
- #Move the hubble.conf, nssm, and osquery to the corerect location
151
+ #Move the hubble.conf, nssm, and osquery to the correct location
79
152
New-Item './hubble/dist/hubble/etc/hubble' -ItemType Directory; \
80
153
New-Item './hubble/dist/hubble/osqueryd' -ItemType Directory; \
81
154
Move-Item hubble.conf -Destination ./hubble/dist/hubble/etc/hubble/; \
@@ -92,6 +165,6 @@ CMD powershell.exe -Command Push-Location C:/temp/hubble; \
92
165
#Build the installer
93
166
Push-Location 'C:/Program Files (x86)/NSIS'; \
94
167
./makensis.exe /DHubbleVersion="$env:HUBBLE_CHECKOUT" 'C:/temp/hubble/pkg/windows/hubble-Setup.nsi'; \
95
- Get-FileHash -Path C:/temp/hubble/pkg/windows/Hubble*exe -Algorithm SHA256 ^ | Out-File C:/temp/hubble/pkg/windows/hubble_windows.sha256; \
168
+ Get-FileHash -Path C:/temp/hubble/pkg/windows/Hubble*exe -Algorithm SHA256 | Out-File C:/temp/hubble/pkg/windows/hubble_windows.sha256; \
96
169
Copy-Item C:/temp/hubble/pkg/windows/Hubble*exe -Destination C:/data/; \
97
- Copy-Item C:/temp/hubble/pkg/windows/hubble_windows.sha256 -Destination C:/data/;
170
+ Copy-Item C:/temp/hubble/pkg/windows/hubble_windows.sha256 -Destination C:/data/;
0 commit comments