Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Experimental Postgres Upgrade #1220

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
4f4ce73
WIP: Experimental postgres upgrade
NickPhura Feb 26, 2024
b0ff189
Update existing bc/dc to point to new postgres image
NickPhura Feb 26, 2024
eb2ba51
Update dc
NickPhura Feb 26, 2024
d2d17c3
Try adding dockerfiles
NickPhura Feb 27, 2024
dc163bf
Update dockerfile
NickPhura Feb 27, 2024
6c17493
Update dockerfile
NickPhura Feb 27, 2024
d8c32df
Update dockerfile 2
NickPhura Feb 27, 2024
8859762
Add sclorg postgres files
NickPhura Feb 27, 2024
a7365e7
Updates
NickPhura Feb 27, 2024
094acc3
Update dockerfile
NickPhura Feb 27, 2024
255e6ea
Update docker debug
NickPhura Feb 27, 2024
5a76d9b
update command
NickPhura Feb 27, 2024
ff4d9c7
Updates
NickPhura Feb 27, 2024
12e5ac8
update
NickPhura Feb 27, 2024
d617918
update 3
NickPhura Feb 27, 2024
81d88f6
update 4
NickPhura Feb 27, 2024
453f1bf
Updates 5
NickPhura Feb 27, 2024
8842e3e
Add sclorg 15
NickPhura Feb 27, 2024
3b02ba7
Update to use psql 15 on rhel 9
NickPhura Feb 27, 2024
f9245ad
Updates
NickPhura Feb 27, 2024
3c9dec5
Updates 2
NickPhura Feb 27, 2024
1ada666
Updates ?
NickPhura Feb 27, 2024
69232f0
Tweak
NickPhura Feb 27, 2024
27a9782
Tweak 2
NickPhura Feb 27, 2024
9130f05
Update
NickPhura Feb 27, 2024
a64cfd4
Add packages
NickPhura Feb 27, 2024
1452311
Enable module
NickPhura Feb 27, 2024
b420b5b
Tweak 2
NickPhura Feb 27, 2024
e54d0c8
Add contrib
NickPhura Feb 27, 2024
00827eb
changes 1
NickPhura Feb 27, 2024
a6f2b44
change
NickPhura Feb 27, 2024
2190197
update
NickPhura Feb 27, 2024
0668dbe
updates
NickPhura Feb 27, 2024
133d4ef
updates
NickPhura Feb 27, 2024
1feab26
remove verification
NickPhura Feb 27, 2024
41559be
updates
NickPhura Feb 27, 2024
7ab4618
updates
NickPhura Feb 27, 2024
54aff8d
updates
NickPhura Feb 27, 2024
40dbfaa
updates
NickPhura Feb 27, 2024
1114ada
updates
NickPhura Feb 27, 2024
f9262b8
updates
NickPhura Feb 27, 2024
ac83b63
updates
NickPhura Feb 27, 2024
4626a26
updates
NickPhura Feb 27, 2024
c317eb6
updates
NickPhura Feb 27, 2024
f1ddd9c
updates
NickPhura Feb 27, 2024
3d7d47e
updates
NickPhura Feb 27, 2024
60ae765
updates
NickPhura Feb 28, 2024
50a5766
updates
NickPhura Feb 28, 2024
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
133 changes: 133 additions & 0 deletions containers/postgres15-2/openshift/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#
# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY.
#
ARG BASE_IMAGE=postgres:15-alpine3.18
FROM ${BASE_IMAGE}

# USER 0

# RUN usermod -G "" postgres
# RUN test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)"

RUN mkdir -p /var/lib/pgsql/data /var/run/postgresql \
&& chgrp -R 0 /var/lib/pgsql /var/run/postgresql \
&& chmod -R g=u /var/lib/pgsql /var/run/postgresql

LABEL maintainer="PostGIS Project - https://postgis.net" \
org.opencontainers.image.description="PostGIS 3.4.2 spatial database extension with PostgreSQL 15 Alpine" \
org.opencontainers.image.source="https://github.com/postgis/docker-postgis"

ENV POSTGIS_VERSION 3.4.2
ENV POSTGIS_SHA256 17aa8760a5c4fcb9a1fdc750c1c9aca0198a35dd1e320628064c43f178eefed2

