forked from CircleCI-Public/cimg-postgres
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.template
121 lines (108 loc) · 3.49 KB
/
Dockerfile.template
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
# vim:set ft=dockerfile:
# Do not edit individual Dockerfiles manually. Instead, please make changes to the Dockerfile.template, which will be used by the build script to generate Dockerfiles.
# By policy, the base image tag should be a quarterly tag unless there's a
# specific reason to use a different one. This means January, April, July, or
# October.
FROM cimg/%%PARENT%%:2024.02
LABEL maintainer="CircleCI Execution Team <[email protected]>"
ENV PG_VER=%%VERSION_FULL%%
ENV PG_MAJOR=%%VERSION_MAJOR%%
ENV POSTGRES_HOST_AUTH_METHOD=trust
ENV PATH=/usr/lib/postgresql/$PG_MAJOR/bin:$PATH
ENV PGDATA=/var/lib/postgresql/data
ENV POSTGRES_DB=circle_test
ENV PGTAP_VERSION=1.2.0
ENV PARTMAN_VERSION=4.7.2
USER root
RUN BUILD_DEPS="bison \
build-essential \
clang \
dirmngr \
flex \
gnupg \
libclang-dev \
libicu-dev \
libipc-run-perl \
libkrb5-dev \
libldap2-dev \
liblz4-dev \
libpam-dev \
libperl-dev \
libpython3-dev \
libreadline-dev \
libssl-dev \
libxml2-dev \
libxslt1-dev \
llvm \
llvm-dev \
postgresql-server-dev-all \
python3-dev \
tcl-dev \
uuid-dev" && \
apt-get update && apt-get install -y --no-install-recommends \
gosu \
locales \
$BUILD_DEPS \
&& \
rm -rf /var/lib/apt/lists/* && \
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 && \
curl -sSL "https://ftp.postgresql.org/pub/source/v${PG_VER}/postgresql-${PG_VER}.tar.gz" | tar -xz && \
cd postgresql-${PG_VER} && \
./configure \
--prefix=/usr/lib/postgresql/$PG_MAJOR \
--enable-integer-datetimes \
--enable-thread-safety \
--enable-tap-tests \
--with-uuid=e2fs \
--with-gnu-ld \
--with-pgport=5432 \
--with-system-tzdata=/usr/share/zoneinfo \
--with-includes=/usr/local/include \
--with-libraries=/usr/local/lib \
--with-krb5 \
--with-gssapi \
--with-ldap \
--with-pam \
--with-tcl \
--with-perl \
--with-python \
--with-openssl \
--with-libxml \
--with-libxslt \
--with-icu \
--with-llvm \
--with-lz4 \
&& \
# we can change from world to world-bin in newer releases
make -j $(nproc) world && \
make install-world && \
cd .. && rm -rf postgresql-${PG_VER} \
&& \
git clone --depth 1 https://github.com/citusdata/pg_cron.git /pg_cron && \
cd /pg_cron && make && PATH=$PATH make install && \
rm -rf /pg_cron && \
apt-get purge -y --auto-remove $BUILD_DEPS
RUN curl -sSL "https://github.com/pgpartman/pg_partman/archive/v${PARTMAN_VERSION}.tar.gz" | tar -xz && \
cd pg_partman-${PARTMAN_VERSION} && make NO_BGW=1 install && \
cd .. && rm -rf pg_partman-${PARTMAN_VERSION}
# Install pgTAP & pg_prove utility.
RUN git clone --depth 1 -b "v$PGTAP_VERSION" https://github.com/theory/pgtap.git /pgtap && \
cd /pgtap && make -j $(nproc) && make install && \
curl -sL https://cpanmin.us | perl - App::cpanminus && \
cpanm -n TAP::Parser::SourceHandler::pgTAP && \
rm -rf /pgtap
RUN mkdir /docker-entrypoint-initdb.d
COPY pg_cron.sh /docker-entrypoint-initdb.d/
COPY custom-postgresql.conf /etc/postgresql/custom-postgresql.conf
COPY docker-entrypoint.sh /usr/local/bin/
# Backwards compatibility
RUN ln -s usr/local/bin/docker-entrypoint.sh /
RUN chmod +x /usr/local/bin/docker-entrypoint.sh /docker-entrypoint-initdb.d/pg_cron.sh && \
mkdir -p /var/lib/postgresql && \
chown -R postgres:postgres /var/lib/postgresql && \
chown -R postgres:postgres /etc/postgresql && \
chown -R postgres:postgres /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]
STOPSIGNAL SIGINT
EXPOSE 5432
CMD ["postgres"]