-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (49 loc) · 1.84 KB
/
Dockerfile
File metadata and controls
61 lines (49 loc) · 1.84 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
FROM alpine:3.19 AS builder
ARG VERSION=1.21.0
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
RUN apk --no-cache --update add \
coreutils \
curl \
build-base \
automake \
libtool \
m4 \
autoconf \
libevent-dev \
openssl-dev \
c-ares-dev
WORKDIR /tmp
RUN curl -sSL https://pgbouncer.github.io/downloads/files/${VERSION}/pgbouncer-${VERSION}.tar.gz | tar xvz
WORKDIR /tmp/pgbouncer-${VERSION}
RUN ./autogen.sh \
&& ./configure --prefix=/usr/local \
&& make \
&& make install
FROM alpine:3.19
LABEL maintainer="Verdigris Technologies <infrastructure@verdigris.co>"
ARG PGBOUNCER_USER=pgbouncer
ARG PGBOUNCER_GROUP=pgbouncer
ARG PGBOUNCER_UID=1001
ARG PGBOUNCER_GID=1001
ARG PGBOUNCER_LOG_DIR=/var/log/pgbouncer
ARG PGBOUNCER_CONFIG_DIR=/etc/pgbouncer
COPY --from=builder /usr/local/bin/pgbouncer /usr/local/bin/pgbouncer
RUN \
# Ensure busybox is upgraded to latest version for security reasons
apk add -U --no-cache --upgrade busybox \
# PgBouncer library dependencies
&& apk add -U --no-cache c-ares dumb-init libevent postgresql15-client \
# Create config and log directories
&& mkdir -p $PGBOUNCER_CONFIG_DIR $PGBOUNCER_LOG_DIR \
&& chmod -R 755 $PGBOUNCER_LOG_DIR \
# Create pgbouncer user and group
&& addgroup -g ${PGBOUNCER_GID} ${PGBOUNCER_GROUP} \
&& adduser -D -u ${PGBOUNCER_UID} -G ${PGBOUNCER_GROUP} ${PGBOUNCER_USER} \
# Update ownership of config and log directories
&& chown -R $PGBOUNCER_USER:$PGBOUNCER_GROUP $PGBOUNCER_CONFIG_DIR \
&& chown -R $PGBOUNCER_USER:$PGBOUNCER_GROUP $PGBOUNCER_LOG_DIR
USER ${PGBOUNCER_UID}:${PGBOUNCER_GID}
COPY default-pgbouncer.ini ${PGBOUNCER_CONFIG_DIR}/pgbouncer.ini
# Rewrite SIGTERM to SIGINT to allow graceful shutdown in PgBouncer
ENTRYPOINT ["/usr/bin/dumb-init", "--rewrite=15:2", "--"]
CMD ["pgbouncer", "${PGBOUNCER_CONFIG_DIR}/pgbouncer.ini"]