-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathDockerfile-windows.template
66 lines (55 loc) · 2.59 KB
/
Dockerfile-windows.template
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
####
#### Download and prepare PostgreSQL for Windows
####
FROM mcr.microsoft.com/windows/servercore:1809 as prepare
##### Use PowerShell for the installation
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
### Download EnterpriseDB and remove cruft
RUN $URL1 = '%%EDB_REPOSITORY%%/postgresql-%%EDB_VERSION%%-windows-x64-binaries.zip' ; \
Invoke-WebRequest -Uri $URL1 -OutFile 'C:\\EnterpriseDB.zip' ; \
Expand-Archive 'C:\\EnterpriseDB.zip' -DestinationPath 'C:\\' ; \
Remove-Item -Path 'C:\\EnterpriseDB.zip' ; \
Remove-Item -Recurse -Force –Path 'C:\\pgsql\\doc' ; \
Remove-Item -Recurse -Force –Path 'C:\\pgsql\\include' ; \
Remove-Item -Recurse -Force –Path 'C:\\pgsql\\pgAdmin*' ; \
Remove-Item -Recurse -Force –Path 'C:\\pgsql\\StackBuilder'
### Make the sample config easier to munge (and "correct by default")
RUN $SAMPLE_FILE = 'C:\\pgsql\\share\\postgresql.conf.sample' ; \
$SAMPLE_CONF = Get-Content $SAMPLE_FILE ; \
$SAMPLE_CONF = $SAMPLE_CONF -Replace '#listen_addresses = ''localhost''','listen_addresses = ''*''' ; \
$SAMPLE_CONF | Set-Content $SAMPLE_FILE
# Install Visual C++ Redistributable Package
RUN $URL2 = '%%EDB_VCREDIST%%' ; \
Invoke-WebRequest -Uri $URL2 -OutFile 'C:\\vcredist.exe' ; \
Start-Process 'C:\\vcredist.exe' -Wait \
-ArgumentList @( \
'/install', \
'/passive', \
'/norestart' \
)
# Copy relevant DLLs to PostgreSQL
RUN if (Test-Path 'C:\\windows\\system32\\msvcp120.dll') { \
Write-Host('Visual C++ 2013 Redistributable Package') ; \
Copy-Item 'C:\\windows\\system32\\msvcp120.dll' -Destination 'C:\\pgsql\\bin\\msvcp120.dll' ; \
Copy-Item 'C:\\windows\\system32\\msvcr120.dll' -Destination 'C:\\pgsql\\bin\\msvcr120.dll' ; \
} else { \
Write-Host('Visual C++ 2017 Redistributable Package') ; \
Copy-Item 'C:\\windows\\system32\\vcruntime140.dll' -Destination 'C:\\pgsql\\bin\\vcruntime140.dll' ; \
}
####
#### PostgreSQL on Windows Nano Server
####
FROM mcr.microsoft.com/windows/nanoserver:1809
RUN mkdir "C:\\docker-entrypoint-initdb.d"
#### Copy over PostgreSQL
COPY --from=prepare "C:\\pgsql" "C:\\pgsql"
#### In order to set system PATH, ContainerAdministrator must be used
USER ContainerAdministrator
RUN setx /M PATH "C:\\pgsql\\bin;%PATH%"
USER ContainerUser
ENV PGDATA "C:\\pgsql\\data"
RUN mkdir "%PGDATA%"
COPY docker-entrypoint.cmd "C:\\"
ENTRYPOINT ["C:\\docker-entrypoint.cmd"]
EXPOSE 5432
CMD ["postgres"]