diff --git a/.github/workflows/build-multiarch.yml b/.github/workflows/build-multiarch.yml new file mode 100644 index 0000000..d80677e --- /dev/null +++ b/.github/workflows/build-multiarch.yml @@ -0,0 +1,82 @@ +name: Build Multi-Architecture Docker Images + +on: + push: + branches: + - master + paths: + - '**/Dockerfile' + - '.github/workflows/build-multiarch.yml' + pull_request: + paths: + - '**/Dockerfile' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + include: + # Latest versions with pg_tle + - version: 16-3-tle + tags: clkao/postgres-plv8:16-3-tle + - version: 15-3-tle + tags: clkao/postgres-plv8:15-3-tle + - version: 14-3-tle + tags: clkao/postgres-plv8:14-3-tle + - version: 13-3-tle + tags: clkao/postgres-plv8:13-3-tle + - version: 12-2-tle + tags: clkao/postgres-plv8:12-2-tle + + # Latest versions (plv8 3.x) + - version: 16-3 + tags: clkao/postgres-plv8:16-3,clkao/postgres-plv8:latest + - version: 15-3 + tags: clkao/postgres-plv8:15-3 + - version: 14-3 + tags: clkao/postgres-plv8:14-3 + - version: 13-3 + tags: clkao/postgres-plv8:13-3 + + # Older versions (plv8 2.x) + - version: 12-2 + tags: clkao/postgres-plv8:12-2 + - version: 11-2 + tags: clkao/postgres-plv8:11-2 + - version: 10-2 + tags: clkao/postgres-plv8:10-2 + - version: 9.6-2 + tags: clkao/postgres-plv8:9.6-2 + - version: 9.5-2 + tags: clkao/postgres-plv8:9.5-2 + - version: 9.4-2 + tags: clkao/postgres-plv8:9.4-2 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: ./${{ matrix.version }} + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ matrix.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4ece447 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,153 @@ +name: Release Tagged Docker Images + +# This workflow creates Docker Hub tags based on Git tags +# Tag format: vX.Y.Z (e.g., v3.2.4) +# Creates Docker tags like: 16-3.2.4, 15-3.2.4, etc. + +on: + push: + tags: + - 'v*.*.*' + workflow_dispatch: + inputs: + version: + description: 'plv8 version (e.g., 3.2.4)' + required: true + +jobs: + build-release: + runs-on: ubuntu-latest + strategy: + matrix: + include: + # PostgreSQL 16 variants + - pg_version: "16" + plv8_major: "3" + dockerfile: "16-3" + with_tle: false + - pg_version: "16" + plv8_major: "3" + dockerfile: "16-3-tle" + with_tle: true + + # PostgreSQL 15 variants + - pg_version: "15" + plv8_major: "3" + dockerfile: "15-3" + with_tle: false + - pg_version: "15" + plv8_major: "3" + dockerfile: "15-3-tle" + with_tle: true + + # PostgreSQL 14 variants + - pg_version: "14" + plv8_major: "3" + dockerfile: "14-3" + with_tle: false + - pg_version: "14" + plv8_major: "3" + dockerfile: "14-3-tle" + with_tle: true + + # PostgreSQL 13 variants + - pg_version: "13" + plv8_major: "3" + dockerfile: "13-3" + with_tle: false + - pg_version: "13" + plv8_major: "3" + dockerfile: "13-3-tle" + with_tle: true + + # PostgreSQL 12 variants + - pg_version: "12" + plv8_major: "3" + dockerfile: "12-2" + with_tle: false + - pg_version: "12" + plv8_major: "3" + dockerfile: "12-2-tle" + with_tle: true + + # PostgreSQL 11 + - pg_version: "11" + plv8_major: "3" + dockerfile: "11-2" + with_tle: false + + # PostgreSQL 10 + - pg_version: "10" + plv8_major: "3" + dockerfile: "10-2" + with_tle: false + + # PostgreSQL 9.6 + - pg_version: "9.6" + plv8_major: "3" + dockerfile: "9.6-2" + with_tle: false + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Extract version from tag + id: version + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + VERSION="${{ github.event.inputs.version }}" + else + VERSION="${GITHUB_REF#refs/tags/v}" + fi + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Building plv8 version: $VERSION" + + - name: Generate Docker tags + id: tags + run: | + VERSION="${{ steps.version.outputs.version }}" + PG="${{ matrix.pg_version }}" + TLE_SUFFIX="" + if [ "${{ matrix.with_tle }}" = "true" ]; then + TLE_SUFFIX="-tle" + fi + + # Generate tags + # Example: 16-3.2.4, 16-3.2, 16-3 + TAGS="clkao/postgres-plv8:${PG}-${VERSION}${TLE_SUFFIX}" + TAGS="${TAGS},clkao/postgres-plv8:${PG}-$(echo $VERSION | cut -d. -f1,2)${TLE_SUFFIX}" + TAGS="${TAGS},clkao/postgres-plv8:${PG}-$(echo $VERSION | cut -d. -f1)${TLE_SUFFIX}" + + # Add latest tag for PostgreSQL 16 without TLE + if [ "${{ matrix.pg_version }}" = "16" ] && [ "${{ matrix.with_tle }}" = "false" ]; then + TAGS="${TAGS},clkao/postgres-plv8:latest" + fi + + echo "tags=$TAGS" >> $GITHUB_OUTPUT + echo "Generated tags: $TAGS" + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: ./${{ matrix.dockerfile }} + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.tags.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + labels: | + org.opencontainers.image.version=${{ steps.version.outputs.version }} + org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..543c09a --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# Claude +CLAUDE.local.md + +# IDE +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS +.DS_Store +Thumbs.db + +# SQLite databases (now using JSONL as source of truth) +*.db +*.db-journal +*.db-wal +*.db-shm + +# Keep JSONL exports (source of truth for git) +!.beads/*.jsonl diff --git a/10-2/Dockerfile b/10-2/Dockerfile index f715322..2248d8a 100644 --- a/10-2/Dockerfile +++ b/10-2/Dockerfile @@ -2,22 +2,25 @@ FROM postgres:10 MAINTAINER Chia-liang Kao -ENV PLV8_VERSION=2.3.13 \ - PLV8_SHASUM="1a96c559d98ad757e7494bf7301f0e6b0dd2eec6066ad76ed36cc13fec4f2390" +ENV PLV8_VERSION=3.2.4 \ + PLV8_SHASUM="e05aed3b39851d7a9dc942d4ee229ca6842ce75b47f1c85c5031bc356061d66a" RUN buildDependencies="build-essential \ ca-certificates \ curl \ git-core \ - python \ + python3 \ gpp \ cpp \ pkg-config \ apt-transport-https \ cmake \ libc++-dev \ + libc++abi-dev \ postgresql-server-dev-$PG_MAJOR" \ - runtimeDependencies="libc++1" \ + && runtimeDependencies="libc++1 \ + libtinfo5 \ + libc++abi1" \ && apt-get update \ && apt-get install -y --no-install-recommends ${buildDependencies} ${runtimeDependencies} \ && mkdir -p /tmp/build \ diff --git a/11-2/Dockerfile b/11-2/Dockerfile index 2883d99..c1dc84c 100644 --- a/11-2/Dockerfile +++ b/11-2/Dockerfile @@ -2,22 +2,25 @@ FROM postgres:11 MAINTAINER Chia-liang Kao -ENV PLV8_VERSION=2.3.13 \ - PLV8_SHASUM="1a96c559d98ad757e7494bf7301f0e6b0dd2eec6066ad76ed36cc13fec4f2390" +ENV PLV8_VERSION=3.2.4 \ + PLV8_SHASUM="e05aed3b39851d7a9dc942d4ee229ca6842ce75b47f1c85c5031bc356061d66a" RUN buildDependencies="build-essential \ ca-certificates \ curl \ git-core \ - python \ + python3 \ gpp \ cpp \ pkg-config \ apt-transport-https \ cmake \ libc++-dev \ + libc++abi-dev \ postgresql-server-dev-$PG_MAJOR" \ - runtimeDependencies="libc++1" \ + && runtimeDependencies="libc++1 \ + libtinfo5 \ + libc++abi1" \ && apt-get update \ && apt-get install -y --no-install-recommends ${buildDependencies} ${runtimeDependencies} \ && mkdir -p /tmp/build \ diff --git a/12-2-tle/Dockerfile b/12-2-tle/Dockerfile new file mode 100644 index 0000000..9ad2026 --- /dev/null +++ b/12-2-tle/Dockerfile @@ -0,0 +1,47 @@ +FROM postgres:12 + +MAINTAINER Chia-liang Kao + +ENV PLV8_VERSION=2.3.13 \ + PLV8_SHASUM="1a96c559d98ad757e7494bf7301f0e6b0dd2eec6066ad76ed36cc13fec4f2390" + +RUN buildDependencies="build-essential \ + ca-certificates \ + curl \ + git-core \ + python \ + gpp \ + cpp \ + pkg-config \ + apt-transport-https \ + cmake \ + libc++-dev \ + libc++abi-dev \ + postgresql-server-dev-$PG_MAJOR" \ + && runtimeDependencies="libc++1 \ + libtinfo5 \ + libc++abi1" \ + && apt-get update \ + && apt-get install -y --no-install-recommends ${buildDependencies} ${runtimeDependencies} \ + && mkdir -p /tmp/build \ + && curl -o /tmp/build/v$PLV8_VERSION.tar.gz -SL "https://github.com/plv8/plv8/archive/v${PLV8_VERSION}.tar.gz" \ + && cd /tmp/build \ + && echo $PLV8_SHASUM v$PLV8_VERSION.tar.gz | sha256sum -c \ + && tar -xzf /tmp/build/v$PLV8_VERSION.tar.gz -C /tmp/build/ \ + && cd /tmp/build/plv8-$PLV8_VERSION \ + && make static \ + && make install \ + && strip /usr/lib/postgresql/${PG_MAJOR}/lib/plv8-${PLV8_VERSION}.so \ + && rm -rf /root/.vpython_cipd_cache /root/.vpython-root \ + && cd /tmp/build \ + && git clone https://github.com/aws/pg_tle.git \ + && cd pg_tle \ + && make \ + && make install \ + && apt-get clean \ + && apt-get remove -y ${buildDependencies} \ + && apt-get autoremove -y \ + && rm -rf /tmp/build /var/lib/apt/lists/* + +# Configure pg_tle to be loaded on startup +RUN echo "shared_preload_libraries = 'pg_tle'" >> /usr/share/postgresql/postgresql.conf.sample diff --git a/12-2/Dockerfile b/12-2/Dockerfile index cabb0a0..f72cf68 100644 --- a/12-2/Dockerfile +++ b/12-2/Dockerfile @@ -2,14 +2,14 @@ FROM postgres:12 MAINTAINER Chia-liang Kao -ENV PLV8_VERSION=2.3.13 \ - PLV8_SHASUM="1a96c559d98ad757e7494bf7301f0e6b0dd2eec6066ad76ed36cc13fec4f2390" +ENV PLV8_VERSION=3.2.4 \ + PLV8_SHASUM="e05aed3b39851d7a9dc942d4ee229ca6842ce75b47f1c85c5031bc356061d66a" RUN buildDependencies="build-essential \ ca-certificates \ curl \ git-core \ - python \ + python3 \ gpp \ cpp \ pkg-config \ diff --git a/13-3-tle/Dockerfile b/13-3-tle/Dockerfile new file mode 100644 index 0000000..7e9ba37 --- /dev/null +++ b/13-3-tle/Dockerfile @@ -0,0 +1,47 @@ +FROM postgres:13 + +MAINTAINER Chia-liang Kao + +ENV PLV8_VERSION=3.2.4 \ + PLV8_SHASUM="e05aed3b39851d7a9dc942d4ee229ca6842ce75b47f1c85c5031bc356061d66a" + +RUN buildDependencies="build-essential \ + ca-certificates \ + curl \ + git-core \ + python3 \ + gpp \ + cpp \ + pkg-config \ + apt-transport-https \ + cmake \ + libc++-dev \ + libc++abi-dev \ + postgresql-server-dev-$PG_MAJOR" \ + && runtimeDependencies="libc++1 \ + libtinfo5 \ + libc++abi1" \ + && apt-get update \ + && apt-get install -y --no-install-recommends ${buildDependencies} ${runtimeDependencies} \ + && mkdir -p /tmp/build \ + && curl -o /tmp/build/v$PLV8_VERSION.tar.gz -SL "https://github.com/plv8/plv8/archive/v${PLV8_VERSION}.tar.gz" \ + && cd /tmp/build \ + && echo $PLV8_SHASUM v$PLV8_VERSION.tar.gz | sha256sum -c \ + && tar -xzf /tmp/build/v$PLV8_VERSION.tar.gz -C /tmp/build/ \ + && cd /tmp/build/plv8-$PLV8_VERSION \ + && make static \ + && make install \ + && strip /usr/lib/postgresql/${PG_MAJOR}/lib/plv8-${PLV8_VERSION}.so \ + && rm -rf /root/.vpython_cipd_cache /root/.vpython-root \ + && cd /tmp/build \ + && git clone https://github.com/aws/pg_tle.git \ + && cd pg_tle \ + && make \ + && make install \ + && apt-get clean \ + && apt-get remove -y ${buildDependencies} \ + && apt-get autoremove -y \ + && rm -rf /tmp/build /var/lib/apt/lists/* + +# Configure pg_tle to be loaded on startup +RUN echo "shared_preload_libraries = 'pg_tle'" >> /usr/share/postgresql/postgresql.conf.sample diff --git a/13-3/Dockerfile b/13-3/Dockerfile new file mode 100644 index 0000000..99dbac5 --- /dev/null +++ b/13-3/Dockerfile @@ -0,0 +1,39 @@ +FROM postgres:13 + +MAINTAINER Chia-liang Kao + +ENV PLV8_VERSION=3.2.4 \ + PLV8_SHASUM="e05aed3b39851d7a9dc942d4ee229ca6842ce75b47f1c85c5031bc356061d66a" + +RUN buildDependencies="build-essential \ + ca-certificates \ + curl \ + git-core \ + python3 \ + gpp \ + cpp \ + pkg-config \ + apt-transport-https \ + cmake \ + libc++-dev \ + libc++abi-dev \ + postgresql-server-dev-$PG_MAJOR" \ + && runtimeDependencies="libc++1 \ + libtinfo5 \ + libc++abi1" \ + && apt-get update \ + && apt-get install -y --no-install-recommends ${buildDependencies} ${runtimeDependencies} \ + && mkdir -p /tmp/build \ + && curl -o /tmp/build/v$PLV8_VERSION.tar.gz -SL "https://github.com/plv8/plv8/archive/v${PLV8_VERSION}.tar.gz" \ + && cd /tmp/build \ + && echo $PLV8_SHASUM v$PLV8_VERSION.tar.gz | sha256sum -c \ + && tar -xzf /tmp/build/v$PLV8_VERSION.tar.gz -C /tmp/build/ \ + && cd /tmp/build/plv8-$PLV8_VERSION \ + && make static \ + && make install \ + && strip /usr/lib/postgresql/${PG_MAJOR}/lib/plv8-${PLV8_VERSION}.so \ + && rm -rf /root/.vpython_cipd_cache /root/.vpython-root \ + && apt-get clean \ + && apt-get remove -y ${buildDependencies} \ + && apt-get autoremove -y \ + && rm -rf /tmp/build /var/lib/apt/lists/* diff --git a/14-3-tle/Dockerfile b/14-3-tle/Dockerfile new file mode 100644 index 0000000..2e4518e --- /dev/null +++ b/14-3-tle/Dockerfile @@ -0,0 +1,47 @@ +FROM postgres:14 + +MAINTAINER Chia-liang Kao + +ENV PLV8_VERSION=3.2.4 \ + PLV8_SHASUM="e05aed3b39851d7a9dc942d4ee229ca6842ce75b47f1c85c5031bc356061d66a" + +RUN buildDependencies="build-essential \ + ca-certificates \ + curl \ + git-core \ + python3 \ + gpp \ + cpp \ + pkg-config \ + apt-transport-https \ + cmake \ + libc++-dev \ + libc++abi-dev \ + postgresql-server-dev-$PG_MAJOR" \ + && runtimeDependencies="libc++1 \ + libtinfo5 \ + libc++abi1" \ + && apt-get update \ + && apt-get install -y --no-install-recommends ${buildDependencies} ${runtimeDependencies} \ + && mkdir -p /tmp/build \ + && curl -o /tmp/build/v$PLV8_VERSION.tar.gz -SL "https://github.com/plv8/plv8/archive/v${PLV8_VERSION}.tar.gz" \ + && cd /tmp/build \ + && echo $PLV8_SHASUM v$PLV8_VERSION.tar.gz | sha256sum -c \ + && tar -xzf /tmp/build/v$PLV8_VERSION.tar.gz -C /tmp/build/ \ + && cd /tmp/build/plv8-$PLV8_VERSION \ + && make static \ + && make install \ + && strip /usr/lib/postgresql/${PG_MAJOR}/lib/plv8-${PLV8_VERSION}.so \ + && rm -rf /root/.vpython_cipd_cache /root/.vpython-root \ + && cd /tmp/build \ + && git clone https://github.com/aws/pg_tle.git \ + && cd pg_tle \ + && make \ + && make install \ + && apt-get clean \ + && apt-get remove -y ${buildDependencies} \ + && apt-get autoremove -y \ + && rm -rf /tmp/build /var/lib/apt/lists/* + +# Configure pg_tle to be loaded on startup +RUN echo "shared_preload_libraries = 'pg_tle'" >> /usr/share/postgresql/postgresql.conf.sample diff --git a/14-3/Dockerfile b/14-3/Dockerfile new file mode 100644 index 0000000..ea48fef --- /dev/null +++ b/14-3/Dockerfile @@ -0,0 +1,39 @@ +FROM postgres:14 + +MAINTAINER Chia-liang Kao + +ENV PLV8_VERSION=3.2.4 \ + PLV8_SHASUM="e05aed3b39851d7a9dc942d4ee229ca6842ce75b47f1c85c5031bc356061d66a" + +RUN buildDependencies="build-essential \ + ca-certificates \ + curl \ + git-core \ + python3 \ + gpp \ + cpp \ + pkg-config \ + apt-transport-https \ + cmake \ + libc++-dev \ + libc++abi-dev \ + postgresql-server-dev-$PG_MAJOR" \ + && runtimeDependencies="libc++1 \ + libtinfo5 \ + libc++abi1" \ + && apt-get update \ + && apt-get install -y --no-install-recommends ${buildDependencies} ${runtimeDependencies} \ + && mkdir -p /tmp/build \ + && curl -o /tmp/build/v$PLV8_VERSION.tar.gz -SL "https://github.com/plv8/plv8/archive/v${PLV8_VERSION}.tar.gz" \ + && cd /tmp/build \ + && echo $PLV8_SHASUM v$PLV8_VERSION.tar.gz | sha256sum -c \ + && tar -xzf /tmp/build/v$PLV8_VERSION.tar.gz -C /tmp/build/ \ + && cd /tmp/build/plv8-$PLV8_VERSION \ + && make static \ + && make install \ + && strip /usr/lib/postgresql/${PG_MAJOR}/lib/plv8-${PLV8_VERSION}.so \ + && rm -rf /root/.vpython_cipd_cache /root/.vpython-root \ + && apt-get clean \ + && apt-get remove -y ${buildDependencies} \ + && apt-get autoremove -y \ + && rm -rf /tmp/build /var/lib/apt/lists/* diff --git a/15-3-tle/Dockerfile b/15-3-tle/Dockerfile new file mode 100644 index 0000000..1a5437a --- /dev/null +++ b/15-3-tle/Dockerfile @@ -0,0 +1,47 @@ +FROM postgres:15 + +MAINTAINER Chia-liang Kao + +ENV PLV8_VERSION=3.2.4 \ + PLV8_SHASUM="e05aed3b39851d7a9dc942d4ee229ca6842ce75b47f1c85c5031bc356061d66a" + +RUN buildDependencies="build-essential \ + ca-certificates \ + curl \ + git-core \ + python3 \ + gpp \ + cpp \ + pkg-config \ + apt-transport-https \ + cmake \ + libc++-dev \ + libc++abi-dev \ + postgresql-server-dev-$PG_MAJOR" \ + && runtimeDependencies="libc++1 \ + libtinfo5 \ + libc++abi1" \ + && apt-get update \ + && apt-get install -y --no-install-recommends ${buildDependencies} ${runtimeDependencies} \ + && mkdir -p /tmp/build \ + && curl -o /tmp/build/v$PLV8_VERSION.tar.gz -SL "https://github.com/plv8/plv8/archive/v${PLV8_VERSION}.tar.gz" \ + && cd /tmp/build \ + && echo $PLV8_SHASUM v$PLV8_VERSION.tar.gz | sha256sum -c \ + && tar -xzf /tmp/build/v$PLV8_VERSION.tar.gz -C /tmp/build/ \ + && cd /tmp/build/plv8-$PLV8_VERSION \ + && make static \ + && make install \ + && strip /usr/lib/postgresql/${PG_MAJOR}/lib/plv8-${PLV8_VERSION}.so \ + && rm -rf /root/.vpython_cipd_cache /root/.vpython-root \ + && cd /tmp/build \ + && git clone https://github.com/aws/pg_tle.git \ + && cd pg_tle \ + && make \ + && make install \ + && apt-get clean \ + && apt-get remove -y ${buildDependencies} \ + && apt-get autoremove -y \ + && rm -rf /tmp/build /var/lib/apt/lists/* + +# Configure pg_tle to be loaded on startup +RUN echo "shared_preload_libraries = 'pg_tle'" >> /usr/share/postgresql/postgresql.conf.sample diff --git a/15-3/Dockerfile b/15-3/Dockerfile new file mode 100644 index 0000000..a832ee8 --- /dev/null +++ b/15-3/Dockerfile @@ -0,0 +1,39 @@ +FROM postgres:15 + +MAINTAINER Chia-liang Kao + +ENV PLV8_VERSION=3.2.4 \ + PLV8_SHASUM="e05aed3b39851d7a9dc942d4ee229ca6842ce75b47f1c85c5031bc356061d66a" + +RUN buildDependencies="build-essential \ + ca-certificates \ + curl \ + git-core \ + python3 \ + gpp \ + cpp \ + pkg-config \ + apt-transport-https \ + cmake \ + libc++-dev \ + libc++abi-dev \ + postgresql-server-dev-$PG_MAJOR" \ + && runtimeDependencies="libc++1 \ + libtinfo5 \ + libc++abi1" \ + && apt-get update \ + && apt-get install -y --no-install-recommends ${buildDependencies} ${runtimeDependencies} \ + && mkdir -p /tmp/build \ + && curl -o /tmp/build/v$PLV8_VERSION.tar.gz -SL "https://github.com/plv8/plv8/archive/v${PLV8_VERSION}.tar.gz" \ + && cd /tmp/build \ + && echo $PLV8_SHASUM v$PLV8_VERSION.tar.gz | sha256sum -c \ + && tar -xzf /tmp/build/v$PLV8_VERSION.tar.gz -C /tmp/build/ \ + && cd /tmp/build/plv8-$PLV8_VERSION \ + && make static \ + && make install \ + && strip /usr/lib/postgresql/${PG_MAJOR}/lib/plv8-${PLV8_VERSION}.so \ + && rm -rf /root/.vpython_cipd_cache /root/.vpython-root \ + && apt-get clean \ + && apt-get remove -y ${buildDependencies} \ + && apt-get autoremove -y \ + && rm -rf /tmp/build /var/lib/apt/lists/* diff --git a/16-3-tle/Dockerfile b/16-3-tle/Dockerfile new file mode 100644 index 0000000..257d3bb --- /dev/null +++ b/16-3-tle/Dockerfile @@ -0,0 +1,47 @@ +FROM postgres:16 + +MAINTAINER Chia-liang Kao + +ENV PLV8_VERSION=3.2.4 \ + PLV8_SHASUM="e05aed3b39851d7a9dc942d4ee229ca6842ce75b47f1c85c5031bc356061d66a" + +RUN buildDependencies="build-essential \ + ca-certificates \ + curl \ + git-core \ + python3 \ + gpp \ + cpp \ + pkg-config \ + apt-transport-https \ + cmake \ + libc++-dev \ + libc++abi-dev \ + postgresql-server-dev-$PG_MAJOR" \ + && runtimeDependencies="libc++1 \ + libtinfo5 \ + libc++abi1" \ + && apt-get update \ + && apt-get install -y --no-install-recommends ${buildDependencies} ${runtimeDependencies} \ + && mkdir -p /tmp/build \ + && curl -o /tmp/build/v$PLV8_VERSION.tar.gz -SL "https://github.com/plv8/plv8/archive/v${PLV8_VERSION}.tar.gz" \ + && cd /tmp/build \ + && echo $PLV8_SHASUM v$PLV8_VERSION.tar.gz | sha256sum -c \ + && tar -xzf /tmp/build/v$PLV8_VERSION.tar.gz -C /tmp/build/ \ + && cd /tmp/build/plv8-$PLV8_VERSION \ + && make static \ + && make install \ + && strip /usr/lib/postgresql/${PG_MAJOR}/lib/plv8-${PLV8_VERSION}.so \ + && rm -rf /root/.vpython_cipd_cache /root/.vpython-root \ + && cd /tmp/build \ + && git clone https://github.com/aws/pg_tle.git \ + && cd pg_tle \ + && make \ + && make install \ + && apt-get clean \ + && apt-get remove -y ${buildDependencies} \ + && apt-get autoremove -y \ + && rm -rf /tmp/build /var/lib/apt/lists/* + +# Configure pg_tle to be loaded on startup +RUN echo "shared_preload_libraries = 'pg_tle'" >> /usr/share/postgresql/postgresql.conf.sample diff --git a/16-3/Dockerfile b/16-3/Dockerfile new file mode 100644 index 0000000..194b7aa --- /dev/null +++ b/16-3/Dockerfile @@ -0,0 +1,39 @@ +FROM postgres:16 + +MAINTAINER Chia-liang Kao + +ENV PLV8_VERSION=3.2.4 \ + PLV8_SHASUM="e05aed3b39851d7a9dc942d4ee229ca6842ce75b47f1c85c5031bc356061d66a" + +RUN buildDependencies="build-essential \ + ca-certificates \ + curl \ + git-core \ + python3 \ + gpp \ + cpp \ + pkg-config \ + apt-transport-https \ + cmake \ + libc++-dev \ + libc++abi-dev \ + postgresql-server-dev-$PG_MAJOR" \ + && runtimeDependencies="libc++1 \ + libtinfo5 \ + libc++abi1" \ + && apt-get update \ + && apt-get install -y --no-install-recommends ${buildDependencies} ${runtimeDependencies} \ + && mkdir -p /tmp/build \ + && curl -o /tmp/build/v$PLV8_VERSION.tar.gz -SL "https://github.com/plv8/plv8/archive/v${PLV8_VERSION}.tar.gz" \ + && cd /tmp/build \ + && echo $PLV8_SHASUM v$PLV8_VERSION.tar.gz | sha256sum -c \ + && tar -xzf /tmp/build/v$PLV8_VERSION.tar.gz -C /tmp/build/ \ + && cd /tmp/build/plv8-$PLV8_VERSION \ + && make static \ + && make install \ + && strip /usr/lib/postgresql/${PG_MAJOR}/lib/plv8-${PLV8_VERSION}.so \ + && rm -rf /root/.vpython_cipd_cache /root/.vpython-root \ + && apt-get clean \ + && apt-get remove -y ${buildDependencies} \ + && apt-get autoremove -y \ + && rm -rf /tmp/build /var/lib/apt/lists/* diff --git a/9.6-2/Dockerfile b/9.6-2/Dockerfile index cd1d96b..4cb9a88 100644 --- a/9.6-2/Dockerfile +++ b/9.6-2/Dockerfile @@ -2,27 +2,37 @@ FROM postgres:9.6 MAINTAINER Chia-liang Kao -ENV PLV8_VERSION=v2.1.0 \ - PLV8_SHASUM="207d712e919ab666936f42b29ff3eae413736b70745f5bfeb2d0910f0c017a5c v2.1.0.tar.gz" +ENV PLV8_VERSION=3.2.4 \ + PLV8_SHASUM="e05aed3b39851d7a9dc942d4ee229ca6842ce75b47f1c85c5031bc356061d66a" RUN buildDependencies="build-essential \ ca-certificates \ curl \ git-core \ + python3 \ + gpp \ + cpp \ + pkg-config \ + apt-transport-https \ + cmake \ + libc++-dev \ + libc++abi-dev \ postgresql-server-dev-$PG_MAJOR" \ + && runtimeDependencies="libc++1 \ + libtinfo5 \ + libc++abi1" \ && apt-get update \ - && apt-get install -y --no-install-recommends ${buildDependencies} \ + && apt-get install -y --no-install-recommends ${buildDependencies} ${runtimeDependencies} \ && mkdir -p /tmp/build \ - && curl -o /tmp/build/${PLV8_VERSION}.tar.gz -SL "https://github.com/plv8/plv8/archive/$PLV8_VERSION.tar.gz" \ + && curl -o /tmp/build/v$PLV8_VERSION.tar.gz -SL "https://github.com/plv8/plv8/archive/v${PLV8_VERSION}.tar.gz" \ && cd /tmp/build \ - && echo ${PLV8_SHASUM} | sha256sum -c \ - && tar -xzf /tmp/build/${PLV8_VERSION}.tar.gz -C /tmp/build/ \ - && cd /tmp/build/plv8-${PLV8_VERSION#?} \ - && sed -i 's/\(depot_tools.git\)/\1; cd depot_tools; git checkout 46541b4996f25b706146148331b9613c8a787e7e; rm -rf .git;/' Makefile.v8 \ + && echo $PLV8_SHASUM v$PLV8_VERSION.tar.gz | sha256sum -c \ + && tar -xzf /tmp/build/v$PLV8_VERSION.tar.gz -C /tmp/build/ \ + && cd /tmp/build/plv8-$PLV8_VERSION \ && make static \ && make install \ - && strip /usr/lib/postgresql/${PG_MAJOR}/lib/plv8.so \ - && cd / \ + && strip /usr/lib/postgresql/${PG_MAJOR}/lib/plv8-${PLV8_VERSION}.so \ + && rm -rf /root/.vpython_cipd_cache /root/.vpython-root \ && apt-get clean \ && apt-get remove -y ${buildDependencies} \ && apt-get autoremove -y \ diff --git a/README.md b/README.md index 74fd32a..e50e621 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,47 @@ # postgres-plv8 -Docker images for running [plv8](https://github.com/plv8/plv8) 1.4, 1.5 and 2.x on Postgres 9.4, 9.5, 9.6, 10, 11 and 12. Based on the [official Postgres image](http://registry.hub.docker.com/_/postgres/). +Docker images for running [plv8](https://github.com/plv8/plv8) 1.4, 1.5, 2.x, and 3.x on Postgres 9.4, 9.5, 9.6, 10, 11, 12, 13, 14, 15, and 16. Based on the [official Postgres image](http://registry.hub.docker.com/_/postgres/). + +**Multi-architecture support**: Images are built for both `linux/amd64` and `linux/arm64` (Apple Silicon) platforms. [![clkao/postgres-plv8][docker-pulls-image]][docker-hub-url] [![clkao/postgres-plv8][docker-stars-image]][docker-hub-url] [![clkao/postgres-plv8][docker-size-image]][docker-hub-url] [![clkao/postgres-plv8][docker-layers-image]][docker-hub-url] ## Tags -- `12-2`, `latest` ([12-2/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/12-2/Dockerfile)) +All images support versioned tags for reproducible builds. Tags follow the format `-[-tle]`. + +**Examples:** +- `16-3.2.4` - PostgreSQL 16 with plv8 3.2.4 +- `15-3.2.4-tle` - PostgreSQL 15 with plv8 3.2.4 and pg_tle +- `16-3` - PostgreSQL 16 with latest plv8 3.x +- `latest` - Latest PostgreSQL with latest plv8 + +### Latest Versions with pg_tle (plv8 3.x + pg_tle) +- `16-3-tle` ([16-3-tle/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/16-3-tle/Dockerfile)) +- `15-3-tle` ([15-3-tle/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/15-3-tle/Dockerfile)) +- `14-3-tle` ([14-3-tle/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/14-3-tle/Dockerfile)) +- `13-3-tle` ([13-3-tle/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/13-3-tle/Dockerfile)) +- `12-2-tle` ([12-2-tle/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/12-2-tle/Dockerfile)) + +### Latest Versions (plv8 3.x) +- `16-3`, `latest` ([16-3/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/16-3/Dockerfile)) +- `15-3` ([15-3/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/15-3/Dockerfile)) +- `14-3` ([14-3/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/14-3/Dockerfile)) +- `13-3` ([13-3/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/13-3/Dockerfile)) + +### Older Versions (plv8 2.x) +- `12-2` ([12-2/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/12-2/Dockerfile)) - `11-2` ([11-2/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/11-2/Dockerfile)) - `10-2` ([10-2/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/10-2/Dockerfile)) -- `9.6-2`, ([9.6-2/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/9.6-2/Dockerfile)) +- `9.6-2` ([9.6-2/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/9.6-2/Dockerfile)) +- `9.5-2` ([9.5-2/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/9.5-2/Dockerfile)) +- `9.4-2` ([9.4-2/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/9.4-2/Dockerfile)) + +### Legacy Versions (plv8 1.x) +- `9.6-1.5` ([9.6-1.5/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/9.6-1.5/Dockerfile)) - `9.6-1.4` ([9.6-1.4/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/9.6-1.4/Dockerfile)) -- `9.5-2` ([9.5-1.5/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/9.5-2/Dockerfile)) - `9.5-1.5` ([9.5-1.5/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/9.5-1.5/Dockerfile)) - `9.5-1.4` ([9.5-1.4/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/9.5-1.4/Dockerfile)) -- `9.4-2` ([9.4-1.5/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/9.4-2/Dockerfile)) - `9.4-1.5` ([9.4-1.5/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/9.4-1.5/Dockerfile)) - `9.4-1.4` ([9.4-1.4/Dockerfile](https://github.com/clkao/docker-postgres-plv8/blob/master/9.4-1.4/Dockerfile)) @@ -38,6 +65,17 @@ postgres: image: clkao/postgres-plv8 ``` +### Using images with pg_tle + +Images with the `-tle` suffix include [pg_tle](https://github.com/aws/pg_tle) (Trusted Language Extensions) pre-installed and configured. pg_tle allows you to install and manage extensions without filesystem access. + +```sh +$ docker run -d --name postgres clkao/postgres-plv8:16-3-tle +$ docker exec -it postgres bash -c "psql -U postgres -c \"CREATE EXTENSION pg_tle; CREATE EXTENSION plv8;\"" +``` + +After creating the pg_tle extension, you can use it to install and manage trusted language extensions dynamically. + ## Image variants The `clkao/postgres-plv8` image comes in multiple flavors: @@ -50,9 +88,55 @@ Points to the latest release available of Postgres stable with compatible plv8 i Points to the latest release available of Postgres `` with the latest release available of plv8 `` installed. +## Creating Releases + +To create a new versioned release: + +1. **Create a Git tag** matching the plv8 version: + ```sh + git tag -a v3.2.4 -m "Release plv8 3.2.4" + git push origin v3.2.4 + ``` + +2. **Automated builds**: GitHub Actions will automatically build and push versioned tags to Docker Hub: + - Full version: `16-3.2.4`, `15-3.2.4`, etc. + - Minor version: `16-3.2`, `15-3.2`, etc. + - Major version: `16-3`, `15-3`, etc. + +3. **Manual release** (if needed): + ```sh + # Trigger the release workflow manually + gh workflow run release.yml -f version=3.2.4 + ``` + +This provides users with immutable, versioned tags for reproducible builds while maintaining mutable tags (`latest`, `16-3`) for convenience. + +## Building Multi-Architecture Images + +This repository includes support for building multi-architecture Docker images (AMD64 + ARM64). + +### Using the Build Script + +```sh +# Build locally (for testing) +./build-multiarch.sh + +# Build and push to Docker Hub +./build-multiarch.sh --push +``` + +### Requirements + +- Docker Buildx (included with Docker Desktop) +- For pushing: Docker Hub credentials + +### GitHub Actions + +The repository includes a GitHub Actions workflow that automatically builds multi-architecture images on push to master. The workflow builds for both `linux/amd64` and `linux/arm64` platforms. + ## Supported Docker versions -This image is officially supported on Docker version 19.03, with support for older versions provided on a best-effort basis. +This image is officially supported on Docker version 19.03+, with support for older versions provided on a best-effort basis. ## License diff --git a/build-multiarch.sh b/build-multiarch.sh new file mode 100755 index 0000000..9524ba3 --- /dev/null +++ b/build-multiarch.sh @@ -0,0 +1,87 @@ +#!/bin/bash +set -e + +# Script to build multi-architecture Docker images (AMD64 + ARM64) +# Requires Docker Buildx + +# Check if buildx is available +if ! docker buildx version > /dev/null 2>&1; then + echo "Error: Docker Buildx is not available. Please install Docker Desktop or enable buildx." + exit 1 +fi + +# Create a new builder instance if it doesn't exist +if ! docker buildx ls | grep -q multiarch-builder; then + echo "Creating new buildx builder instance..." + docker buildx create --name multiarch-builder --use + docker buildx inspect --bootstrap +else + echo "Using existing buildx builder instance..." + docker buildx use multiarch-builder +fi + +# Function to build and push a multi-arch image +build_image() { + local version=$1 + local tag=$2 + local push=${3:-false} + + echo "Building multi-arch image for $version (tag: $tag)..." + + if [ "$push" = "true" ]; then + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --tag "clkao/postgres-plv8:$tag" \ + --push \ + "$version/" + else + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --tag "clkao/postgres-plv8:$tag" \ + --load \ + "$version/" + fi + + echo "✓ Built $tag successfully" +} + +# Parse command line arguments +PUSH=false +if [ "$1" = "--push" ]; then + PUSH=true + echo "Push mode enabled - images will be pushed to Docker Hub" +else + echo "Local build mode - images will be loaded locally" + echo "Use --push flag to push to Docker Hub" +fi + +# Build all versions +echo "Building multi-architecture images..." + +# Latest versions with pg_tle +build_image "16-3-tle" "16-3-tle" "$PUSH" +build_image "15-3-tle" "15-3-tle" "$PUSH" +build_image "14-3-tle" "14-3-tle" "$PUSH" +build_image "13-3-tle" "13-3-tle" "$PUSH" +build_image "12-2-tle" "12-2-tle" "$PUSH" + +# Latest versions (plv8 3.x) +build_image "16-3" "16-3" "$PUSH" +build_image "15-3" "15-3" "$PUSH" +build_image "14-3" "14-3" "$PUSH" +build_image "13-3" "13-3" "$PUSH" + +# Tag latest +if [ "$PUSH" = "true" ]; then + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --tag "clkao/postgres-plv8:latest" \ + --push \ + "16-3/" +fi + +echo "" +echo "✓ All images built successfully!" +echo "" +echo "To build and push to Docker Hub, run:" +echo " ./build-multiarch.sh --push"