Skip to content

Commit 22d91f6

Browse files
devaguptjettero
authored andcommitted
Docker file changes for Windows 4.0
1 parent 2b4bcf6 commit 22d91f6

File tree

3 files changed

+52
-54
lines changed

3 files changed

+52
-54
lines changed

pkg/windows/dockerfile

+24-52
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,14 @@ FROM microsoft/windowsservercore:ltsc2016
1313
ENV PYTHONIOENCODING='UTF-8'
1414
ENV _HOOK_DIR='./pkg/'
1515
ENV NSIS_LOC='C:/Program Files (x86)/NSIS'
16+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
1617
#Create location for build environment and set as working dir
17-
RUN powershell.exe -Command New-Item c:/temp -ItemType Directory; \
18+
RUN New-Item C:/temp -ItemType Directory; \
1819
New-Item C:/data -ItemType Directory;
1920
WORKDIR C:/temp
2021
VOLUME C:/data
21-
#############
22-
# Installing Python 3.5.3
23-
#############
24-
25-
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
2622

23+
#Installing Python 3.5.3
2724
ENV PYTHON_VERSION 3.5.3
2825
ENV PYTHON_RELEASE 3.5.3
2926

@@ -46,7 +43,7 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
4643
'Include_test=0' \
4744
); \
4845
\
49-
# the installer updated PATH, so we should refresh our local value
46+
#the installer updated PATH, so we should refresh our local value
5047
$env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \
5148
\
5249
Write-Host 'Verifying install ...'; \
@@ -84,49 +81,52 @@ RUN Write-Host ('Downloading get-pip.py ({0}) ...' -f $env:PYTHON_GET_PIP_URL);
8481
pip --version; \
8582
\
8683
Write-Host 'Complete.'
87-
8884
#############
8985

90-
ENV CHOCO_URL=https://chocolatey.org/install.ps1
9186
##install Chocolatey, then git and osquery
92-
RUN powershell.exe -Command Set-ExecutionPolicy Bypass -Scope Process -Force; \
87+
ENV CHOCO_URL=https://chocolatey.org/install.ps1
88+
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; \
9389
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'; \
9490
iex ((New-Object System.Net.WebClient).DownloadString("$env:CHOCO_URL"));
95-
RUN powershell.exe -Command choco install git nssm -y;
96-
RUN powershell.exe -Command choco install osquery --version 3.4.0 -y;
91+
RUN choco install git nssm -y;
92+
RUN choco install osquery --version 3.4.0 -y;
9793

9894
#RUN powershell.exe $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
9995
#All the variables used for salt
10096
ENV SALT_SRC_PATH='C:/temp/salt/'
10197
ENV SALT_GIT_URL=https://github.com/saltstack/salt
10298
ENV SALT_CHECKOUT=v2018.11
10399
#Git clone salt and run packages
104-
RUN powershell.exe -Command git clone "$env:SALT_GIT_URL"; \
100+
RUN git clone "$env:SALT_GIT_URL"; \
105101
Push-Location salt/pkg/windows; \
106102
git checkout "$env:SALT_CHECKOUT"; \
107103
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'; \
108-
C:/temp/salt/pkg/windows/build_env_3.ps1 -Silent;
104+
./build_env_3.ps1 -Silent;
109105
#more salt installs
110-
RUN powershell.exe -Command Push-Location salt; \
111-
test-path C:/temp/salt/setup.py; \
112-
python C:/temp/salt/setup.py --quiet install --force; \
106+
RUN Push-Location salt; \
107+
test-path ./setup.py; \
108+
python ./setup.py --quiet install --force; \
113109
pop-location;
114110
#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
111+
ARG HUBBLE_CHECKOUT=4.0-win-release
112+
ARG HUBBLE_GIT_URL=https://github.com/devagupt/hubble.git
117113
ENV HUBBLE_SRC_PATH='C:/temp/hubble/'
118114
#Clone Hubble
119-
RUN powershell.exe -Command git clone "$env:HUBBLE_GIT_URL"; \
115+
RUN git clone "$env:HUBBLE_GIT_URL"; \
120116
Push-Location hubble; \
121117
git checkout "$env:HUBBLE_CHECKOUT"; \
122118
pop-location;
123119

124120
#Copy local files to working directory
125-
COPY pyinstaller-requirements.txt c:/temp/
126121
COPY hubble.conf C:/temp/
127122

