Skip to content

Commit

Permalink
Fix for CI docker builds. (#235)
Browse files Browse the repository at this point in the history
* Don't build plrust support in Docker images pushed in CI. Update PLRUST version.

* Add comments to dockerfile

* update plrustversion

* Start incremental migration tests at 0.3.0 as pg_partman which is only used prior to v0.3.0 introduced a breaking change with no way to pin to earlier version

* Add platforms and comments to ci build for PRs

* remove verbose name
  • Loading branch information
bitner authored Jan 24, 2024
1 parent ebb45f1 commit 20b00f7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ jobs:
echo "pytag=${{ env.REGISTRY }}/stac-utils/pgstac-pyrust:$ref" >>$GITHUB_OUTPUT;
echo "buildpy=$buildpg" >>$GITHUB_OUTPUT;
# This builds a base postgres image that has everything installed to be able to run pgstac. This image does not have pgstac itself installed.
buildpg:
name: Build and push base postgres
name: Build and push base postgres image
if: ${{ needs.changes.outputs.buildpgdocker == 'true' }}
runs-on: ubuntu-latest
needs: [changes]
Expand All @@ -62,8 +63,9 @@ jobs:
- name: Build and Push Base Postgres
uses: docker/build-push-action@v4
with:
platforms: linux/amd64,linux/arm64
context: .
target: pgstacbase-plrust
target: pgstacbase
file: docker/pgstac/Dockerfile
tags: ${{ needs.changes.outputs.pgdocker }}
push: true
Expand All @@ -87,6 +89,7 @@ jobs:
- name: Build and Push Base pyrust
uses: docker/build-push-action@v4
with:
platforms: linux/amd64,linux/arm64
context: .
target: pyrustbase
file: docker/pypgstac/Dockerfile
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false


# This builds a base postgres image that has everything installed to be able to run pgstac.
buildpg:
name: Build and push base postgres
name: Build and push base postgres image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -46,16 +46,17 @@ jobs:
with:
platforms: linux/amd64,linux/arm64
context: .
target: pgstacbase-plrust
target: pgstacbase
file: docker/pgstac/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
cache-from: type=gha
cache-to: type=gha, mode=max

# This builds a postgres image that already has pgstac installed to the tagged version
buildpgstac:
name: Build and push base postgres
name: Build and push base postgres with pgstac installed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -78,7 +79,7 @@ jobs:
with:
platforms: linux/amd64,linux/arm64
context: .
target: pgstac-plrust
target: pgstac
file: docker/pgstac/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
8 changes: 6 additions & 2 deletions docker/pgstac/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ARG PG_MAJOR=15
ARG POSTGIS_MAJOR=3

# Base postgres image that pgstac can be installed onto
FROM postgres:${PG_MAJOR}-bullseye as pgstacbase
ARG POSTGIS_MAJOR
RUN \
Expand All @@ -17,9 +18,10 @@ RUN \
&& rm -rf /var/lib/apt/lists/*
COPY docker/pgstac/dbinit/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh

# Base postgres image with plrust installed that can be used for future development using plrust
FROM pgstacbase as pgstacbase-plrust
ENV PLRUSTVERSION=1.2.3
ENV RUSTVERSION=1.70.0
ENV PLRUSTVERSION=1.2.7
ENV RUSTVERSION=1.72.0
ENV PLRUSTDOWNLOADURL=https://github.com/tcdi/plrust/releases/download/
ENV PLRUSTFILE=plrust-trusted-${PLRUSTVERSION}_${RUSTVERSION}-debian-pg${PG_MAJOR}-amd64.deb
ENV PLRUSTURL=${PLRUSTDOWNLOADURL}v${PLRUSTVERSION}/${PLRUSTFILE}
Expand Down Expand Up @@ -60,11 +62,13 @@ COPY docker/pgstac/dbinit/pgstac-rust.sh 991_plrust.sh
USER root
RUN apt-get install -y /${PLRUSTFILE}

# The pgstacbase image with latest version of pgstac installed
FROM pgstacbase as pgstac
WORKDIR /docker-entrypoint-initdb.d
COPY docker/pgstac/dbinit/pgstac.sh 990_pgstac.sh
COPY src/pgstac/pgstac.sql 999_pgstac.sql

# The pgstacbase-plrust image with the latest version of pgstac installed
FROM pgstacbase-plrust as pgstac-plrust
WORKDIR /docker-entrypoint-initdb.d
COPY docker/pgstac/dbinit/pgstac.sh 990_pgstac.sh
Expand Down
4 changes: 2 additions & 2 deletions docker/pypgstac/bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ ALTER DATABASE pgstac_test_migration SET search_path to pgstac, public;
ALTER DATABASE pgstac_test_migration SET client_min_messages to $CLIENTMESSAGES;
EOSQL
export PGDATABASE=pgstac_test_migration
echo "Migrating from version 0.1.9"
echo "Migrating from version 0.3.0"
cd $SRCDIR/pypgstac
python -m venv venv
source venv/bin/activate
pip install --cache /tmp/.pipcache --upgrade pip
pip install --cache /tmp/.pipcache -e .[dev,test,psycopg]

pypgstac migrate --toversion 0.1.9
pypgstac migrate --toversion 0.3.0
pypgstac --version

pypgstac migrate
Expand Down

0 comments on commit 20b00f7

Please sign in to comment.