forked from edoburu/docker-pgbouncer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
48 lines (41 loc) · 1.8 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
38
39
40
41
42
43
44
45
46
47
48
# Based on:
# https://hub.docker.com/r/edoburu/pgbouncer
# https://github.com/edoburu/docker-pgbouncer
# https://github.com/pgbouncer/pgbouncer
#
FROM alpine:3.19
ARG VERSION=1.22.0
LABEL maintainer="Sergey Grinko <[email protected]>"
# 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 c-ares-dev build-base && \
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 && \
cp pgbouncer /usr/bin && \
mkdir -p /etc/pgbouncer /var/log/pgbouncer /var/run/pgbouncer && \
# entrypoint installs the configuration, allow to write as postgres user
touch /etc/pgbouncer/userlist.txt && \
addgroup -g 998 -S postgres && \
adduser -u 999 -S -D -H -h /var/lib/postgresql -g "Postgres user" -s /bin/sh -G postgres postgres && \
chown -R postgres /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 build-base
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY conf/auth_hba.txt /usr/local/bin/auth_hba.txt.tmpl
COPY conf/pgbouncer.ini /usr/local/bin/pgbouncer.ini.tmpl
RUN chmod +x /usr/local/bin/*.sh
USER postgres
EXPOSE 6432
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["/usr/bin/pgbouncer", "/etc/pgbouncer/pgbouncer.ini"]