Skip to content

Commit

Permalink
update pg-ext
Browse files Browse the repository at this point in the history
  • Loading branch information
haobibo committed Apr 16, 2024
1 parent 0312971 commit ef2309a
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 1,359 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,17 @@ jobs:
- run: |
source ./tool.sh
build_image greenplum latest docker_greenplum/Dockerfile && push_image
qpod_postgres:
name: "postgres-ext"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
source ./tool.sh
build_image postgres-ext latest docker_postgres/postgres-ext.Dockerfile && push_image
build_image postgres-16-ext latest docker_postgres/postgres-ext.Dockerfile --build-arg BASE_IMG=postgres-16
build_image postgres-15-ext latest docker_postgres/postgres-ext.Dockerfile --build-arg BASE_IMG=postgres-15
push_image postgres
## Sync all images in this build (listed by "names") to mirror registry.
sync_images:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# QPod Data Lab - Docker Image Stack for BigData

[![License](https://img.shields.io/badge/License-BSD%203--Clause-green.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/QPod/lab-data/docker.yml?branch=main)](https://github.com/QPod/lab-data/actions/workflows/docker.yml)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/QPod/lab-data/build-docker.yml?branch=main)](https://github.com/QPod/lab-data/actions/workflows/build-docker.yml)
[![Recent Code Update](https://img.shields.io/github/last-commit/QPod/lab-data.svg)](https://github.com/QPod/lab-data/stargazers)

Please generously STAR★ our project or donate to us! [![GitHub Starts](https://img.shields.io/github/stars/QPod/data-lab.svg?label=Stars&style=social)](https://github.com/QPod/data-lab/stargazers)
Expand Down
17 changes: 7 additions & 10 deletions docker_postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

```shell
BUILDKIT_PROGRESS=plain \
docker build -t qpod0dev/postgres-ext -f ./postgres-ext.Dockerfile --build-arg BASE_NAMESPACE=qpod0dev .
docker build -t qpod0dev/postgres-16-ext -f ./postgres-ext.Dockerfile --build-arg BASE_NAMESPACE=qpod0dev .

( docker rm db-postgres || true )
( docker stop db-postgres && docker rm db-postgres || true )
docker run -d \
--name db-postgres \
-p 5432:5432 \
-e POSTGRES_PASSWORD=pg-password \
qpod0dev/postgres-ext
-e POSTGRES_PASSWORD=postgres \
qpod0dev/postgres-16-ext

docker exec -it db-postgres bash

Expand All @@ -26,14 +26,11 @@ ls -alh /usr/share/postgresql/${PG_MAJOR}/extension/*.control
## List of Extensions

```sql
SELECT extname AS name, extversion AS ver
FROM pg_extension ORDER BY extname;
SELECT extname AS name, extversion AS ver FROM pg_extension ORDER BY extname;

SELECT name, default_version AS ver, comment
FROM pg_available_extensions ORDER BY name;
SELECT name, default_version AS ver, comment FROM pg_available_extensions ORDER BY name;

SELECT name, default_version AS ver
FROM pg_available_extensions
SELECT name, default_version AS ver FROM pg_available_extensions
WHERE name NOT IN (SELECT extname AS name FROM pg_extension)
ORDER BY name;
```
Expand Down
2 changes: 1 addition & 1 deletion docker_postgres/postgres-ext.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Distributed under the terms of the Modified BSD License.

ARG BASE_NAMESPACE
ARG BASE_IMG="postgres"
ARG BASE_IMG="postgres-16"
FROM ${BASE_NAMESPACE:+$BASE_NAMESPACE/}${BASE_IMG}

LABEL maintainer="[email protected]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ BEGIN
END;
$$;

CREATE EXTENSION "hstore";
CREATE EXTENSION IF NOT EXISTS "hstore";
-- CALL enable_all_extensions();
15 changes: 11 additions & 4 deletions docker_postgres/rootfs/docker-entrypoint-initdb.d/01-init-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@ ls -alh /usr/share/postgresql/${PG_MAJOR}/extension/*.control

mkdir -pv ${PGDATA}/conf.d
echo "include_dir='./conf.d'" >> ${PGDATA}/postgresql.conf
sudo mv /opt/utils/pg-ext.conf ${PGDATA}/conf.d/

cat ${PGDATA}/conf.d/*
tail ${PGDATA}/postgresql.conf

cat <<EOT >> ${PGDATA}/conf.d/pg-ext.conf
shared_preload_libraries = 'citus,timescaledb,vector,pgaudit,pgautofailover,pg_qualstats,pg_squeeze,pg_net'
cron.database_name='${POSTGRES_DB:-postgres}'
EOT
cat ${PGDATA}/conf.d/*

# https://github.com/docker-library/postgres/blob/master/docker-entrypoint.sh
# form: docker-entrypoint.sh
docker_temp_server_stop
sleep 2s
docker_temp_server_start


psql -v ON_ERROR_STOP=0 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CALL enable_all_extensions();
SELECT extname AS name, extversion AS ver FROM pg_extension ORDER BY extname;
SELECT a.name, e.extversion AS installed, a.default_version AS avaliable, a.comment --e.extowner, e.extnamespace, e.extrelocatable
FROM pg_available_extensions AS a LEFT JOIN pg_extension AS e ON a.name = e.extname
ORDER BY name;
EOSQL
Loading

0 comments on commit ef2309a

Please sign in to comment.