This repository was archived by the owner on Apr 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
68 lines (60 loc) · 2.13 KB
/
Dockerfile
File metadata and controls
68 lines (60 loc) · 2.13 KB
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
FROM alpine:3.18
ARG VERSION=1.21.0
# Update and upgrade packages
RUN apk update && apk upgrade
# Install pgbouncer from source
RUN apk add --no-cache --virtual .build-deps \
gcc \
libc-dev \
libevent-dev \
libtool \
udns-dev \
make \
openssl-dev \
pkgconf \
readline-dev \
tar \
wget \
zlib-dev \
&& apk add --no-cache \
bash \
udns \
libevent \
# Install pgbouncer
&& wget -O - "https://pgbouncer.github.io/downloads/files/${VERSION}/pgbouncer-${VERSION}.tar.gz" | tar xz \
&& cd "pgbouncer-${VERSION}" \
&& ./configure --prefix=/usr --with-udns \
&& make \
&& make install \
&& cp pgbouncer /usr/bin \
&& mkdir -p /etc/pgbouncer /var/log/pgbouncer \
&& touch /etc/pgbouncer/userlist.txt \
&& cd .. \
# Cleanup
&& rm -rf "pgbouncer-${VERSION}" \
&& apk del .build-deps \
&& rm -rf /var/cache/apk/*
# Fix permissions
RUN addgroup -S pgbouncer \
&& adduser -S -G pgbouncer pgbouncer \
&& chown -R pgbouncer:pgbouncer /etc/pgbouncer /var/log/pgbouncer
# Add scripts to bin
COPY scripts/* /usr/local/bin/
RUN chmod +x /usr/local/bin/*
# Setup entrypoint
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
# Setup user
USER pgbouncer
EXPOSE 6432
CMD ["/usr/bin/pgbouncer", "/etc/pgbouncer/pgbouncer.ini"]
# Build:
# docker build -t litehex/pgbouncer:1.21.0 .
# Run:
# docker run --rm -p 6432:5432 -e DATABASE_URL="postgres://postgres:securepassword@localhost:5432/db" litehex/pgbouncer:1.21.0
# docker run --rm -p 6432:5432 -e DB_HOST=localhost -e DB_PORT=5432 -e DB_NAME=db -e DB_USER=postgres -e DB_PASSWORD=securepassword litehex/pgbouncer:1.21.0
# docker run --rm -p 6432:5432 -v ./pgbouncer.ini:/etc/pgbouncer/pgbouncer.ini litehex/pgbouncer:1.21.0
# docker run --rm -p 6432:5432 -e DB_DEFAULT="host=localhost port=5432 dbname=db user=postgres password=securepassword" litehex/pgbouncer:1.21.0
# docker run --rm -p 6432:5432 -e ADMIN_USER=superuser -e ADMIN_PASSWORD=securepassword litehex/pgbouncer:1.21.0
# docker run --rm -p 6432:5432 -e USER_BAZ=securepassword litehex/pgbouncer:1.21.0