forked from edoburu/docker-pgbouncer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
37 lines (35 loc) · 1.53 KB
/
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
FROM alpine:3.18
ARG VERSION=1.21.0
# Inspiration from https://github.com/gmr/alpine-pgbouncer/blob/master/Dockerfile
# hadolint ignore=DL3003,DL3018
RUN \
# security
apk add -U --no-cache --upgrade busybox && \
# Download
apk add -U --no-cache autoconf autoconf-doc automake udns udns-dev curl gcc libc-dev libevent libevent-dev libtool make openssl-dev pkgconfig postgresql-client && \
curl -o /tmp/pgbouncer-$VERSION.tar.gz -L https://pgbouncer.github.io/downloads/files/$VERSION/pgbouncer-$VERSION.tar.gz && \
cd /tmp && \
# Unpack, compile
tar xvfz /tmp/pgbouncer-$VERSION.tar.gz && \
cd pgbouncer-$VERSION && \
./configure --prefix=/usr --with-udns && \
make && \
# Manual install
cp pgbouncer /usr/bin && \
mkdir -p /etc/pgbouncer /var/log/pgbouncer /var/run/pgbouncer && \
# entrypoint installs the configuration, allow to write as postgres user
cp etc/pgbouncer.ini /etc/pgbouncer/pgbouncer.ini.example && \
cp etc/userlist.txt /etc/pgbouncer/userlist.txt.example && \
touch /etc/pgbouncer/userlist.txt && \
chown -R postgres /var/log/pgbouncer /var/run/pgbouncer /etc/pgbouncer && \
# Cleanup
cd /tmp && \
rm -rf /tmp/pgbouncer* && \
apk del --purge autoconf autoconf-doc automake udns-dev curl gcc libc-dev libevent-dev libtool make openssl-dev pkgconfig
COPY entrypoint.sh /entrypoint.sh
COPY pgbouncer.ini /etc/pgbouncer/pgbouncer.ini
RUN chown -c postgres /etc/pgbouncer/pgbouncer.ini
USER postgres
EXPOSE 5432
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/usr/bin/pgbouncer", "/etc/pgbouncer/pgbouncer.ini"]