-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
209 lines (184 loc) · 6.46 KB
/
Dockerfile
File metadata and controls
209 lines (184 loc) · 6.46 KB
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
FROM docker.io/bitnami/python:3.9-prod AS python
RUN mkdir -p /var/lib/apt/lists/partial && \
install_packages wget \
gcc \
git \
sed \
make \
build-essential \
procps \
sysstat \
libldap2-dev \
# libpython-dev \
libreadline-dev \
libssl-dev \
bison \
flex \
libghc-zlib-dev \
libcrypto++-dev \
libxml2-dev \
libxslt1-dev \
bzip2 \
unzip \
libgeos-dev \
libproj-dev \
libgdal-dev \
zlib1g-dev \
libncurses5-dev \
libgdbm-dev \
libnss3-dev \
libsqlite3-dev \
libffi-dev \
libbz2-dev \
libprotobuf-c1 \
libprotobuf-c-dev \
protobuf-c-compiler
ENV POSTGRES_VERSION 13.4
RUN wget -O /tmp/postgres.tar.gz "https://ftp.postgresql.org/pub/source/v${POSTGRES_VERSION}/postgresql-${POSTGRES_VERSION}.tar.gz"
RUN cd /tmp \
&& tar zxf postgres.tar.gz \
&& cd postgresql-${POSTGRES_VERSION} \
# && cd src/pl/plpython \
&& export C_INCLUDE_PATH=/opt/bitnami/postgresql/include/:/opt/bitnami/common/include/ \
&& export LIBRARY_PATH=/opt/bitnami/postgresql/lib/:/opt/bitnami/common/lib/ \
&& export LD_LIBRARY_PATH=/opt/bitnami/postgresql/lib/:/opt/bitnami/common/lib/ \
&& ./configure \
--enable-integer-datetimes \
--enable-thread-safety \
# --with-pgport=5432 \
# --prefix=/opt/bitnami/postgresql \
--with-ldap \
--with-python \
--with-openssl \
--with-libxml \
--with-libxslt \
# --datadir=/bitnami/postgresql/data \
# --sysconfdir=/bitnami/postgresql/conf \
# --with-gssapi \
# --with-perl \
# --with-tcl \
# --with-pam \
# --with-system-tzdata=/usr/share/zoneinfo \
# --with-uuid=e2fs \
--with-icu \
# --with-systemd \
# --with-llvm \
# --enable-nls \
&& make -j $(nproc) world-bin \
&& make install-world-bin
# FROM postgres:13.4 AS extensions
# RUN \
# apt-get update && \
# apt-get upgrade -y && \
# apt-get install -y --no-install-recommends \
# postgresql-contrib \
# postgresql-plpython3-13 \
# postgresql-plpython3-13-dbgsym
FROM bitnami/postgresql:13 AS plv8
USER root
ENV PLV8_VERSION=3.0.0
ENV PG_MAJOR 13
RUN mkdir -p /var/lib/apt/lists/partial
RUN buildDependencies="build-essential \
ca-certificates \
curl \
git \
gnupg2 \
lsb-release \
apt-utils \
python \
python3 \
gpp \
cpp \
pkg-config \
apt-transport-https \
cmake \
libc++-dev \
libc++abi-dev \
libpq-dev \
libglib2.0-dev \
postgresql-server-dev-$PG_MAJOR" \
&& runtimeDependencies="libc++1 \
libtinfo5 \
libc++abi1" \
&& apt-get update \
&& apt-get install lsb-release gnupg2 -y \
&& curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo "deb http://apt.postgresql.org/pub/repos/apt `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list \
&& apt-get update \
&& apt-get install libpq-dev cmake -y \
&& apt-get update \
&& apt-get install -y --no-install-recommends ${buildDependencies} ${runtimeDependencies} \
&& mkdir -p /tmp/build \
&& curl -o /tmp/build/v$PLV8_VERSION.tar.gz -SL "https://github.com/plv8/plv8/archive/v${PLV8_VERSION}.tar.gz" \
&& cd /tmp/build \
# && echo $PLV8_SHASUM v$PLV8_VERSION.tar.gz | sha256sum -c \
&& tar -xzf /tmp/build/v$PLV8_VERSION.tar.gz -C /tmp/build/ \
&& cd /tmp/build/plv8-$PLV8_VERSION \
&& export C_INCLUDE_PATH=/opt/bitnami/postgresql/include/:/opt/bitnami/common/include/ \
&& export LIBRARY_PATH=/opt/bitnami/postgresql/lib/:/opt/bitnami/common/lib/ \
&& export LD_LIBRARY_PATH=/opt/bitnami/postgresql/lib/:/opt/bitnami/common/lib/ \
&& make -j $(nproc) PG_CONFIG=/opt/bitnami/postgresql/bin/pg_config static \
&& make install \
&& strip /opt/bitnami/postgresql/lib/plv8-${PLV8_VERSION}.so \
&& rm -rf /root/.vpython_cipd_cache /root/.vpython-root \
&& apt-get clean \
&& apt-get remove -y ${buildDependencies} \
&& apt-get autoremove -y \
&& rm -rf /tmp/build /var/lib/apt/lists/*
FROM bitnami/postgresql:13
USER root
## Copy python files into the final image
COPY --from=python /opt/bitnami/ /opt/bitnami/
ENV PATH="/opt/bitnami/python/bin:$PATH"
## Copy plpython related files into the final image
COPY --from=python /usr/local/pgsql/share/extension/*python* /opt/bitnami/postgresql/share/extension/
COPY --from=python /usr/local/pgsql/lib/*python* /opt/bitnami/postgresql/lib/
## Copy the plv8 extension and lib into the final image
COPY --from=plv8 /opt/bitnami/postgresql/share/extension/plv8* /opt/bitnami/postgresql/share/extension/
COPY --from=plv8 /opt/bitnami/postgresql/share/extension/plcoffee* /opt/bitnami/postgresql/share/extension/
COPY --from=plv8 /opt/bitnami/postgresql/share/extension/plls* /opt/bitnami/postgresql/share/extension/
COPY --from=plv8 /opt/bitnami/postgresql/lib/plv8* /opt/bitnami/postgresql/lib/
RUN mkdir -p /var/lib/apt/lists/partial \
## runtime dependencies for plv8
&& runtimeDependencies="libc++1 \
libtinfo5 \
libc++abi1" \
&& install_packages ${runtimeDependencies} wget git gcc make build-essential libxml2-dev libgeos-dev libproj-dev \
libgdal-dev \
libprotobuf-c1 libprotobuf-c-dev protobuf-c-compiler
ENV POSTGIS_VERSION 3.1.4
## Download Postgis
RUN wget -O /tmp/postgis.tar.gz "https://download.osgeo.org/postgis/source/postgis-$POSTGIS_VERSION.tar.gz"
## build and Install Postgis
RUN cd /tmp \
&& export C_INCLUDE_PATH=/opt/bitnami/postgresql/include/:/opt/bitnami/common/include/ \
&& export LIBRARY_PATH=/opt/bitnami/postgresql/lib/:/opt/bitnami/common/lib/ \
&& export LD_LIBRARY_PATH=/opt/bitnami/postgresql/lib/:/opt/bitnami/common/lib/ \
&& tar zxf postgis.tar.gz \
&& cd postgis-$POSTGIS_VERSION \
&& ./configure --with-pgconfig=/opt/bitnami/postgresql/bin/pg_config \
&& make \
&& make install \
&& cd ~ \
&& rm /tmp/postgis.tar.gz \
&& rm -rf /tmp/postgis-$POSTGIS_VERSION
## git clone pgjwt repo, make and install
RUN cd /tmp \
&& git clone https://github.com.cnpmjs.org/michelp/pgjwt.git \
&& cd pgjwt \
&& sed 's;PG_CONFIG = pg_config;PG_CONFIG = \/opt\/bitnami\/postgresql\/bin\/pg_config;g' Makefile \
&& export C_INCLUDE_PATH=/opt/bitnami/postgresql/include/:/opt/bitnami/common/include/ \
&& export LIBRARY_PATH=/opt/bitnami/postgresql/lib/:/opt/bitnami/common/lib/ \
&& export LD_LIBRARY_PATH=/opt/bitnami/postgresql/lib/:/opt/bitnami/common/lib/ \
&& make \
&& make install \
&& cd ~ \
&& rm -rf /tmp/pgjwt
RUN apt-get update && apt-get purge --auto-remove -y \
wget git gcc make build-essential libxml2-dev libgeos-dev libproj-dev \
libgdal-dev \
libprotobuf-c-dev protobuf-c-compiler \
&& apt-get install -y libxml2 \
&& rm -rf /var/lib/apt/lists/*
USER 1001