From 696033c63afb264d7de099f93c5bee4220fbfdc6 Mon Sep 17 00:00:00 2001 From: ajp_anton Date: Mon, 22 Jun 2026 22:07:53 +0000 Subject: [PATCH] Add custom container image builds --- .dockerignore | 4 ++ .gitea/workflows/build-images.yaml | 70 ++++++++++++++++++++++++++++++ .gitignore | 1 + README.md | 52 ++++++++++++++++++++++ php8-pgsql/Dockerfile | 14 ++++++ postgres/Dockerfile | 21 +++++++++ 6 files changed, 162 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitea/workflows/build-images.yaml create mode 100644 .gitignore create mode 100644 README.md create mode 100644 php8-pgsql/Dockerfile create mode 100644 postgres/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b0eb7b5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git +.gitea +local +README.md diff --git a/.gitea/workflows/build-images.yaml b/.gitea/workflows/build-images.yaml new file mode 100644 index 0000000..d5e8ab0 --- /dev/null +++ b/.gitea/workflows/build-images.yaml @@ -0,0 +1,70 @@ +name: Build custom container images + +on: + push: + branches: + - main + workflow_dispatch: + schedule: + - cron: "27 3 * * 1" + +permissions: + contents: read + packages: write + +env: + REGISTRY: git.ajpanton.se + OWNER: ajp_anton + PG_VERSION: "18" + POSTGIS_VERSION: "3" + VCHORD_VERSION: "0.5.3" + PHP_VERSION: "8" + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + image: + - name: postgres-custom + context: postgres + tags: | + git.ajpanton.se/ajp_anton/postgres-custom:18 + git.ajpanton.se/ajp_anton/postgres-custom:18-postgis3-vchord0.5.3 + git.ajpanton.se/ajp_anton/postgres-custom:latest + build_args: | + PG_VERSION=18 + POSTGIS_VERSION=3 + VCHORD_VERSION=0.5.3 + - name: php8-pgsql + context: php8-pgsql + tags: | + git.ajpanton.se/ajp_anton/php8-pgsql:8 + git.ajpanton.se/ajp_anton/php8-pgsql:8-fpm-alpine + git.ajpanton.se/ajp_anton/php8-pgsql:latest + build_args: | + PHP_VERSION=8 + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Gitea container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ gitea.actor }} + password: ${{ secrets.GITEA_TOKEN }} + + - name: Build and push ${{ matrix.image.name }} + uses: docker/build-push-action@v6 + with: + context: ./${{ matrix.image.context }} + push: true + tags: ${{ matrix.image.tags }} + build-args: ${{ matrix.image.build_args }} + pull: true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..51b4cfd --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +local/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..ff1ee4c --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +# Custom container images + +Small custom container images published to the Gitea container registry at +`git.ajpanton.se`. + +## Images + +| Image | Purpose | Base | +| --- | --- | --- | +| `git.ajpanton.se/ajp_anton/postgres-custom:18` | PostgreSQL with `pg_cron`, `pgvector`, PostGIS, and VectorChord | `postgres:18` | +| `git.ajpanton.se/ajp_anton/php8-pgsql:8` | PHP-FPM with the `pdo_pgsql` extension | `php:8-fpm-alpine` | + +There is no custom nginx image here yet. The current web-server image can stay +on upstream `nginx:*alpine` unless custom nginx modules or baked-in config are +needed. + +## How Updates Work + +The workflow in `.gitea/workflows/build-images.yaml` rebuilds and pushes these +images on: + +- pushes to `main` +- manual workflow runs +- the weekly schedule in the workflow + +Each scheduled run asks Docker to pull the current base image before building. +During the build, package managers also install the currently available packages +from their configured repositories. If the upstream base image or installed +packages have changed, the resulting image digest changes even when the tag name +stays the same. + +Container update tools can then watch the pushed tags by digest. When the remote +digest for a watched tag differs from the locally running image digest, the tool +can report or apply an update. + +Pinned build arguments, such as `VCHORD_VERSION`, do not update themselves. +Changing those values requires a commit or an additional automation step that +checks upstream releases and updates this repository. + +## Publishing + +The workflow publishes these tags: + +- `git.ajpanton.se/ajp_anton/postgres-custom:18` +- `git.ajpanton.se/ajp_anton/postgres-custom:18-postgis3-vchord0.5.3` +- `git.ajpanton.se/ajp_anton/postgres-custom:latest` +- `git.ajpanton.se/ajp_anton/php8-pgsql:8` +- `git.ajpanton.se/ajp_anton/php8-pgsql:8-fpm-alpine` +- `git.ajpanton.se/ajp_anton/php8-pgsql:latest` + +The workflow uses Gitea Actions and the built-in `GITEA_TOKEN` with package +write permission. diff --git a/php8-pgsql/Dockerfile b/php8-pgsql/Dockerfile new file mode 100644 index 0000000..1327770 --- /dev/null +++ b/php8-pgsql/Dockerfile @@ -0,0 +1,14 @@ +ARG PHP_VERSION=8 +FROM php:${PHP_VERSION}-fpm-alpine AS build + +RUN set -eux; \ + apk add --no-cache postgresql-dev; \ + docker-php-ext-install pdo_pgsql + +FROM php:${PHP_VERSION}-fpm-alpine + +RUN set -eux; \ + apk add --no-cache libpq + +COPY --from=build /usr/local/lib/php/extensions/ /usr/local/lib/php/extensions/ +COPY --from=build /usr/local/etc/php/conf.d/ /usr/local/etc/php/conf.d/ diff --git a/postgres/Dockerfile b/postgres/Dockerfile new file mode 100644 index 0000000..d97a80e --- /dev/null +++ b/postgres/Dockerfile @@ -0,0 +1,21 @@ +ARG PG_VERSION=18 +FROM postgres:${PG_VERSION} + +ARG PG_VERSION=18 +ARG POSTGIS_VERSION=3 +ARG VCHORD_VERSION=0.5.3 + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + ca-certificates \ + wget \ + postgresql-${PG_VERSION}-cron \ + postgresql-${PG_VERSION}-pgvector \ + postgresql-${PG_VERSION}-postgis-${POSTGIS_VERSION}; \ + wget -O /tmp/vchord.deb "https://github.com/tensorchord/VectorChord/releases/download/${VCHORD_VERSION}/postgresql-${PG_VERSION}-vchord_${VCHORD_VERSION}-1_amd64.deb"; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends /tmp/vchord.deb; \ + rm -f /tmp/vchord.deb; \ + rm -rf /var/lib/apt/lists/* + +CMD ["postgres", "-c", "shared_preload_libraries=pg_cron,vchord", "-c", "cron.database_name=firecrawl"]