From dfb807a2e92df2f728285a850795a4af1d4f75e3 Mon Sep 17 00:00:00 2001 From: takahashim Date: Mon, 22 Jul 2024 22:43:05 +0900 Subject: [PATCH] Add pg_bigm --- .github/workflows/pg_build.yml | 36 ++++++++++++++++++++++++++++++++++ Dockerfile | 16 +++++++++++++++ initdb-pg_bigm.sh | 19 ++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 .github/workflows/pg_build.yml create mode 100644 Dockerfile create mode 100755 initdb-pg_bigm.sh diff --git a/.github/workflows/pg_build.yml b/.github/workflows/pg_build.yml new file mode 100644 index 0000000..c97b191 --- /dev/null +++ b/.github/workflows/pg_build.yml @@ -0,0 +1,36 @@ +name: Build and Push Docker Image of PostgreSQL with pg_bigm + +on: + push: + branches: + - 'main' + workflow_dispatch: + +jobs: + build-and-push: + runs-on: ubuntu-latest + env: + IMAGE_NAME: postgres_bigm + IMAGE_TAG: 12-latest + permissions: + packages: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + push: true + tags: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..84d9acb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM postgres:12 + +RUN apt update +RUN apt install -y postgresql-server-dev-12 make gcc curl libicu-dev + +RUN cd /tmp && \ + curl -L -O https://github.com/pgbigm/pg_bigm/archive/refs/tags/v1.2-20240606.tar.gz && \ + tar zxf v1.2-20240606.tar.gz && \ + cd pg_bigm-1.2-20240606 && \ + make USE_PGXS=1 && \ + make USE_PGXS=1 install && \ + rm -rf /tmp/pg_bigm-1.2-20240606 /tmp/v1.2-20240606.tar.gz + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-pg_bigm.sh /docker-entrypoint-initdb.d/10_pg_bigm.sh +# RUN echo shared_preload_libraries='pg_bigm' >> /var/lib/postgresql/data/postgresql.conf diff --git a/initdb-pg_bigm.sh b/initdb-pg_bigm.sh new file mode 100755 index 0000000..c6a65e1 --- /dev/null +++ b/initdb-pg_bigm.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_pg_bigm' template db +"${psql[@]}" <<- 'EOSQL' +CREATE DATABASE template_pg_bigm IS_TEMPLATE true; +EOSQL + +# Load pg_bigm into both template_database and $POSTGRES_DB +for DB in template_pg_bigm "$POSTGRES_DB"; do + echo "Loading pg_bigm extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS pg_bigm; +EOSQL +done