Skip to content

Commit d0bca07

Browse files
authored
chore: remove pgbouncer from docker aio image (supabase#907)
* chore: docker aio - clean fail2ban and gotrue disabled flags/code * chore: remove pgbouncer from docker AIO image.
1 parent aa7cc37 commit d0bca07

File tree

21 files changed

+28
-547
lines changed

21 files changed

+28
-547
lines changed

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,6 @@ RUN sed -i \
927927

928928
# Include schema migrations
929929
COPY migrations/db /docker-entrypoint-initdb.d/
930-
COPY ansible/files/pgbouncer_config/pgbouncer_auth_schema.sql /docker-entrypoint-initdb.d/init-scripts/00-schema.sql
931930
COPY ansible/files/stat_extension.sql /docker-entrypoint-initdb.d/migrations/00-extension.sql
932931

933932
# Add upstream entrypoint script

common.vars.pkr.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
postgres-version = "15.1.1.25"
1+
postgres-version = "15.1.1.26"

docker/all-in-one/Dockerfile

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
ARG postgres_version=15.1.0.148
22

3-
ARG pgbouncer_release=1.18.0
43
ARG postgrest_release=10.1.2
54
ARG gotrue_release=2.130.0
65
ARG adminapi_release=0.62.0
@@ -26,33 +25,6 @@ RUN apt-get update && apt-get install -y \
2625
cmake \
2726
&& rm -rf /var/lib/apt/lists/*
2827

29-
####################
30-
# Install pgbouncer
31-
####################
32-
FROM builder as pgbouncer-source
33-
# Download and extract
34-
ARG pgbouncer_release
35-
ADD "https://www.pgbouncer.org/downloads/files/${pgbouncer_release}/pgbouncer-${pgbouncer_release}.tar.gz" /tmp/pgbouncer.tar.gz
36-
RUN tar -xvf /tmp/pgbouncer.tar.gz -C /tmp && \
37-
rm -rf /tmp/pgbouncer.tar.gz
38-
# Install build dependencies
39-
RUN apt-get update && apt-get install -y \
40-
libevent-dev \
41-
&& rm -rf /var/lib/apt/lists/*
42-
# Build from source
43-
WORKDIR /tmp/pgbouncer-${pgbouncer_release}
44-
RUN ./configure --prefix=/usr/local
45-
RUN make -j$(nproc)
46-
# Create debian package
47-
RUN checkinstall -D --install=no --fstrans=no --backup=no --pakdir=/tmp --requires=libevent-2.1-7 --nodoc
48-
49-
FROM base as pgbouncer
50-
# Download pre-built packages
51-
RUN apt-get update && apt-get install -y --no-install-recommends --download-only \
52-
pgbouncer \
53-
&& rm -rf /var/lib/apt/lists/*
54-
RUN mv /var/cache/apt/archives/*.deb /tmp/
55-
5628
####################
5729
# Install PostgREST
5830
####################
@@ -126,7 +98,6 @@ RUN mv /var/cache/apt/archives/*.deb /tmp/
12698
FROM base as production
12799

128100
# Copy dependencies from previous build stages
129-
COPY --from=pgbouncer /tmp/*.deb /tmp/
130101
COPY --from=vector /tmp/*.deb /tmp/
131102
COPY --from=kong /tmp/*.deb /tmp/
132103
COPY --from=supervisor /tmp/*.deb /tmp/
@@ -177,11 +148,6 @@ COPY docker/all-in-one/etc/sudoers.d /etc/sudoers.d/
177148
# Script for pg_egress_collect
178149
COPY --chown=adminapi:adminapi docker/all-in-one/opt/pg_egress_collect /opt/pg_egress_collect
179150

180-
# Customizations for pgbouncer
181-
COPY docker/all-in-one/etc/pgbouncer /etc/pgbouncer
182-
COPY docker/all-in-one/etc/pgbouncer-custom /etc/pgbouncer-custom
183-
COPY docker/all-in-one/etc/tmpfiles.d /etc/tmpfiles.d
184-
185151
# Customizations for postgres
186152
COPY --chown=postgres:postgres docker/all-in-one/etc/postgresql/pg_hba.conf /etc/postgresql/
187153
COPY --chown=postgres:postgres docker/all-in-one/etc/postgresql/logging.conf /etc/postgresql/
@@ -250,9 +216,6 @@ ENV ADMIN_API_CERT_DIR=/etc/ssl/adminapi
250216
ENV ADMIN_API_PORT=8085
251217
EXPOSE ${ADMIN_API_PORT}
252218

253-
ENV PGBOUNCER_PORT=6543
254-
EXPOSE ${PGBOUNCER_PORT}
255-
256219
ENV PGEXPORTER_PORT=9187
257220
EXPOSE ${PGEXPORTER_PORT}
258221

@@ -262,8 +225,7 @@ ENV VECTOR_API_PORT=9001
262225
RUN useradd --create-home --shell /bin/bash postgrest && \
263226
useradd --create-home --shell /bin/bash gotrue && \
264227
useradd --create-home --shell /bin/bash envoy && \
265-
useradd --create-home --shell /bin/bash pgbouncer -G postgres,ssl-cert && \
266-
useradd --create-home --shell /bin/bash adminapi -G root,envoy,kong,pgbouncer,postgres,postgrest,wal-g && \
228+
useradd --create-home --shell /bin/bash adminapi -G root,envoy,kong,postgres,postgrest,wal-g && \
267229
usermod --append --shell /bin/bash -G postgres vector
268230
RUN mkdir -p /etc/wal-g && \
269231
chown -R adminapi:adminapi /etc/wal-g && \

docker/all-in-one/entrypoint.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ function disable_fail2ban {
8484
sed -i "s/autorestart=.*/autorestart=false/" /etc/supervisor/services/fail2ban.conf
8585
}
8686

87+
function disable_gotrue {
88+
sed -i "s/autostart=.*/autostart=false/" /etc/supervisor/services/gotrue.conf
89+
sed -i "s/autorestart=.*/autorestart=false/" /etc/supervisor/services/gotrue.conf
90+
}
91+
92+
function replace_kong_envoy {
93+
sed -i "s/autostart=.*/autostart=true/" /etc/supervisor/services/envoy.conf
94+
sed -i "s/autostart=.*/autostart=false/" /etc/supervisor/services/kong.conf
95+
sed -i "s/kong/envoy/" /etc/supervisor/services/group.conf
96+
}
97+
8798
function setup_postgres {
8899
tar -xzvf "$INIT_PAYLOAD_PATH" -C / ./etc/postgresql.schema.sql
89100
mv /etc/postgresql.schema.sql /docker-entrypoint-initdb.d/migrations/99-schema.sql
@@ -274,19 +285,18 @@ if [ "${AUTOSHUTDOWN_ENABLED:-}" == "true" ]; then
274285
enable_autoshutdown
275286
fi
276287

288+
277289
if [ "${ENVOY_ENABLED:-}" == "true" ]; then
278-
sed -i "s/autostart=.*/autostart=true/" /etc/supervisor/services/envoy.conf
279-
sed -i "s/autostart=.*/autostart=false/" /etc/supervisor/services/kong.conf
280-
sed -i "s/kong/envoy/" /etc/supervisor/services/group.conf
290+
replace_kong_envoy
281291
fi
282292

283293
if [ "${FAIL2BAN_DISABLED:-}" == "true" ]; then
284294
disable_fail2ban
285295
fi
286296

297+
287298
if [ "${GOTRUE_DISABLED:-}" == "true" ]; then
288-
sed -i "s/autostart=.*/autostart=false/" /etc/supervisor/services/gotrue.conf
289-
sed -i "s/autorestart=.*/autorestart=false/" /etc/supervisor/services/gotrue.conf
299+
disable_gotrue
290300
fi
291301

292302
if [ "${PLATFORM_DEPLOYMENT:-}" == "true" ]; then

docker/all-in-one/etc/adminapi/adminapi.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ node_exporter_additional_args:
1616
# cert_path: /etc/ssl/adminapi/server.crt
1717
# key_path: /etc/ssl/adminapi/server.key
1818
upstream_metrics_refresh_duration: 60s
19-
pgbouncer_endpoints:
20-
- "postgres://pgbouncer:{{ .PgbouncerPassword }}@localhost:6543/pgbouncer"
2119
fail2ban_socket: /var/run/fail2ban/fail2ban.sock
2220
upstream_metrics_sources:
2321
- name: system
@@ -62,7 +60,6 @@ firewall:
6260
- 0.0.0.0/0
6361
filtered_ports:
6462
- 5432
65-
- 6543
6663
unfiltered_ports:
6764
- 80
6865
- 443

docker/all-in-one/etc/fail2ban/filter.d/postgresql.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ ignoreregex = ^.*,.*,.*,.*,"127\.0\.0\.1.*password authentication failed for use
55
^.*,.*,.*,.*,"<HOST>:.*password authentication failed for user ""supabase_auth_admin".*$
66
^.*,.*,.*,.*,"<HOST>:.*password authentication failed for user ""supabase_storage_admin".*$
77
^.*,.*,.*,.*,"<HOST>:.*password authentication failed for user ""authenticator".*$
8-
^.*,.*,.*,.*,"<HOST>:.*password authentication failed for user ""pgbouncer".*$

docker/all-in-one/etc/fail2ban/jail.d/pgbouncer.conf

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)