Skip to content

Commit

Permalink
Change cadc-postgresql-dev to use Postgres15 / Remove previous versio…
Browse files Browse the repository at this point in the history
…ns that do not build (centos)
  • Loading branch information
stvoutsin committed Jul 12, 2024
1 parent 881f700 commit d63295d
Show file tree
Hide file tree
Showing 15 changed files with 2,633 additions and 134 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ Find changes for the upcoming release in the project's [changelog.d](https://git

<!-- scriv-insert-here -->

<a id='changelog-1.18.1'></a>
## 1.18.1 (2024-07-11)

## Changed

- Change Postgres to v15 and base image to fedora (centos endoflife)

<a id='changelog-1.18.0'></a>
## 1.18.0 (2024-06-24)

Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
27 changes: 0 additions & 27 deletions docker/cadc-postgresql-dev/Dockerfile.pg10

This file was deleted.

22 changes: 0 additions & 22 deletions docker/cadc-postgresql-dev/Dockerfile.pg12

This file was deleted.

17 changes: 17 additions & 0 deletions docker/cadc-postgresql-dev/Dockerfile.pg15
Original file line number Diff line number Diff line change
@@ -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"]
9 changes: 4 additions & 5 deletions docker/cadc-postgresql-dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
45 changes: 45 additions & 0 deletions docker/cadc-postgresql-dev/src/cadc-dev-postgresql-start
Original file line number Diff line number Diff line change
@@ -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"
42 changes: 0 additions & 42 deletions docker/cadc-postgresql-dev/src/cadc-dev-postgresql-start-12

This file was deleted.

15 changes: 0 additions & 15 deletions docker/cadc-postgresql-dev/src/init/init-postgres-10.sh

This file was deleted.

15 changes: 0 additions & 15 deletions docker/cadc-postgresql-dev/src/init/init-postgres-12.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;"
Expand Down
Loading

0 comments on commit d63295d

Please sign in to comment.