|
1 | 1 | #### |
2 | | -#### Pretty Good Command Line Interface (PGCLI) |
| 2 | +#### Download and prepare PostgreSQL for Windows |
3 | 3 | #### |
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 |
9 | 5 |
|
10 | 6 | ##### Use PowerShell for the installation |
11 | 7 | SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] |
12 | 8 |
|
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' |
40 | 18 |
|
41 | 19 | ### 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' ; \ |
43 | 21 | $SAMPLE_CONF = Get-Content $SAMPLE_FILE ; \ |
44 | 22 | $SAMPLE_CONF = $SAMPLE_CONF -Replace '#listen_addresses = ''localhost''','listen_addresses = ''*''' ; \ |
45 | 23 | $SAMPLE_CONF | Set-Content $SAMPLE_FILE |
46 | 24 |
|
| 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 | + |
47 | 45 | #### |
48 | 46 | #### PostgreSQL on Windows Nano Server |
49 | 47 | #### |
50 | | -FROM microsoft/nanoserver:1803 |
| 48 | +FROM mcr.microsoft.com/windows/nanoserver:1809 |
51 | 49 |
|
52 | 50 | RUN mkdir "C:\\docker-entrypoint-initdb.d" |
53 | 51 |
|
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" |
68 | 54 |
|
69 | 55 | #### In order to set system PATH, ContainerAdministrator must be used |
70 | 56 | USER ContainerAdministrator |
71 | | -RUN setx /M PATH "C:\\bigsql\\%PGC_DB%\\bin;%PATH%" |
| 57 | +RUN setx /M PATH "C:\\pgsql\\bin;%PATH%" |
72 | 58 | USER ContainerUser |
73 | | -ENV PGDATA "C:\\bigsql\\data\\${PGC_DB}" |
| 59 | +ENV PGDATA "C:\\pgsql\\data" |
74 | 60 | RUN mkdir "%PGDATA%" |
75 | 61 |
|
76 | 62 | COPY docker-entrypoint.cmd "C:\\" |
|
0 commit comments