Skip to content

Commit 64dccb7

Browse files
stellirinAdam Farden
authored andcommitted
Update Windows containers to EnterpriseDB
1 parent 9b5b73a commit 64dccb7

File tree

2 files changed

+56
-61
lines changed

2 files changed

+56
-61
lines changed

Dockerfile-windows.template

Lines changed: 37 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,62 @@
11
####
2-
#### Pretty Good Command Line Interface (PGCLI)
2+
#### Download and prepare PostgreSQL for Windows
33
####
4-
FROM microsoft/windowsservercore:1803 as prepare
5-
6-
# Set the variables for PGCLI
7-
ENV PGC_VER %%PGC_VERSION%%
8-
ENV PGC_REPO %%PGC_REPOSITORY%%
4+
FROM mcr.microsoft.com/windows/servercore:1809 as prepare
95

106
##### Use PowerShell for the installation
117
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
128

13-
### Required for PGCLI
14-
ENV PYTHONIOENCODING UTF-8
15-
16-
### Download PGCLI
17-
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; \
18-
Invoke-WebRequest $('{0}/bigsql-pgc-{1}.zip' -f $env:PGC_REPO,$env:PGC_VER) -OutFile 'C:\\BigSQL.zip' ; \
19-
Expand-Archive 'C:\\BigSQL.zip' -DestinationPath 'C:\\' ; \
20-
Remove-Item -Path 'C:\\BigSQL.zip'
21-
22-
### Update PGCLI
23-
RUN Invoke-Expression -Command $('C:\\bigsql\\pgc set GLOBAL REPO {0}' -f$env:PGC_REPO) ; \
24-
Invoke-Expression -Command 'C:\\bigsql\\pgc update --silent' ; \
25-
Remove-Item -Path 'C:\\bigsql\\conf\\pgc.pid'
26-
27-
####
28-
#### Download PostgreSQL
29-
####
30-
FROM prepare as download
31-
32-
### Set the PostgreSQL version we will install
33-
### This is set here to allow us to reuse the abover layers
34-
ENV PGC_DB %%PGC_DB_VERSION%%
35-
36-
### Download PostgreSQL
37-
RUN Invoke-Expression -Command $('C:\\bigsql\\pgc install --silent {0}' -f $env:PGC_DB) ; \
38-
Invoke-Expression -Command 'C:\\bigsql\\pgc clean' ; \
39-
Remove-Item -Path 'C:\\bigsql\\conf\\pgc.pid'
9+
### Download EnterpriseDB and remove cruft
10+
RUN $URL1 = '%%EDB_REPOSITORY%%/postgresql-%%EDB_VERSION%%-windows-x64-binaries.zip' ; \
11+
Invoke-WebRequest -Uri $URL1 -OutFile 'C:\\EnterpriseDB.zip' ; \
12+
Expand-Archive 'C:\\EnterpriseDB.zip' -DestinationPath 'C:\\' ; \
13+
Remove-Item -Path 'C:\\EnterpriseDB.zip' ; \
14+
Remove-Item -Recurse -Force –Path 'C:\\pgsql\\doc' ; \
15+
Remove-Item -Recurse -Force –Path 'C:\\pgsql\\include' ; \
16+
Remove-Item -Recurse -Force –Path 'C:\\pgsql\\pgAdmin*' ; \
17+
Remove-Item -Recurse -Force –Path 'C:\\pgsql\\StackBuilder'
4018

4119
### Make the sample config easier to munge (and "correct by default")
42-
RUN $SAMPLE_FILE = $('C:\\bigsql\\{0}\\share\\postgresql\\postgresql.conf.sample' -f $env:PGC_DB) ; \
20+
RUN $SAMPLE_FILE = 'C:\\pgsql\\share\\postgresql.conf.sample' ; \
4321
$SAMPLE_CONF = Get-Content $SAMPLE_FILE ; \
4422
$SAMPLE_CONF = $SAMPLE_CONF -Replace '#listen_addresses = ''localhost''','listen_addresses = ''*''' ; \
4523
$SAMPLE_CONF | Set-Content $SAMPLE_FILE
4624

25+
# Install Visual C++ Redistributable Package
26+
RUN $URL2 = '%%EDB_VCREDIST%%' ; \
27+
Invoke-WebRequest -Uri $URL2 -OutFile 'C:\\vcredist.exe' ; \
28+
Start-Process 'C:\\vcredist.exe' -Wait \
29+
-ArgumentList @( \
30+
'/install', \
31+
'/passive', \
32+
'/norestart' \
33+
)
34+
35+
# Copy relevant DLLs to PostgreSQL
36+
RUN if (Test-Path 'C:\\windows\\system32\\msvcp120.dll') { \
37+
Write-Host('Visual C++ 2013 Redistributable Package') ; \
38+
Copy-Item 'C:\\windows\\system32\\msvcp120.dll' -Destination 'C:\\pgsql\\bin\\msvcp120.dll' ; \
39+
Copy-Item 'C:\\windows\\system32\\msvcr120.dll' -Destination 'C:\\pgsql\\bin\\msvcr120.dll' ; \
40+
} else { \
41+
Write-Host('Visual C++ 2017 Redistributable Package') ; \
42+
Copy-Item 'C:\\windows\\system32\\vcruntime140.dll' -Destination 'C:\\pgsql\\bin\\vcruntime140.dll' ; \
43+
}
44+
4745
####
4846
#### PostgreSQL on Windows Nano Server
4947
####
50-
FROM microsoft/nanoserver:1803
48+
FROM mcr.microsoft.com/windows/nanoserver:1809
5149

