-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv13.dockerfile
252 lines (240 loc) · 6.15 KB
/
v13.dockerfile
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
FROM alpine:3.12 AS geos
RUN set -x \
&& cd /tmp \
&& wget -qO- https://github.com/libgeos/geos/archive/3.8.1.tar.gz | tar xz \
&& apk add --no-cache --virtual .build-deps \
# --repositories-file /dev/null \
# --repository https://mirror.ps.kz/alpine/v3.12/main \
build-base \
automake \
autoconf \
libtool \
\
&& cd /tmp/geos-* \
&& ./autogen.sh \
&& ./configure \
&& make \
&& make install \
&& apk del .build-deps \
&& rm -r /tmp/*
FROM alpine:3.12 AS proj_gdal
RUN set -x \
&& cd /tmp \
&& wget -qO- https://github.com/OSGeo/PROJ/archive/6.3.2.tar.gz | tar xz \
&& apk add --no-cache --virtual .build-deps \
# --repositories-file /dev/null \
# --repository https://mirror.ps.kz/alpine/v3.12/main \
build-base \
autoconf \
automake \
libtool \
sqlite \
sqlite-dev \
\
&& cd /tmp/PROJ-* \
&& ./autogen.sh \
&& ./configure \
&& make \
&& make install \
&& apk del .build-deps \
&& rm -r /tmp/*
RUN set -x \
&& cd /tmp \
&& wget -qO- https://github.com/OSGeo/gdal/archive/v3.1.4.tar.gz | tar xz \
&& apk add --no-cache --virtual .build-deps \
# --repositories-file /dev/null \
# --repository https://mirror.ps.kz/alpine/v3.12/main \
build-base \
linux-headers \
sqlite-dev \
\
&& cd /tmp/gdal-*/gdal \
&& ./configure --without-libtool --enable-lto \
&& make \
&& make install \
&& apk del .build-deps \
&& rm -r /tmp/*
FROM alpine:3.12 AS postgres_base
RUN set -x \
&& cd /tmp \
&& wget -qO- https://github.com/postgres/postgres/archive/REL_13_0.tar.gz | tar xz \
&& apk add --no-cache --virtual .build-deps \
# --repositories-file /dev/null \
# --repository https://mirror.ps.kz/alpine/v3.12/main \
build-base \
linux-headers \
bison \
flex \
python3-dev \
libxml2-dev \
libxslt-dev \
icu-dev \
openssl-dev \
autoconf \
automake \
libtool \
clang-dev \
llvm10-dev \
\
&& cd /tmp/postgres-* \
&& ./configure \
--prefix=/usr/local \
--without-readline \
--with-libxml \
--with-libxslt \
--with-python \
--with-icu \
--with-openssl \
--with-llvm LLVM_CONFIG=/usr/lib/llvm10/bin/llvm-config \
&& make \
&& make install \
&& cd contrib \
&& make \
&& make install \
&& apk del .build-deps \
&& rm -r /tmp/*
# postgis
COPY --from=geos /usr/local /usr/local
COPY --from=proj_gdal /usr/local /usr/local
RUN set -x \
&& cd /tmp \
&& wget -qO- https://github.com/postgis/postgis/archive/3.0.2.tar.gz | tar xz \
&& apk add --no-cache --virtual .build-deps \
# --repositories-file /dev/null \
# --repository https://mirror.ps.kz/alpine/v3.12/main \
build-base \
autoconf \
automake \
libtool \
# postgis не устанаваливается через CREATE EXTENSION без libxslt-dev
libxslt-dev \
libxml2-dev \
json-c-dev \
protobuf-c-dev \
sqlite-dev \
clang-dev \
llvm10-dev \
\
&& cd /tmp/postgis-* \
&& ./autogen.sh \
&& ./configure \
&& make \
&& make install \
&& make comments-install \
&& apk del .build-deps \
&& rm -r /tmp/*
# pgsql-http
RUN set -x \
&& cd /tmp \
&& wget -qO- https://github.com/pramsey/pgsql-http/archive/v1.3.1.tar.gz | tar xz \
&& apk add --no-cache --virtual .build-deps \
# --repositories-file /dev/null \
# --repository https://mirror.ps.kz/alpine/v3.12/main \
build-base \
curl-dev \
clang \
llvm10-dev \
\
&& cd /tmp/pgsql-http-* \
&& make \
&& make install \
&& apk del .build-deps \
&& rm -r /tmp/*
# pg_cron
RUN set -x \
&& cd /tmp \
&& wget -qO- https://github.com/citusdata/pg_cron/archive/v1.3.0.tar.gz | tar xz \
&& apk add --no-cache --virtual .build-deps \
# --repositories-file /dev/null \
# --repository https://mirror.ps.kz/alpine/v3.12/main \
build-base \
clang \
llvm10-dev \
\
&& cd /tmp/pg_cron-* \
# https://github.com/citusdata/pg_cron/issues/9#issuecomment-269188155
&& sed -e s/-Werror//g -i Makefile \
&& make \
&& make install \
&& apk del .build-deps \
&& rm -r /tmp/*
# pg_json_decoding
RUN set -x \
&& cd /tmp \
&& wget -qO- https://github.com/kagis/pg_json_decoding/archive/v20201030.tar.gz | tar xz \
&& apk add --no-cache --virtual .build-deps \
# --repositories-file /dev/null \
# --repository https://mirror.ps.kz/alpine/v3.12/main \
build-base \
clang \
llvm10-dev \
\
&& cd /tmp/pg_json_decoding-* \
&& make \
&& make install \
&& apk del .build-deps \
&& rm -r /tmp/*
# pg_json_log
RUN set -x \
&& cd /tmp \
&& wget -qO- https://github.com/kagis/pg_json_log/archive/v20201030.tar.gz | tar xz \
&& apk add --no-cache --virtual .build-deps \
# --repositories-file /dev/null \
# --repository https://mirror.ps.kz/alpine/v3.12/main \
build-base \
clang \
openssl-dev \
llvm10-dev \
\
&& cd /tmp/pg_json_log-* \
&& make \
&& make install \
&& apk del .build-deps \
&& rm -r /tmp/*
RUN set -x \
&& apk add --no-cache \
# --repositories-file /dev/null \
# --repository https://mirror.ps.kz/alpine/v3.12/main \
libxml2 \
libxslt \
python3 \
protobuf-c \
json-c \
icu \
openssl \
libcurl \
llvm10 \
&& adduser --uid 70 \
--disabled-password \
--home /var/lib/postgresql \
--no-create-home \
postgres \
&& install -o postgres -g postgres -m 700 -d \
/var/lib/postgresql/data \
/var/lib/postgresql/conf \
/var/lib/postgresql/init
COPY conf /var/lib/postgresql/conf
COPY migrate_and_start.sh /var/lib/postgresql/
FROM scratch
MAINTAINER Vladislav Nezhutin <[email protected]>
COPY --from=postgres_base / /
# FIXME hub.docker.com does not preserve ownership
RUN chown -R postgres:postgres /var/lib/postgresql
WORKDIR /var/lib/postgresql
ENV PGDATA=/var/lib/postgresql/data
USER postgres
EXPOSE 5432
CMD ["/bin/sh", "migrate_and_start.sh"]
ONBUILD COPY . ./
ONBUILD RUN set -x \
&& initdb \
&& rm $PGDATA/postgresql.conf $PGDATA/pg_hba.conf \
&& pg_ctl --silent --wait start -o "-c config_file=conf/postgresql.on_migration.conf" \
&& (cd init && psql -v ON_ERROR_STOP=1 -f init.sql) \
&& find migrations -type f -mindepth 2 -maxdepth 2 -name '*.sql' \
# find latest migration for each db
| sort -r | awk -F/ '{ print $3, $2 }' | uniq -f1 | awk '{ print $2, $1 }' \
| xargs -rn2 printf "ALTER DATABASE \"%s\" SET migration.latest = '%s';\n" \
| psql -v ON_ERROR_STOP=1 \
&& pg_ctl --silent --wait stop
ONBUILD VOLUME $PGDATA