-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathDockerfile.bookworm
187 lines (143 loc) · 6.95 KB
/
Dockerfile.bookworm
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
ARG PGTARGET=17
### Things we need in all build containers
FROM debian:bookworm AS base-build
# The versions of PostgreSQL to use
ENV PG95=9.5.25
ENV PG96=9.6.24
ENV PG10=10.23
ENV PG11=11.22
# renovate: datasource=repology depName=homebrew/postgresql@12 versioning=loose
ENV PG12_VERSION=12.22
# renovate: datasource=repology depName=homebrew/postgresql@13 versioning=loose
ENV PG13_VERSION=13.18
# renovate: datasource=repology depName=homebrew/postgresql@14 versioning=loose
ENV PG14_VERSION=14.15
# renovate: datasource=repology depName=homebrew/postgresql@15 versioning=loose
ENV PG15_VERSION=15.10
# renovate: datasource=repology depName=homebrew/postgresql@16 versioning=loose
ENV PG16_VERSION=16.6
# Where we'll do all our compiling and similar
ENV BUILD_ROOT=/buildroot
# Make the directory for building, and set it as the default for the following Docker commands
RUN mkdir ${BUILD_ROOT}
WORKDIR ${BUILD_ROOT}
# Install things needed for development
RUN apt update && \
apt upgrade && \
apt install -y build-essential libicu-dev liblz4-dev locales tzdata zlib1g-dev libzstd-dev wget pkg-config && \
apt clean
### PostgreSQL 9.5
FROM base-build AS build-9.5
RUN wget https://ftp.postgresql.org/pub/source/v${PG95}/postgresql-${PG95}.tar.bz2 && \
tar -xf postgresql-9.5*.tar.bz2
RUN cd postgresql-9.5.* && \
./configure --prefix=/usr/local-pg9.5 --with-openssl=no --without-readline --with-system-tzdata=/usr/share/zoneinfo --enable-debug=no CFLAGS="-Os" && \
make -j $(nproc) && \
make install-world && \
rm -rf /usr/local-pg9.5/include
### PostgreSQL 9.6
FROM base-build AS build-9.6
RUN wget https://ftp.postgresql.org/pub/source/v${PG96}/postgresql-${PG96}.tar.bz2 && \
tar -xf postgresql-9.6*.tar.bz2
RUN cd postgresql-9.6.* && \
./configure --prefix=/usr/local-pg9.6 --with-openssl=no --without-readline --with-system-tzdata=/usr/share/zoneinfo --enable-debug=no CFLAGS="-Os" && \
make -j $(nproc) && \
make install-world && \
rm -rf /usr/local-pg9.6/include
### PostgreSQL 10
FROM base-build AS build-10
RUN wget https://ftp.postgresql.org/pub/source/v${PG10}/postgresql-${PG10}.tar.bz2 && \
tar -xf postgresql-10*.tar.bz2
RUN cd postgresql-10.* && \
./configure --prefix=/usr/local-pg10 --with-openssl=no --without-readline --with-icu --with-system-tzdata=/usr/share/zoneinfo --enable-debug=no CFLAGS="-Os" && \
make -j $(nproc) && \
make install-world && \
rm -rf /usr/local-pg10/include
### PostgreSQL 11
FROM base-build AS build-11
RUN wget https://ftp.postgresql.org/pub/source/v${PG11}/postgresql-${PG11}.tar.bz2 && \
tar -xf postgresql-11*.tar.bz2
RUN cd postgresql-11.* && \
./configure --prefix=/usr/local-pg11 --with-openssl=no --without-readline --with-icu --with-system-tzdata=/usr/share/zoneinfo --enable-debug=no CFLAGS="-Os" && \
make -j $(nproc) && \
make install-world && \
rm -rf /usr/local-pg11/include
### PostgreSQL 12
FROM base-build AS build-12
RUN wget https://ftp.postgresql.org/pub/source/v${PG12_VERSION}/postgresql-${PG12_VERSION}.tar.bz2 && \
tar -xf postgresql-12*.tar.bz2
RUN cd postgresql-12.* && \
./configure --prefix=/usr/local-pg12 --with-openssl=no --without-readline --with-icu --with-system-tzdata=/usr/share/zoneinfo --enable-debug=no CFLAGS="-Os" && \
make -j $(nproc) && \
make install-world && \
rm -rf /usr/local-pg12/include
### PostgreSQL 13
FROM base-build AS build-13
RUN wget https://ftp.postgresql.org/pub/source/v${PG13_VERSION}/postgresql-${PG13_VERSION}.tar.bz2 && \
tar -xf postgresql-13*.tar.bz2
RUN cd postgresql-13.* && \
./configure --prefix=/usr/local-pg13 --with-openssl=no --without-readline --with-icu --with-system-tzdata=/usr/share/zoneinfo --enable-debug=no CFLAGS="-Os" && \
make -j $(nproc) && \
make install-world && \
rm -rf /usr/local-pg13/include
### PostgreSQL 14
FROM base-build AS build-14
RUN wget https://ftp.postgresql.org/pub/source/v${PG14_VERSION}/postgresql-${PG14_VERSION}.tar.bz2 && \
tar -xf postgresql-14*.tar.bz2
RUN cd postgresql-14.* && \
./configure --prefix=/usr/local-pg14 --with-openssl=no --without-readline --with-icu --with-lz4 --with-system-tzdata=/usr/share/zoneinfo --enable-debug=no CFLAGS="-Os" && \
make -j $(nproc) && \
make install-world && \
rm -rf /usr/local-pg14/include
### PostgreSQL 15
FROM base-build AS build-15
RUN wget https://ftp.postgresql.org/pub/source/v${PG15_VERSION}/postgresql-${PG15_VERSION}.tar.bz2 && \
tar -xf postgresql-15*.tar.bz2
RUN cd postgresql-15.* && \
./configure --prefix=/usr/local-pg15 --with-openssl=no --without-readline --with-icu --with-lz4 --with-system-tzdata=/usr/share/zoneinfo --enable-debug=no CFLAGS="-Os" && \
make -j $(nproc) && \
make install-world && \
rm -rf /usr/local-pg15/include
### PostgreSQL 16
FROM base-build AS build-16
RUN wget https://ftp.postgresql.org/pub/source/v${PG16_VERSION}/postgresql-${PG16_VERSION}.tar.gz && \
tar -xf postgresql-16*.tar.gz
RUN cd postgresql-16.* && \
./configure --prefix=/usr/local-pg16 --with-openssl=no --without-readline --with-icu --with-lz4 --with-system-tzdata=/usr/share/zoneinfo --enable-debug=no CFLAGS="-Os" && \
make -j $(nproc) && \
make install-world && \
rm -rf /usr/local-pg16/include
# Use the PostgreSQL Bookworm image as our output image base
FROM postgres:${PGTARGET}-bookworm
# We need to define this here, to make the above PGTARGET available after the FROM
ARG PGTARGET
# Copy across our compiled files
COPY --from=build-9.5 /usr/local-pg9.5 /usr/local-pg9.5
COPY --from=build-9.6 /usr/local-pg9.6 /usr/local-pg9.6
COPY --from=build-10 /usr/local-pg10 /usr/local-pg10
COPY --from=build-11 /usr/local-pg11 /usr/local-pg11
COPY --from=build-12 /usr/local-pg12 /usr/local-pg12
COPY --from=build-13 /usr/local-pg13 /usr/local-pg13
COPY --from=build-14 /usr/local-pg14 /usr/local-pg14
COPY --from=build-15 /usr/local-pg15 /usr/local-pg15
COPY --from=build-16 /usr/local-pg16 /usr/local-pg16
# Remove any left over PG directory stubs. Doesn't help with image size, just with clarity on what's in the image.
RUN if [ "${PGTARGET}" -eq 12 ]; then rm -rf /usr/local-pg12 /usr/local-pg13 /usr/local-pg14 /usr/local-pg15 /usr/local-pg16; fi
RUN if [ "${PGTARGET}" -eq 13 ]; then rm -rf /usr/local-pg13 /usr/local-pg14 /usr/local-pg15 /usr/local-pg16; fi
RUN if [ "${PGTARGET}" -eq 14 ]; then rm -rf /usr/local-pg14 /usr/local-pg15 /usr/local-pg16; fi
RUN if [ "${PGTARGET}" -eq 15 ]; then rm -rf /usr/local-pg15 /usr/local-pg16; fi
RUN if [ "${PGTARGET}" -eq 16 ]; then rm -rf /usr/local-pg16; fi
# Install locale
RUN apt update && \
apt install -y icu-devtools locales tzdata && \
apt clean
# Pass the PG build target through to the running image
ENV PGTARGET=${PGTARGET}
# Copy across the post-upgrade shell script
COPY pgautoupgrade-postupgrade.sh pgautoupgrade-healthcheck.sh /usr/local/bin/
# Set up the script run by the container when it starts
WORKDIR /var/lib/postgresql
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
HEALTHCHECK CMD /usr/local/bin/pgautoupgrade-healthcheck.sh
CMD ["postgres"]