RUN set -eux \
&& apk add --no-cache --virtual .fetch-deps \
ca-certificates \
openssl \
tar \
\
&& wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \
&& echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \
&& mkdir -p /usr/src/postgis \
&& tar \
--extract \
--file postgis.tar.gz \
--directory /usr/src/postgis \
--strip-components 1 \
&& rm postgis.tar.gz \
\
&& apk add --no-cache --virtual .build-deps \
\
gdal-dev \
geos-dev \
proj-dev \
proj-util \
sfcgal-dev \
\
# The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains
# the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL.
# This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077
$DOCKER_PG_LLVM_DEPS \
\
autoconf \
automake \
cunit-dev \
file \
g++ \
gcc \
gettext-dev \
git \
json-c-dev \
libtool \
libxml2-dev \
make \
pcre2-dev \
perl \
protobuf-c-dev \
\
# build PostGIS - with Link Time Optimization (LTO) enabled
&& cd /usr/src/postgis \
&& gettextize \
&& ./autogen.sh \
&& ./configure \
--enable-lto \
&& make -j$(nproc) \
&& make install \
\
# This section is for refreshing the proj data for the regression tests.
# It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316
# This increases the Docker image size by about 1 MB.
&& projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \
&& projsync --system-directory --file us_noaa_eshpgn \
&& projsync --system-directory --file us_noaa_prvi \
&& projsync --system-directory --file us_noaa_wmhpgn \
# This section performs a regression check.
&& mkdir /tempdb \
&& chown -R postgres:postgres /tempdb \
&& su postgres -c 'pg_ctl -D /tempdb init' \
&& su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \
&& cd regress \
&& make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \
\
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \
&& su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \
&& su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \
&& su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \
&& su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \
\
&& su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \
&& rm -rf /tempdb \
&& rm -rf /tmp/logfile \
&& rm -rf /tmp/pgis_reg \
# add .postgis-rundeps
&& apk add --no-cache --virtual .postgis-rundeps \
\
gdal \
geos \
proj \
sfcgal \
\
json-c \
libstdc++ \
pcre2 \
protobuf-c \
\
# ca-certificates: for accessing remote raster files
# fix https://github.com/postgis/docker-postgis/issues/307
ca-certificates \
# clean
&& cd / \
&& rm -rf /usr/src/postgis \
&& apk del .fetch-deps .build-deps \
# At the end of the build, we print the collected information
# from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes.
&& cat /_pgis_full_version.txt

COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh
COPY ./update-postgis.sh /usr/local/bin
25 changes: 25 additions & 0 deletions containers/postgres15-2/openshift/docker/initdb-postgis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -e

# Perform all actions as $POSTGRES_USER
export PGUSER="$POSTGRES_USER"

# Create the 'template_postgis' template db
"${psql[@]}" <<- 'EOSQL'
CREATE DATABASE template_postgis IS_TEMPLATE true;
EOSQL

# Load PostGIS into both template_database and $POSTGRES_DB
for DB in template_postgis "$POSTGRES_DB"; do
echo "Loading PostGIS extensions into $DB"
"${psql[@]}" --dbname="$DB" <<-'EOSQL'
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS postgis_topology;
-- Reconnect to update pg_setting.resetval
-- See https://github.com/postgis/docker-postgis/issues/288
\c
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;
EOSQL
done
28 changes: 28 additions & 0 deletions containers/postgres15-2/openshift/docker/update-postgis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

set -e

# Perform all actions as $POSTGRES_USER
export PGUSER="$POSTGRES_USER"

POSTGIS_VERSION="${POSTGIS_VERSION%%+*}"

# Load PostGIS into both template_database and $POSTGRES_DB
for DB in template_postgis "$POSTGRES_DB" "${@}"; do
echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION"
psql --dbname="$DB" -c "
-- Upgrade PostGIS (includes raster)
CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION';
ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION';

-- Upgrade Topology
CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION';
ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION';