123+
RUN Push-Location C:/temp/hubble; \
124+
python setup.py egg_info; \
128125
#Use pip to install hubble dependencies
129-
RUN powershell.exe -Command pip install -r pyinstaller-requirements.txt;
126+
pip install -r hubblestack.egg-info/requires.txt \
127+
-r optional-requirements.txt \
128+
-r package-requirements.txt; \
129+
Pop-Location;
130130

131131
#Modify gitfs fix for incorrect path variables until fix has been upstreamed
132132
RUN If (!(Test-Path C:/Python35/Lib/site-packages/salt)) { Copy-Item C:/temp/salt/salt -Destination C:/Python35/Lib/site-packages/ -Recurse -Force}; \
@@ -138,33 +138,5 @@ RUN If (!(Test-Path C:/Python35/Lib/site-packages/salt)) { Copy-Item C:/temp/sal
138138
RUN $ProgressPreference = 'SilentlyContinue'; \
139139
Invoke-WebRequest -Uri 'http://repo.saltstack.com/windows/dependencies/64/vcredist_x64_2008_mfc.exe' -OutFile "C:/temp/hubble/pkg/windows/vcredist.exe"
140140

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; \
145-
pyi-makespec --additional-hooks-dir=$env:_HOOK_DIR ./hubble.py; \
146-
$specFile = Get-Content 'C:/temp/hubble/hubble.spec'; \
147-
$specFile = $specFile -replace 'a.binaries','a.binaries + [(''libeay32.dll'', ''C:\Python35\libeay32.dll'', ''BINARY'')]'; \
148-
Set-Content -Path ./hubble.spec -Value $specFile -Force; \
149-
pyinstaller ./hubble.spec; \
150-
Pop-Location; \
151-
#Move the hubble.conf, nssm, and osquery to the correct location
152-
New-Item './hubble/dist/hubble/etc/hubble' -ItemType Directory; \
153-
New-Item './hubble/dist/hubble/osqueryd' -ItemType Directory; \
154-
Move-Item hubble.conf -Destination ./hubble/dist/hubble/etc/hubble/; \
155-
Move-Item 'C:/ProgramData/chocolatey/lib/NSSM/tools/nssm.exe' -Destination './hubble/dist/hubble/' -Force; \
156-
If (Test-Path C:/ProgramData/osquery/osqueryi.exe) {Copy-Item 'C:/ProgramData/osquery/osqueryi.exe' -Destination './hubble/dist/hubble/' -Force} \
157-
Else {Copy-Item 'C:/Program Files/osquery/osqueryi.exe' -Destination './hubble/dist/hubble/' -Force}; \
158-
If (Test-Path C:/ProgramData/osquery/osqueryd/osqueryd.exe) {Copy-Item 'C:/ProgramData/osquery/osqueryd/osqueryd.exe' -Destination './hubble/dist/hubble/osqueryd/' -Force} \
159-
Else {Copy-Item 'C:/Program Files/osquery/osqueryd/osqueryd.exe' -Destination './hubble/dist/hubble/osqueryd/' -Force}; \
160-
If (Test-Path C:/data/hubble.conf) {Copy-Item C:/data/hubble.conf -Destination ./hubble/dist/hubble/etc/hubble/ -Force}; \
161-
If (Test-Path C:/data/opt) {Copy-Item C:/data/opt -Destination './hubble/dist/hubble/' -Recurse -Force}; \
162-
Move-Item 'C:/temp/hubble/pkg/windows/osqueryd_safe_permissions.ps1' -Destination './hubble/dist/hubble/' -Force; \
163-
Move-Item 'C:/temp/hubble/pkg/windows/hubble_config_permissions.ps1' -Destination './hubble/dist/hubble/' -Force; \
164-
Move-Item 'C:/temp/hubble/pkg/windows/prerequisites.ps1' -Destination './hubble/dist/hubble/' -Force; \
165-
#Build the installer
166-
Push-Location 'C:/Program Files (x86)/NSIS'; \
167-
./makensis.exe /DHubbleVersion="$env:HUBBLE_CHECKOUT" 'C:/temp/hubble/pkg/windows/hubble-Setup.nsi'; \
168-
Get-FileHash -Path C:/temp/hubble/pkg/windows/Hubble*exe -Algorithm SHA256 | Out-File C:/temp/hubble/pkg/windows/hubble_windows.sha256; \
169-
Copy-Item C:/temp/hubble/pkg/windows/Hubble*exe -Destination C:/data/; \
170-
Copy-Item C:/temp/hubble/pkg/windows/hubble_windows.sha256 -Destination C:/data/;
141+
COPY entrypoint.ps1 C:/temp/
142+
ENTRYPOINT ["powershell.exe", "C:/temp/entrypoint.ps1"]

pkg/windows/entrypoint.ps1

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Push-Location C:/temp/hubble;
2+
#Create pyinstaller spec and edit it to work with windows
3+
pyi-makespec --additional-hooks-dir=$env:_HOOK_DIR ./hubble.py;
4+
$specFile = Get-Content -Path ./hubble.spec;
5+
$specFile = $specFile -replace 'a.binaries','a.binaries + [(''libeay32.dll'', ''C:\Python35\libeay32.dll'', ''BINARY'')]';
6+
Set-Content -Path ./hubble.spec -Value $specFile -Force;
7+
pyinstaller ./hubble.spec;
8+
Pop-Location;
9+
#Move the hubble.conf, nssm, and osquery to the correct location
10+
New-Item './hubble/dist/hubble/etc/hubble' -ItemType Directory;
11+
New-Item './hubble/dist/hubble/osqueryd' -ItemType Directory;
12+
Move-Item hubble.conf -Destination ./hubble/dist/hubble/etc/hubble/;
13+
Move-Item 'C:/ProgramData/chocolatey/lib/NSSM/tools/nssm.exe' -Destination './hubble/dist/hubble/' -Force;
14+
If (Test-Path C:/ProgramData/osquery/osqueryi.exe) {Copy-Item 'C:/ProgramData/osquery/osqueryi.exe' -Destination './hubble/dist/hubble/' -Force}
15+
Else {Copy-Item 'C:/Program Files/osquery/osqueryi.exe' -Destination './hubble/dist/hubble/' -Force};
16+
If (Test-Path C:/ProgramData/osquery/osqueryd/osqueryd.exe) {Copy-Item 'C:/ProgramData/osquery/osqueryd/osqueryd.exe' -Destination './hubble/dist/hubble/osqueryd/' -Force}
17+
Else {Copy-Item 'C:/Program Files/osquery/osqueryd/osqueryd.exe' -Destination './hubble/dist/hubble/osqueryd/' -Force};
18+
If (Test-Path C:/data/hubble.conf) {Copy-Item C:/data/hubble.conf -Destination ./hubble/dist/hubble/etc/hubble/ -Force};
19+
If (Test-Path C:/data/opt) {Copy-Item C:/data/opt -Destination './hubble/dist/hubble/' -Recurse -Force};
20+
Move-Item 'C:/temp/hubble/pkg/windows/osqueryd_safe_permissions.ps1' -Destination './hubble/dist/hubble/' -Force;
21+
Move-Item 'C:/temp/hubble/pkg/windows/hubble_config_permissions.ps1' -Destination './hubble/dist/hubble/' -Force;
22+
Move-Item 'C:/temp/hubble/pkg/windows/prerequisites.ps1' -Destination './hubble/dist/hubble/' -Force;
23+
#Build the installer
24+
Push-Location 'C:/Program Files (x86)/NSIS';
25+
./makensis.exe /DHubbleVersion="$env:HUBBLE_CHECKOUT" 'C:/temp/hubble/pkg/windows/hubble-Setup.nsi';
26+
Get-FileHash -Path C:/temp/hubble/pkg/windows/Hubble*exe -Algorithm SHA256 | Out-File C:/temp/hubble/pkg/windows/hubble_windows.sha256;
27+
Copy-Item C:/temp/hubble/pkg/windows/Hubble*exe -Destination C:/data/;
28+
Copy-Item C:/temp/hubble/pkg/windows/hubble_windows.sha256 -Destination C:/data/;

setup.py

-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343

4444
if platform_name == 'Windows':
4545
dependencies.remove('pyinotify')
46-
dependencies.append('argparse')
47-
dependencies.append('pprint')
4846

4947
with open('hubblestack/__init__.py', 'r') as fd:
5048
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',

0 commit comments

Comments
 (0)