-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
58 lines (47 loc) · 1.4 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
49
50
51
52
53
54
55
56
57
58
# docker build -t pgbouncer-docker:1.24.0 --build-arg REPO_TAG=1.24.0 .
# docker run pgbouncer-docker:1.24.0
# This image is made to work with the related Helm chart. It lacks config files on purpose.
# Build stage
FROM alpine:3.21 AS build
ARG REPO_TAG
# Install build dependencies
RUN apk add -U --no-cache \
autoconf \
automake \
libtool \
pandoc \
curl \
gcc \
libc-dev \
libevent \
libevent-dev \
make \
openssl-dev \
pkgconfig \
postgresql-client \
git
# Clone pgbouncer repository
RUN git clone https://github.com/pgbouncer/pgbouncer.git /tmp/pgbouncer
# Checkout the desired version
WORKDIR /tmp/pgbouncer
RUN git checkout "pgbouncer_${REPO_TAG//./_}"
# Initialize and update submodules
RUN git submodule init
RUN git submodule update
# Compile
RUN ./autogen.sh
RUN ./configure --prefix=/usr
RUN make
RUN make install
# Runtime stage
FROM alpine:3.21
# Install runtime dependencies
RUN apk add -U --no-cache busybox libevent postgresql-client
# Copy necessary files from build stage
COPY --from=build /usr/bin/pgbouncer /usr/bin/
# COPY --from=build /tmp/pgbouncer/etc/pgbouncer.ini /etc/pgbouncer/pgbouncer.ini
# Setup directories
RUN mkdir -p /etc/pgbouncer /var/log/pgbouncer /var/run/pgbouncer && chown -R postgres /var/run/pgbouncer /etc/pgbouncer /var/log/pgbouncer
USER postgres
EXPOSE 5432
CMD ["/usr/bin/pgbouncer", "/etc/pgbouncer/pgbouncer.ini"]