forked from stellirin/docker-postgres-windows
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.cmd
194 lines (170 loc) · 4.91 KB
/
build.cmd
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
@echo off
SETLOCAL EnableDelayedExpansion
:: Usage: build.cmd pgValue winValue
:: pgValue: specifies a specific PostgreSQL version. One of:
:: pg94
:: pg95
:: pg96
:: pg10
:: pg11
:: pg12
:: pg15
:: winValue: specifies a specific Windows base image. One of:
:: win1607
:: win1709
:: win1803
:: win1809
:: win1903
:: win1909
:: win20H2
:: If no values are specified then all images are built.
:: Batch file has no concept of a function, only goto
goto :start
:: CALL :image_build TAGNAME COREVER NANOVER EDBVER
:image_build
set winVer=%~1
set edbVer=%~2
set pgVer=%edbVer:~0,-2%
:: Modern version numbers: 10, 11, 12 etc.
:: legacy version numbers: 9.4, 9.5, 9.6
for /f "tokens=1,2,3 delims=." %%a in ("%pgVer%") do (
if [%%c] == [] (
set tagVer=%%a
)
if NOT [%%c] == [] (
set tagVer=%%a.%%b
)
)
docker build ^
--build-arg WIN_VER=%winVer% ^
--build-arg EDB_VER=%edbVer% ^
--tag %repoName%:%pgVer%-%winVer% ^
--tag %repoName%:%tagVer%-%winVer% ^
.
docker push %repoName%:%pgVer%-%winVer%
docker push %repoName%:%tagVer%-%winVer%
EXIT /B 0
:: CALL :postgres_build EDBVER
:postgres_build
set edbVer=%~1
if [%win1809%] == [true] (
call :image_build 1809 %edbVer%
)
if [%win1903%] == [true] (
call :image_build 1903 %edbVer%
)
if [%win1909%] == [true] (
call :image_build 1909 %edbVer%
)
if [%win20H2%] == [true] (
call :image_build 20H2 %edbVer%
)
EXIT /B 0
:: call :manifest_build MANVER
:manifest_build
set manVer=%~1
docker manifest create --amend ^
%repoName%:%manVer% ^
%repoName%:%manVer%-1809 ^
%repoName%:%manVer%-1903 ^
%repoName%:%manVer%-1909 ^
%repoName%:%manVer%-20H2
docker manifest push %repoName%:%manVer%
EXIT /B 0
:: ------------------------------------------------------------
:: ------------------------------------------------------------
:: ------------------------------------------------------------
:start
set repoName=marekistvanekmycronic/postgres-windows
:: Build versions of PostgreSQL supported by EnterpriseDB
set pgValue=%~1
if [%pgValue%] == [] (
echo Building all PostgreSQL versions
set pg94=true
set pg95=true
set pg96=true
set pg10=true
set pg11=true
set pg12=true
set pg15=true
)
if NOT [%pgValue%] == [] (
set %pgValue%=true
)
:: Build versions based on various Windows 10 base images
set winValue=%~2
if [%winValue%] == [] (
set win1809=true
set win1903=true
set win1909=true
set win20H2=true
)
if NOT [%winValue%] == [] (
set %winValue%=true
)
::docker pull mcr.microsoft.com/windows/servercore:1809
::docker pull mcr.microsoft.com/windows/servercore:1903
::docker pull mcr.microsoft.com/windows/servercore:1909
::docker pull mcr.microsoft.com/windows/nanoserver:1809
::docker pull mcr.microsoft.com/windows/nanoserver:1903
::docker pull mcr.microsoft.com/windows/nanoserver:1909
:: ------------------------------------------------------------
:: ------------------------------------------------------------
:: ------------------------------------------------------------
:: https://www.enterprisedb.com/download-postgresql-binaries
:: PostgreSQL 9.4
if [%pg94%] == [true] (
call :postgres_build "9.4.24-2"
if [%winValue%] == [] (
call :manifest_build "9.4"
call :manifest_build "9.4.24"
)
)
:: PostgreSQL 9.5
if [%pg95%] == [true] (
call :postgres_build "9.15.19-2"
if [%winValue%] == [] (
call :manifest_build "9.5"
call :manifest_build "9.5.19"
)
)
:: PostgreSQL 9.6
if [%pg96%] == [true] (
call :postgres_build "9.6.15-2"
if [%winValue%] == [] (
call :manifest_build "9.6"
call :manifest_build "9.6.15"
)
)
:: PostgreSQL 10
if [%pg10%] == [true] (
call :postgres_build "10.10-2"
if [%winValue%] == [] (
call :manifest_build "10"
call :manifest_build "10.10"
)
)
:: PostgreSQL 11
if [%pg11%] == [true] (
call :postgres_build "11.5-2"
if [%winValue%] == [] (
call :manifest_build "11"
call :manifest_build "11.5"
)
)
:: PostgreSQL 12
if [%pg12%] == [true] (
call :postgres_build "12.0-1"
if [%winValue%] == [] (
call :manifest_build "12"
call :manifest_build "12.0"
)
)
:: PostgreSQL 15
if [%pg15%] == [true] (
call :postgres_build "15.10-3"
if [%winValue%] == [] (
call :manifest_build "15"
call :manifest_build "15.10"
)
)