diff --git a/.github/workflows/build_tembo_pg_slim.yaml b/.github/workflows/build_tembo_pg_slim.yaml index afe30e8..6cf6880 100644 --- a/.github/workflows/build_tembo_pg_slim.yaml +++ b/.github/workflows/build_tembo_pg_slim.yaml @@ -11,6 +11,7 @@ on: - 'dw-cnpg/**' - 'ml-cnpg/**' - 'geo-cnpg/**' + - 'analytics-cnpg/**' pull_request: branches: - main @@ -20,6 +21,7 @@ on: - 'dw-cnpg/**' - 'ml-cnpg/**' - 'geo-cnpg/**' + - 'analytics-cnpg/**' jobs: pre-build: @@ -364,6 +366,75 @@ jobs: docker push ${{ secrets.ECR_REGISTRY }}/$IMAGE_NAME-$tag done + analytics-cnpg-build: + needs: [pre-build, standard-cnpg-build] + permissions: + id-token: write + contents: read + runs-on: + - self-hosted + - dind + - large-8x8 + strategy: + fail-fast: false + matrix: ${{fromJson(needs.pre-build.outputs.build_matrix)}} + env: + CONTAINER_NAME: "analytics-cnpg" + steps: + - uses: actions/checkout@v4 + - name: Build Docker images based on conditions + run: | + if [[ "${{ matrix.pg_version }}" == "14" || "${{ matrix.pg_version }}" == "15" ]]; then + echo "Skipping Analytics build for Postgres 14 or 15" + exit 0 + fi + IMAGE_NAME=$CONTAINER_NAME:${{ matrix.pg_version }} + docker build ./$CONTAINER_NAME --build-arg PG_VERSION=${{ matrix.pg_version }} --build-arg TAG=${{ needs.pre-build.outputs.short_sha }} -t $IMAGE_NAME + shell: bash + - name: Login to Tembo Quay + uses: docker/login-action@v2 + with: + registry: ${{ secrets.QUAY_REPOSITORY }} + username: ${{ secrets.QUAY_USER_TEMBO }} + password: ${{ secrets.QUAY_PASSWORD_TEMBO }} + - name: Push to Quay + shell: bash + run: | + if [[ "${{ matrix.pg_version }}" == "14" || "${{ matrix.pg_version }}" == "15" ]]; then + echo "Skipping Analytics build for Postgres 14 or 15" + exit 0 + fi + set -xe + IMAGE_NAME=$CONTAINER_NAME:${{ matrix.pg_version }} + IFS=' ' read -ra TAG_ARRAY <<< "${{ needs.pre-build.outputs.tags }}" + for tag in "${TAG_ARRAY[@]}"; do + docker tag $IMAGE_NAME ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag + docker push ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag + done + - name: Configure AWS credentials for ECR + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.GHA_IAM_ROLE }} + role-session-name: images-gha-docker-build-and-push + aws-region: "us-east-1" + - name: Install awscli + uses: unfor19/install-aws-cli-action@v1 + - name: Push to ECR + shell: bash + run: | + if [[ "${{ matrix.pg_version }}" == "14" || "${{ matrix.pg_version }}" == "15" ]]; then + echo "Skipping Analytics build for Postgres 14 or 15" + exit 0 + fi + set -xe + IMAGE_NAME=$CONTAINER_NAME:${{ matrix.pg_version }} + IFS=' ' read -ra TAG_ARRAY <<< "${{ needs.pre-build.outputs.tags }}" + for tag in "${TAG_ARRAY[@]}"; do + aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ secrets.ECR_REGISTRY }}/$CONTAINER_NAME + docker tag $IMAGE_NAME ${{ secrets.ECR_REGISTRY }}/$IMAGE_NAME-$tag + docker push ${{ secrets.ECR_REGISTRY }}/$IMAGE_NAME-$tag + done + tembo-pg-cnpg-build: needs: [pre-build, tembo-pg-slim-build] permissions: diff --git a/analytics-cnpg/Dockerfile b/analytics-cnpg/Dockerfile new file mode 100644 index 0000000..ff10288 --- /dev/null +++ b/analytics-cnpg/Dockerfile @@ -0,0 +1,36 @@ +ARG PG_VERSION=16 +ARG TAG=c19d507 + +FROM quay.io/tembo/standard-cnpg:${PG_VERSION}-${TAG} +USER root + +WORKDIR / + +# Install build dependencies for parquet_s3_fdw and its dependent libraries +RUN apt-get update && apt-get install -y \ + git \ + g++ \ + cmake \ + ninja-build \ + libssl-dev \ + && rm -rf /var/lib/apt/lists/* + +# Clone and build parquet_s3_fdw +RUN git clone https://github.com/duckdb/duckdb && \ + cd duckdb && \ + GEN=ninja make + +RUN git clone https://github.com/duckdb/pg_duckdb.git && \ + cd pg_duckdb && \ + make install + +# cache all extensions +RUN set -eux; \ + cp -r $(pg_config --pkglibdir)/* /tmp/pg_pkglibdir; \ + cp -r $(pg_config --sharedir)/* /tmp/pg_sharedir; + +ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + +# Revert the postgres user to id 26 +RUN usermod -u 26 postgres +USER 26