Skip to content
This repository was archived by the owner on Sep 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: build

on:
pull_request:
types: [opened, synchronize, reopened]


# automatically cancel previous runs on the same PR
# https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre/67939898#67939898
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true


jobs:
# tmate:
# name: TMate
# runs-on: postgres-builder-32core
# timeout-minutes: 120
# steps:
# - name: Checkout
# uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # pin@v3
# with:
# # https://github.com/actions/checkout/issues/626
# # This is correct, because we're using a merge queue (mergify) which only merges when built against the latest target branch.
# # https://docs.mergify.com/actions/queue/
# ref: ${{ github.event.pull_request.head.sha }}

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

# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3

docker-build:
name: Build Docker ${{ fromJson(matrix.image).dockerfile }}
runs-on: postgres-builder-32core
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
image:
- '{"dockerfile": "./Dockerfile", "context": ".", "platforms": "linux/amd64" }'
- '{"dockerfile": "./Dockerfile.ami_buildscript", "context": ".", "platforms": "linux/amd64" }'
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # pin@v3
with:
# https://github.com/actions/checkout/issues/626
# This is correct, because we're using a merge queue (mergify) which only merges when built against the latest target branch.
# https://docs.mergify.com/actions/queue/
ref: ${{ github.event.pull_request.head.sha }}

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

- name: Docker Cache
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-${{ fromJson(matrix.image).dockerfile }}-buildx

- name: Docker build
uses: docker/build-push-action@v4
with:
context: ${{ fromJson(matrix.image).context }}
file: ${{ fromJson(matrix.image).dockerfile }}
platforms: ${{ fromJson(matrix.image).platforms }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
push: false
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ ENV PLV8_VERSION=${PLV8_VERSION}
RUN set -ex && \
git clone --branch ${PLV8_BRANCH} https://github.com/plv8/plv8 /plv8

RUN make -j32 -C /plv8 install || true
RUN make -j32 -C /plv8 install
RUN make -j$(nproc --all) -C /plv8 plv8_config.h
RUN make -j$(nproc --all) -C /plv8 install

RUN strip /usr/lib/postgresql/${PG_MAJOR}/lib/plv8-${PLV8_VERSION}.so

# install our own postgres extension source code
COPY postgres_extension /postgres_extension/

# build and install custom postgres extension
RUN make -C /postgres_extension/functions
RUN make -j$(nproc --all) -C /postgres_extension/functions
RUN make -C /postgres_extension/functions install

RUN git clone https://github.com/chimpler/postgres-aws-s3.git /postgres-aws-s3 && \
Expand Down
6 changes: 6 additions & 0 deletions Dockerfile.ami_buildscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM amazonlinux:2

COPY ./postgres_extension/ /postgres_extension

COPY imagebuild.sh .
RUN bash imagebuild.sh
28 changes: 23 additions & 5 deletions imagebuild.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
#!/bin/sh

set -Eeuo pipefail
set -Eeuxo pipefail

amazon-linux-extras install postgresql14
yum -y install postgresql-server postgresql-server-devel postgresql-plpython3 git gcc jq
yum -y install postgresql-server postgresql-server-devel postgresql-plpython3 git gcc jq wget tar make xz \
libxml2-devel libyaml-devel lz4-devel libzstd-devel bzip2-devel \
ncurses-compat-libs


pip3 install requests

make -C /postgres_extension/functions
make -C /postgres_extension/functions install
cd /
wget https://github.com/Kitware/CMake/releases/download/v3.27.4/cmake-3.27.4-linux-x86_64.tar.gz
tar -xvzf cmake-3.27.4-linux-x86_64.tar.gz
export PATH="/cmake-3.27.4-linux-x86_64/bin:${PATH}"

CPU_COUNT=$(nproc --all)

PLV8_BRANCH=v3.2.0
mkdir -p /build/
cd /build
git clone --branch "$PLV8_BRANCH" --depth 1 https://github.com/plv8/plv8

sed -i 's/cmake -Denable/CXX=clang++ CC=clang cmake -Denable/' plv8/Makefile
make -C plv8 -j"$CPU_COUNT" plv8_config.h
make -C plv8 -j"$CPU_COUNT" install
make -C /postgres_extension/functions -j"$CPU_COUNT"
make -C /postgres_extension/functions -j"$CPU_COUNT" install

# pgbackrest
yum -y install libxml2-devel libyaml-devel lz4-devel libzstd-devel bzip2-devel
mkdir -p /pgbackrest-build
wget -q -O - https://github.com/pgbackrest/pgbackrest/archive/release/2.42.tar.gz | tar zx -C /pgbackrest-build
cd /pgbackrest-build/pgbackrest-release-2.42/src && ./configure && make
Expand Down