-- Install Tiger dependencies in case not already installed
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
-- Upgrade US Tiger Geocoder
CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION';
ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION';
"
done
145 changes: 145 additions & 0 deletions containers/postgres15-2/openshift/postgres-15-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
kind: Template
apiVersion: template.openshift.io/v1
metadata:
name: ${NAME}-build-template
parameters:
- name: NAME
displayName: Name
description: The name assigned to all of the objects defined in this template.
required: true
value: postgres-postgis
- name: SUFFIX
displayName: Suffix
description: A name suffix used for all objects
required: false
value:
- name: APP_NAME
displayName: App Name
description: Used to group components together in the OpenShift console.
required: true
value: biohubbc
- name: APP_GROUP
displayName: App Group
description: The name assigned to all of the deployments in this project.
required: true
value: biohubbc
- name: GIT_REPO_URL
displayName: Git Repo URL
description: The URL to your GIT repo.
required: true
value: https://github.com/postgis/docker-postgis.git
- name: GIT_REF
displayName: Git Reference
description: The git reference or branch.
required: true
value: master
- name: SOURCE_CONTEXT_DIR
displayName: Source Context Directory
description: The source context directory.
required: false
value: 15-3.4/alpine
- name: OUTPUT_IMAGE_TAG
displayName: Output Image Tag
description: The tag given to the built image.
required: true
value: "15-3.4-alpine"
- name: DOCKER_FILE_PATH
displayName: Docker File Path
description: The path to the docker file.
required: true
value: Dockerfile
- name: SOURCE_IMAGE_KIND
displayName: Source Image Kind
description: The 'kind' (type) of the source image; typically ImageStreamTag, or DockerImage.
required: false
value: DockerImage
# - name: SOURCE_IMAGE_NAME
# displayName: Source Image Name
# description: The name of the source image. If specified, this overrides the 'FROM' spec in the Docker file.
# required: false
# value:
# - name: SOURCE_IMAGE_TAG
# displayName: Source Image Tag
# description: The tag of the source image. If specified, this overrides the 'FROM' spec in the Docker file.
# required: false
# value:
- name: CPU_LIMIT
displayName: Resources CPU Limit
description: The resources CPU limit (in cores) for this build; 0 = use default.
required: true
value: "0"
- name: MEMORY_LIMIT
displayName: Resources Memory Limit
description: The resources Memory limit (in Mi, Gi, etc) for this build; 0Mi = use default.
required: true
value: 0Mi
- name: CPU_REQUEST
displayName: Resources CPU Request
description: The resources CPU request (in cores) for this build; 0 = use default.
required: true
value: "0"
- name: MEMORY_REQUEST
displayName: Resources Memory Request
description: The resources Memory request (in Mi, Gi, etc) for this build; 0Mi = use default.
required: true
value: 0Mi
objects:
- kind: ImageStream
apiVersion: image.openshift.io/v1
metadata:
name: ${NAME}
labels:
name: ${NAME}
app: ${APP_NAME}${SUFFIX}
app-group: ${APP_GROUP}

- kind: BuildConfig
apiVersion: build.openshift.io/v1
metadata:
name: ${NAME}
labels:
name: ${NAME}
app: ${APP_NAME}${SUFFIX}
app-group: ${APP_GROUP}
spec:
runPolicy: Serial
source:
type: Git
git:
ref: ${GIT_REF}
uri: ${GIT_REPO_URL}
contextDir: ${SOURCE_CONTEXT_DIR}
# secrets:
# - secret:
# name: platform-services-controlled-etc-pki-entitlement
# destinationDir: etc-pki-entitlement
# configMaps:
# - configMap:
# name: platform-services-controlled-rhsm-conf
# destinationDir: rhsm-conf
# - configMap:
# name: platform-services-controlled-rhsm-ca
# destinationDir: rhsm-ca
strategy:
type: Docker
dockerStrategy:
noCache: true
imageOptimizationPolicy: SkipLayers
dockerfilePath: ${DOCKER_FILE_PATH}
# from:
# kind: ${SOURCE_IMAGE_KIND}
# name: ${SOURCE_IMAGE_NAME}:${SOURCE_IMAGE_TAG}
output:
to:
kind: ImageStreamTag
name: ${NAME}:${OUTPUT_IMAGE_TAG}
resources:
requests:
cpu: ${CPU_REQUEST}
memory: ${MEMORY_REQUEST}
limits:
cpu: ${CPU_LIMIT}
memory: ${MEMORY_LIMIT}
triggers:
- type: ImageChange
- type: ConfigChange
Loading
Loading