From d63295d72bb31f90737c51eb1399e58fe8e04439 Mon Sep 17 00:00:00 2001 From: Stelios Voutsinas Date: Thu, 11 Jul 2024 11:06:37 -0700 Subject: [PATCH] Change cadc-postgresql-dev to use Postgres15 / Remove previous versions that do not build (centos) --- .github/workflows/ci.yaml | 2 +- CHANGELOG.md | 7 + build.sh | 2 +- docker/cadc-postgresql-dev/Dockerfile.pg10 | 27 - docker/cadc-postgresql-dev/Dockerfile.pg12 | 22 - docker/cadc-postgresql-dev/Dockerfile.pg15 | 17 + docker/cadc-postgresql-dev/README.md | 9 +- .../src/cadc-dev-postgresql-start | 45 + .../src/cadc-dev-postgresql-start-12 | 42 - .../src/{init => config}/pg_hba.conf | 0 .../src/{init => config}/postgresql.conf | 0 .../src/init/init-postgres-10.sh | 15 - .../src/init/init-postgres-12.sh | 15 - .../{init-content.sh => pgdb-init-content.sh} | 12 +- .../src/init/pgdb-init-postgres.sh | 2552 +++++++++++++++++ 15 files changed, 2633 insertions(+), 134 deletions(-) delete mode 100644 docker/cadc-postgresql-dev/Dockerfile.pg10 delete mode 100644 docker/cadc-postgresql-dev/Dockerfile.pg12 create mode 100644 docker/cadc-postgresql-dev/Dockerfile.pg15 create mode 100755 docker/cadc-postgresql-dev/src/cadc-dev-postgresql-start delete mode 100755 docker/cadc-postgresql-dev/src/cadc-dev-postgresql-start-12 rename docker/cadc-postgresql-dev/src/{init => config}/pg_hba.conf (100%) rename docker/cadc-postgresql-dev/src/{init => config}/postgresql.conf (100%) delete mode 100755 docker/cadc-postgresql-dev/src/init/init-postgres-10.sh delete mode 100755 docker/cadc-postgresql-dev/src/init/init-postgres-12.sh rename docker/cadc-postgresql-dev/src/init/{init-content.sh => pgdb-init-content.sh} (80%) create mode 100755 docker/cadc-postgresql-dev/src/init/pgdb-init-postgres.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index accfe3b..0c9926f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -53,6 +53,6 @@ jobs: with: context: docker/cadc-postgresql-dev push: true - file: docker/cadc-postgresql-dev/Dockerfile.pg12 + file: docker/cadc-postgresql-dev/Dockerfile.pg15 tags: | ghcr.io/lsst-sqre/tap-postgres-db:${{ steps.vars.outputs.tag }} diff --git a/CHANGELOG.md b/CHANGELOG.md index fc4b3f2..cd6a922 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ Find changes for the upcoming release in the project's [changelog.d](https://git + +## 1.18.1 (2024-07-11) + +## Changed + +- Change Postgres to v15 and base image to fedora (centos endoflife) + ## 1.18.0 (2024-06-24) diff --git a/build.sh b/build.sh index a50575a..14ff250 100755 --- a/build.sh +++ b/build.sh @@ -4,5 +4,5 @@ cp tap/build/libs/tap-1.1.war docker/tap/tap.war (cd docker/tap && docker build . -t lsstdax/tap-postgres-service:dev) -(cd docker/cadc-postgresql-dev && docker build . -f Dockerfile.pg12 -t lsstdax/tap-postgres-db:dev) +(cd docker/cadc-postgresql-dev && docker build . -f Dockerfile.pg15 -t lsstdax/tap-postgres-db:dev) (cd docker/uws && docker build . -t lsstdax/tap-postgres-uws:dev) diff --git a/docker/cadc-postgresql-dev/Dockerfile.pg10 b/docker/cadc-postgresql-dev/Dockerfile.pg10 deleted file mode 100644 index 051a588..0000000 --- a/docker/cadc-postgresql-dev/Dockerfile.pg10 +++ /dev/null @@ -1,27 +0,0 @@ -FROM centos:7 - -# To allow --build-arg switch -ARG PG_RPM_URL=https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm - -# install required software -RUN yum update -y - -# repositories and keys -RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \ - && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 -RUN yum install -y ${PG_RPM_URL} \ - && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG - -# packages -RUN yum -y install postgresql10-server-10.9-1PGDG.rhel7 postgresql10-contrib-10.9-1PGDG.rhel7 postgresql10-devel-10.9-1PGDG.rhel7 - -# CADC build of pgsphere for postgresql10-server -RUN yum -y install https://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/software/pgsphere10-1.1.5-1.el7.centos.x86_64.rpm - -RUN yum clean all - -RUN mkdir -p /logs -COPY src/init/* /var/lib/pgsql/10/ - -COPY src/cadc-dev-postgresql-start-10 /usr/bin/cadc-dev-postgresql-start -CMD ["/usr/bin/cadc-dev-postgresql-start"] diff --git a/docker/cadc-postgresql-dev/Dockerfile.pg12 b/docker/cadc-postgresql-dev/Dockerfile.pg12 deleted file mode 100644 index 543f6ca..0000000 --- a/docker/cadc-postgresql-dev/Dockerfile.pg12 +++ /dev/null @@ -1,22 +0,0 @@ -FROM centos:7 - -# external URLs; allow --build-arg switch -ARG PGDG=https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm -ARG PGSPHERE=https://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/software/pgsphere12-1.2.0-1.el7.x86_64.rpm - -# repositories and keys -RUN yum -y install centos-release-scl epel-release ${PGDG} \ - && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 \ - && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo \ - && rpm -q gpg-pubkey --qf '%{NAME}-%{VERSION}-%{RELEASE}\t%{SUMMARY}\n' - -# packages -RUN yum -y install postgresql12-server postgresql12-contrib ${PGSPHERE} \ - && yum -y clean all - -RUN mkdir -p /logs -COPY src/init/* /var/lib/pgsql/12/ - -COPY src/cadc-dev-postgresql-start-12 /usr/bin/cadc-dev-postgresql-start -CMD ["/usr/bin/cadc-dev-postgresql-start"] - diff --git a/docker/cadc-postgresql-dev/Dockerfile.pg15 b/docker/cadc-postgresql-dev/Dockerfile.pg15 new file mode 100644 index 0000000..49193a9 --- /dev/null +++ b/docker/cadc-postgresql-dev/Dockerfile.pg15 @@ -0,0 +1,17 @@ +FROM fedora:40 + +# external URLs; allow --build-arg switch +ARG PGDG=https://download.postgresql.org/pub/repos/yum/reporpms/F-40-x86_64/pgdg-fedora-repo-latest.noarch.rpm +ARG PGSPHERE=https://ws-cadc.canfar.net/vault/files/pdowler/rpms/pgsphere15-1.4.2-1.fc40.x86_64.rpm + +# install repositories, server, extensions +RUN dnf -y install ${PGDG} \ + && dnf -y install postgresql15-server postgresql15-contrib ${PGSPHERE} \ + && dnf -y clean all + +RUN mkdir -p /config /logs /var/lib/pgsql/15 +COPY src/config/* /var/lib/pgsql/15/ +COPY src/init/* /usr/local/bin/ + +COPY src/cadc-dev-postgresql-start /usr/bin/ +CMD ["/usr/bin/cadc-dev-postgresql-start"] diff --git a/docker/cadc-postgresql-dev/README.md b/docker/cadc-postgresql-dev/README.md index 302d3f6..5ef0724 100644 --- a/docker/cadc-postgresql-dev/README.md +++ b/docker/cadc-postgresql-dev/README.md @@ -4,8 +4,7 @@ This postgresql instance is designed for development support and has a very low level of security. -Note: the PostgreSQL 10.x build includes the pgsphere extension. -TODO: add pgsphere extension to the PostgreSQL 12.x build once there is an rpm available from CADC. +Note: the PostgreSQL 10.x & PostgreSQL 15.x build includes the pgsphere extension. ## databases On startup, the following user accounts are created (name : password): @@ -35,11 +34,11 @@ Like the TAP-related schemas, all content schemas are created in each dcatabnase database and one schema is needed to start a useful postgresql server. The `cadmin` account will have full authorization in these "content" schema(s). -# PostgreSQL 12.x +# PostgreSQL 15.x ## building it ``` -docker build -t cadc-postgresql-dev -f Dockerfile.pg12 . +docker build -t cadc-postgresql-dev -f Dockerfile.pg15 . ``` ## checking it @@ -49,7 +48,7 @@ docker run -it cadc-postgresql-dev:latest /bin/bash ## running it ``` -docker run -d --volume=/path/to/config:/config:ro --volume=/path/to/logs:/logs:rw --name pg12db cadc-postgresql-dev:latest +docker run -d --volume=/path/to/config:/config:ro --volume=/path/to/logs:/logs:rw --name pg15db cadc-postgresql-dev:latest ``` One can expose the postgres server port (-p {external http port}:5432) or access it from an application diff --git a/docker/cadc-postgresql-dev/src/cadc-dev-postgresql-start b/docker/cadc-postgresql-dev/src/cadc-dev-postgresql-start new file mode 100755 index 0000000..d74995a --- /dev/null +++ b/docker/cadc-postgresql-dev/src/cadc-dev-postgresql-start @@ -0,0 +1,45 @@ +#!/bin/bash + +# log to external +LOGDIR=/logs +LOG=$LOGDIR/do-init.log + +touch $LOG + +echo -n "START: " +date + +INITDB=0 + +if [ -e /var/lib/pgsql/${PG}/data/postgresql.conf ]; then + echo "do-init: detected existing setup... skipping database init" +else + INITDB=1 +fi + +if [ $INITDB == 1 ]; then + # change ownership of injected config files + chown -R postgres:postgres /var/lib/pgsql/${PG}/* + su -l postgres -c '/bin/bash /usr/local/bin/pgdb-init-postgres.sh' +fi + +# start postgresql server +su -l postgres -c '/usr/pgsql-15/bin/postmaster -D /var/lib/pgsql/15/data' > $LOGDIR/postgresql.log & + +sleep 6 +if [ $INITDB == 1 ]; then + if [ -e /config/init-content-schemas.sh ]; then + cp /config/init-content-schemas.sh /usr/local/bin/ + # create standard user(s), database(s), schema(s) + su -l postgres -c '/bin/bash /usr/local/bin/pgdb-init-content.sh' + else + echo "not found: /config/init-content-schemas.sh" + fi +fi + +echo -n "init DONE: " +date + +echo "waiting for postmaster to terminate..." +wait +echo "wait returned... exiting" diff --git a/docker/cadc-postgresql-dev/src/cadc-dev-postgresql-start-12 b/docker/cadc-postgresql-dev/src/cadc-dev-postgresql-start-12 deleted file mode 100755 index c518d3f..0000000 --- a/docker/cadc-postgresql-dev/src/cadc-dev-postgresql-start-12 +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# log to external -LOGDIR=/logs -LOG=$LOGDIR/do-init.log - -touch $LOG - -echo -n "START: " -date - -INITDB=0 - -if [ -e /var/lib/pgsql/12/data/postgresql.conf ]; then - echo "do-init: detected existing setup... skipping database init" -else - INITDB=1 -fi - -if [ $INITDB == 1 ]; then - # change ownership of injected config files - chown -R postgres.postgres /var/lib/pgsql/12/* - su -l postgres -c '/bin/bash /var/lib/pgsql/12/init-postgres-12.sh' -fi - -# start postgresql server -su -l postgres -c '/usr/pgsql-12/bin/postmaster -D /var/lib/pgsql/12/data' > $LOGDIR/postgresql.log & - -sleep 6 -if [ $INITDB == 1 ]; then - # create standard user(s), database(s), schema(s) - su -l postgres -c '/bin/bash /var/lib/pgsql/12/init-content.sh' -fi - -echo -n "init DONE: " -date - -echo "waiting for postmaster to terminate..." -wait -echo "wait returned... exiting" - - diff --git a/docker/cadc-postgresql-dev/src/init/pg_hba.conf b/docker/cadc-postgresql-dev/src/config/pg_hba.conf similarity index 100% rename from docker/cadc-postgresql-dev/src/init/pg_hba.conf rename to docker/cadc-postgresql-dev/src/config/pg_hba.conf diff --git a/docker/cadc-postgresql-dev/src/init/postgresql.conf b/docker/cadc-postgresql-dev/src/config/postgresql.conf similarity index 100% rename from docker/cadc-postgresql-dev/src/init/postgresql.conf rename to docker/cadc-postgresql-dev/src/config/postgresql.conf diff --git a/docker/cadc-postgresql-dev/src/init/init-postgres-10.sh b/docker/cadc-postgresql-dev/src/init/init-postgres-10.sh deleted file mode 100755 index 6fee4ec..0000000 --- a/docker/cadc-postgresql-dev/src/init/init-postgres-10.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -## this script runs on the container (as postgres) before the postgres server starts ## - -PGBASE=/var/lib/pgsql/10 - -/usr/pgsql-10/bin/initdb -D $PGBASE/data --encoding=UTF8 --lc-collate=C --lc-ctype=C - -## modified config files are provided by the container in the $PGBASE dir -for cf in $PGBASE/*.conf; do - FNAME=$(basename $cf) - \rm -f $PGBASE/data/$FNAME - ln -s $cf $PGBASE/data/$FNAME -done - diff --git a/docker/cadc-postgresql-dev/src/init/init-postgres-12.sh b/docker/cadc-postgresql-dev/src/init/init-postgres-12.sh deleted file mode 100755 index 781d1b1..0000000 --- a/docker/cadc-postgresql-dev/src/init/init-postgres-12.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -## this script runs on the container (as postgres) before the postgres server starts ## - -PGBASE=/var/lib/pgsql/12 - -/usr/pgsql-12/bin/initdb -D $PGBASE/data --encoding=UTF8 --lc-collate=C --lc-ctype=C - -## modified config files are provided by the container in the $PGBASE dir -for cf in $PGBASE/*.conf; do - FNAME=$(basename $cf) - \rm -f $PGBASE/data/$FNAME - ln -s $cf $PGBASE/data/$FNAME -done - diff --git a/docker/cadc-postgresql-dev/src/init/init-content.sh b/docker/cadc-postgresql-dev/src/init/pgdb-init-content.sh similarity index 80% rename from docker/cadc-postgresql-dev/src/init/init-content.sh rename to docker/cadc-postgresql-dev/src/init/pgdb-init-content.sh index 1320c1e..f878b83 100755 --- a/docker/cadc-postgresql-dev/src/init/init-content.sh +++ b/docker/cadc-postgresql-dev/src/init/pgdb-init-content.sh @@ -3,15 +3,16 @@ ## this scripts runs in the container (as postgres) after the postgres process is started ## ## create accounts -psql --command "CREATE USER cadmin WITH ENCRYPTED PASSWORD 'pw-cadmin'" +psql --command "CREATE USER cadmin WITH ENCRYPTED PASSWORD 'pw-cadmin'" psql --command "CREATE USER tapuser WITH ENCRYPTED PASSWORD 'pw-tapuser';" psql --command "CREATE USER tapadm WITH ENCRYPTED PASSWORD 'pw-tapadm';" -DATABASES="" -SCHEMAS="" -. /config/init-content-schemas.sh +. /usr/local/bin/init-content-schemas.sh -for DBNAME in $DATABASES; do +echo "catalogs: $CATALOGS" +echo "content schemas: $SCHEMAS" +for DBNAME in $CATALOGS; do + echo "create db: $DBNAME" createdb $DBNAME ## enable extensions: citext pgsphere @@ -24,7 +25,6 @@ for DBNAME in $DATABASES; do psql -d $DBNAME --command "CREATE SCHEMA tap_upload AUTHORIZATION tapuser;" ## create content schema(s) - echo "content schemas: $SCHEMAS" for SN in $SCHEMAS; do echo "create schema: $SN" psql -d $DBNAME --command "CREATE SCHEMA $SN AUTHORIZATION cadmin;" diff --git a/docker/cadc-postgresql-dev/src/init/pgdb-init-postgres.sh b/docker/cadc-postgresql-dev/src/init/pgdb-init-postgres.sh new file mode 100755 index 0000000..ef5cab8 --- /dev/null +++ b/docker/cadc-postgresql-dev/src/init/pgdb-init-postgres.sh @@ -0,0 +1,2552 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + docker-base/cadc-postgresql-dev/src/init/pgdb-init-postgres.sh at 213f29ca0f2b1221d297aae49a6f47b15e4d4039 · opencadc/docker-base · GitHub + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ Skip to content + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + +
+ +
+ + + + + + + + +
+ + + + + +
+ + + + + + + + + +
+
+
+ + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + / + + docker-base + + + Public +
+ + +
+ +
+ + +
+
+ +
+
+ + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + +

Latest commit

 

History

History
executable file
·
16 lines (11 loc) · 427 Bytes

pgdb-init-postgres.sh

File metadata and controls

executable file
·
16 lines (11 loc) · 427 Bytes
+
+ + + + +
+ +
+ +
+
+ +
+ +
+

Footer

+ + + + +
+
+ + + + + © 2024 GitHub, Inc. + +
+ + +
+
+ + + + + + + + + + + + + + + + + + + +
+ +
+
+ + +