-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
184 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
ARG PGTARGET=16 | ||
|
||
### 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 | ||
ENV PG12=12.19 | ||
ENV PG13=13.15 | ||
ENV PG14=14.12 | ||
ENV PG15=15.7 | ||
ENV PG16=16.3 | ||
|
||
# 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 | ||
# We might want to install "alpine-sdk" instead of "build-base", if build-base | ||
# doesn't have everything we need | ||
RUN apt update && \ | ||
apt upgrade && \ | ||
apt install -y build-essential icu-devtools icu-data libicu-dev linux-headers-$(uname -r) liblz4-dev locales tzdata zlib1g-dev libzstd-dev && \ | ||
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}/postgresql-${PG12}.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}/postgresql-${PG13}.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}/postgresql-${PG14}.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}/postgresql-${PG15}.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}/postgresql-${PG16}.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 Alpine 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 icu-data locales tzdata && \ | ||
apt clean | ||
|
||
# Pass the PG build target through to the running image | ||
ENV PGTARGET=${PGTARGET} | ||
|
||
# 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"] | ||
|
||
CMD ["postgres"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters