Skip to content

Commit

Permalink
feat(pgbouncer): add image
Browse files Browse the repository at this point in the history
  • Loading branch information
f-bn committed Apr 13, 2024
1 parent 8fb1eb1 commit f3ce828
Show file tree
Hide file tree
Showing 5 changed files with 506 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build-pgbouncer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---

Check failure on line 1 in .github/workflows/build-pgbouncer.yml

View workflow job for this annotation

GitHub Actions / build (1.22.0)

.github/workflows/build-pgbouncer.yml#L1

This run was manually canceled.
name: Build pgbouncer image
on:
push:
branches:
- main
paths:
- pgbouncer/**
- .github/workflows/pgbouncer.yml
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['1.22.0']
steps:
- name: Check-out repository
uses: actions/checkout@v4

- name: Set up QEMU (for multi-arch build)
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image to registry
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
context: ./pgbouncer
file: ./pgbouncer/Dockerfile
push: true
build-args: |
VERSION=${{ matrix.version }}
tags: |
ghcr.io/f-bn/pgbouncer:${{ matrix.version }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This repository contains my personal custom OCI containers images.

#### Images

- [pgbouncer](./pgbouncer/)
- [postgresql](./postgresql/)

#### How to pull the images ?
Expand Down
63 changes: 63 additions & 0 deletions pgbouncer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# --- Build stage ---
FROM docker.io/gcc:13.2 AS build

ARG TARGETOS
ARG TARGETARCH
ARG VERSION=1.22.0

RUN set -ex ; \
export DEBIAN_FRONTEND=noninteractive ; \
apt update ; \
apt install -y --no-install-recommends \
ca-certificates \
wget \
libc6-dev \
libevent-dev \
libssl-dev \
libc-ares-dev \
libpq-dev \
pkg-config

WORKDIR /build

RUN set -ex ; \
wget -O pgbouncer-${VERSION}.tar.gz https://www.pgbouncer.org/downloads/files/${VERSION}/pgbouncer-${VERSION}.tar.gz ; \
wget -O pgbouncer-${VERSION}.tar.gz.sha256 https://www.pgbouncer.org/downloads/files/${VERSION}/pgbouncer-${VERSION}.tar.gz.sha256 ; \
cat pgbouncer-${VERSION}.tar.gz.sha256 | sha256sum -c ; \
tar -xzf pgbouncer-${VERSION}.tar.gz --strip-components=1

RUN set -ex ; \
./configure --prefix=/usr ; \
make -j2

# --- Final stage ---
FROM cgr.dev/chainguard/wolfi-base:latest

ARG VERSION=1.22.0

COPY --from=build --chmod=755 /build/pgbouncer /usr/bin/pgbouncer
COPY --chown=nonroot:nonroot --chmod=640 pgbouncer.default.ini /etc/pgbouncer/pgbouncer.ini

RUN set -ex ; \
mkdir -p /etc/pgbouncer /var/run/pgbouncer ; \
touch /etc/pgbouncer/userlist.txt ; \
chown -R nonroot:nonroot /etc/pgbouncer /var/run/pgbouncer ;

RUN apk add --no-cache c-ares libevent

USER nonroot

EXPOSE 6432/tcp

STOPSIGNAL SIGINT

ENTRYPOINT [ "/usr/bin/pgbouncer" ]

CMD [ "/etc/pgbouncer/pgbouncer.ini" ]

LABEL \
org.opencontainers.image.title="pgbouncer" \
org.opencontainers.image.source="https://github.com/f-bn/containers-images/pgbouncer" \
org.opencontainers.image.description="Lightweight connection pooler for PostgreSQL" \
org.opencontainers.image.licenses="ISC" \
org.opencontainers.image.authors="Florian Bobin <contact@fbobin.me>"
18 changes: 18 additions & 0 deletions pgbouncer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## General informations

Custom PgBouncer image builded from sources.

Built with GCC 13.2.

### Supported PgBouncer versions

- PgBouncer 1.22.x

## PgBouncer configuration

By default, this image is builded with a default empty PgBouncer configuration. You can bring your own configuration to the container (e.g using Docker):

```shell
# By default, the image is looking for configuration in /etc/pgbouncer/pgbouncer.ini
$ docker run [options] -v pgbouncer.ini:/etc/pgbouncer/pgbouncer.ini ghcr.io/f-bn/pgbouncer:1.22.0
```
Loading

0 comments on commit f3ce828

Please sign in to comment.