5250
RUN mkdir "C:\\docker-entrypoint-initdb.d"
5351

54-
#### Copy over the PGCLI
55-
COPY --from=prepare "C:\\bigsql" "C:\\bigsql"
56-
57-
### Set the PostgreSQL version we will install
58-
### This is set here to allow us to reuse the abover layers
59-
ENV PGC_DB %%PGC_DB_VERSION%%
60-
61-
### Required for PGCLI
62-
ENV PYTHONIOENCODING="UTF-8" \
63-
PYTHONPATH="C:\\bigsql\\${PGC_DB}\\python\\site-packages" \
64-
GDAL_DATA="C:\\bigsql\\${PGC_DB}\\share\\gdal"
65-
66-
#### Copy over PostgeSQL
67-
COPY --from=download "C:\\bigsql\\${PGC_DB}" "C:\\bigsql\\${PGC_DB}"
52+
#### Copy over PostgreSQL
53+
COPY --from=prepare "C:\\pgsql" "C:\\pgsql"
6854

6955
#### In order to set system PATH, ContainerAdministrator must be used
7056
USER ContainerAdministrator
71-
RUN setx /M PATH "C:\\bigsql\\%PGC_DB%\\bin;%PATH%"
57+
RUN setx /M PATH "C:\\pgsql\\bin;%PATH%"
7258
USER ContainerUser
73-
ENV PGDATA "C:\\bigsql\\data\\${PGC_DB}"
59+
ENV PGDATA "C:\\pgsql\\data"
7460
RUN mkdir "%PGDATA%"
7561

7662
COPY docker-entrypoint.cmd "C:\\"

update.sh

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,32 +104,41 @@ for version in "${versions[@]}"; do
104104
continue
105105
fi
106106

107-
pgcVersion='3.3.7'
108-
pgcRepository='https://s3.amazonaws.com/pgcentral'
107+
edbRepository='https://get.enterprisedb.com/postgresql'
109108

110109
cp docker-entrypoint.cmd "$version/$variant/docker-entrypoint.cmd"
111110
cp Dockerfile-windows.template "$version/$variant/Dockerfile"
112111

113112
case "$version" in
114113
9.4)
115-
pgcDbVersion='pg94'
114+
edbVersion='9.4.22-1'
115+
# Visual C++ 2013 Redistributable Package
116+
edbVCRedist='https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe'
116117
;;
117118
9.5)
118-
pgcDbVersion='pg95'
119+
edbVersion='9.5.17-1'
120+
# Visual C++ 2013 Redistributable Package
121+
edbVCRedist='https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe'
119122
;;
120123
9.6)
121-
pgcDbVersion='pg96'
124+
edbVersion='9.6.13-1'
125+
# Visual C++ 2013 Redistributable Package
126+
edbVCRedist='https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe'
122127
;;
123128
10)
124-
pgcDbVersion='pg10'
129+
edbVersion='10.8-1'
130+
# Visual C++ 2013 Redistributable Package
131+
edbVCRedist='https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe'
125132
;;
126133
11)
127-
pgcDbVersion='pg11'
134+
edbVersion='11.3-1'
135+
# Visual C++ 2017 Redistributable Package
136+
edbVCRedist='https://download.visualstudio.microsoft.com/download/pr/11100230/15ccb3f02745c7b206ad10373cbca89b/VC_redist.x64.exe'
128137
;;
129138
esac
130-
sed -e 's|%%PGC_VERSION%%|'"$pgcVersion"'|g' \
131-
-e 's|%%PGC_REPOSITORY%%|'"$pgcRepository"'|g' \
132-
-e 's|%%PGC_DB_VERSION%%|'"$pgcDbVersion"'|g' \
139+
sed -e 's|%%EDB_VERSION%%|'"$edbVersion"'|g' \
140+
-e 's|%%EDB_REPOSITORY%%|'"$edbRepository"'|g' \
141+
-e 's|%%EDB_VCREDIST%%|'"$edbVCRedist"'|g' \
133142
"Dockerfile-$variant.template" > "$version/$variant/Dockerfile"
134143
done
135144

0 commit comments

Comments
 (0)