Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
kaznak committed Feb 1, 2025
1 parent b04b319 commit 36a1f25
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 0 deletions.
121 changes: 121 additions & 0 deletions postgresql/16/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
##################################################################
##################################################################
##################################################################
FROM postgres:16-bookworm as builder

RUN echo '/var/lib/apt/lists/*' ./del.lst > ./del.lst

# Set locale
RUN localedef -i ja_JP -c -f UTF-8 -A /usr/share/locale/locale.alias ja_JP.UTF-8

##################################################################
# update repository
RUN apt update

# build and install extentions
COPY pkg.lst ./
RUN ls ./pkg.lst >> ./del.lst
RUN apt install -y $(sed -e 's/#.*$//' ./pkg.lst)

# setup postgres apt respository
# https://wiki.postgresql.org/wiki/Apt
RUN yes | /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

# setup pgroonga apt respository
# https://pgroonga.github.io/ja/install/debian.html
RUN wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
RUN ls ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb >> ./del.lst
RUN apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
RUN wget https://packages.groonga.org/debian/groonga-apt-source-latest-$(lsb_release --codename --short).deb
RUN ls ./groonga-apt-source-latest-$(lsb_release --codename --short).deb >> ./del.lst
RUN apt install -y -V ./groonga-apt-source-latest-$(lsb_release --codename --short).deb

##################################################################
# install apt packages

RUN apt update
RUN apt install -y -V \
postgresql-16-pgdg-pgroonga \
groonga-tokenizer-mecab \
\
postgresql-16-pgvector

##################################################################
# install pgx packages

# pgvector
RUN git clone --branch v0.5.1 https://github.com/pgvector/pgvector.git
RUN ls -d ./pgvector >> ./del.lst
RUN cd pgvector && make && make install && cd ../

# pldebugger
RUN git clone https://github.com/EnterpriseDB/pldebugger.git
RUN ls -d ./pldebugger >> ./del.lst
RUN cd pldebugger && git checkout v1.5 && USE_PGXS=1 make install && cd ../

##################################################################
# install pgrx packages
# # pgrx requires very log time to build. So, it is placed here.

# setup rust/pgrx environment
RUN curl https://sh.rustup.rs -sSf > rustup-install.sh
RUN ls ./rustup-install.sh >> ./del.lst
RUN sh rustup-install.sh -y
RUN ls -d $HOME/.cargo $HOME/.rustup >> ./del.lst


# ulid
RUN . "$HOME/.cargo/env" && cargo install [email protected]
RUN . "$HOME/.cargo/env" && RUST_BACKTRACE=full cargo pgrx init
# RUN . "$HOME/.cargo/env" && export PGRX_HOME=${HOME:-"/root"}/.pgrx
RUN ls -d $HOME/.pgrx >> ./del.lst

RUN git clone https://github.com/pksunkara/pgx_ulid.git
RUN ls -d ./pgx_ulid >> ./del.lst
RUN . "$HOME/.cargo/env" && cd pgx_ulid && git checkout f84954cf63fc8c80d964ac970d9eceed3c791196 && cd ../
RUN . "$HOME/.cargo/env" && cd pgx_ulid && RUST_BACKTRACE=full cargo pgrx install -c /usr/lib/postgresql/16/bin/pg_config && cd ../

# pg_uuidv7
RUN . "$HOME/.cargo/env" && cargo install [email protected]
RUN . "$HOME/.cargo/env" && RUST_BACKTRACE=full cargo pgrx init
# RUN . "$HOME/.cargo/env" && export PGRX_HOME=${HOME:-"/root"}/.pgrx
RUN ls -d $HOME/.pgrx >> ./del.lst

RUN git clone https://github.com/craigpastro/pg_uuidv7.git
RUN ls -d ./pg_uuidv7 >> ./del.lst
RUN . "$HOME/.cargo/env" && cd pg_uuidv7 && RUST_BACKTRACE=full cargo pgrx install -c /usr/lib/postgresql/16/bin/pg_config && cd ../

##################################################################
# clean up build and install environment
RUN apt remove -y --purge --auto-remove $(grep -E '#.* remove($| )' pkg.lst | sed -e 's/#.*$//')
RUN apt-get clean

RUN rm -rf $(tr '\n' ' ' < ./del.lst)

# remove the line `. "$HOME/.cargo/env"` from $HOME/.bashrc and $HOME/.profile
RUN sed -i '$d' $HOME/.bashrc
RUN sed -i '$d' $HOME/.profile

##################################################################
##################################################################
##################################################################
FROM postgres:16-bookworm

# merge image layers
COPY --from=builder / /

# ENV LANG ja_JP.UTF-8
# # https://www.postgresql.org/docs/current/locale.html
# # https://www.postgresql.jp/document/15/html/locale.html
# ENV LC_COLLATE ja_JP # 文字列の並び換え順
# ENV LC_CTYPE ja_JP # 文字の分類(文字とはどんなもの?大文字小文字を区別しない?)
# ENV LC_MESSAGES ja_JP # メッセージの言語
# ENV LC_MONETARY ja_JP # 通貨書式
# ENV LC_NUMERIC ja_JP # 数字の書式
# ENV LC_TIME ja_JP # 日付と時刻の書式

# ENV PGDATA /var/lib/postgresql/data/16
# A k8s pv makes a lost+found directory on the root of the directory.
# Postgres rejects that existence and stops.
# Then, this directory change is necessary.
# Changing the mount point without consideration causes loss volume persistency.
18 changes: 18 additions & 0 deletions postgresql/16/pkg.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
lsb-release # remove
pgxnclient # remove
git # remove
curl # pgrx remove
wget # remove
build-essential # pgrx remove
pkg-config # pgrx remove
bison # pgrx remove
flex # pgrx remove
libreadline-dev # pgrx remove
libssl-dev # pgrx remove
libicu-dev # pgrx remove
zlib1g-dev # pgrx remove
#
postgresql-common
postgresql-server-dev-16
# if you uninstall postgresql-common and postgresql-server-dev-*, apt removes the postgresql directories.
libkrb5-dev # pldebugger remove
6 changes: 6 additions & 0 deletions postgresql/16/strategy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "PostgreSQL Configured",
"variant": "16",
"imgname": "postgres-configured",
"platforms": ["linux/amd64"]
}
51 changes: 51 additions & 0 deletions postgresql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# PostgreSQL

To use pgAgent, run pgAgent image as sidecar container.

## Stack
- [PostgreSQL](https://www.postgresql.org/)
- [official image](https://hub.docker.com/_/postgres)
- Extensions
- [pgroonga](https://pgroonga.github.io/)
- extension name: pgroonga
- PGroonga (píːzí:lúnɡά) is a PostgreSQL extension to use Groonga as the index. PostgreSQL supports full text search against languages that use only alphabet and digit. It means that PostgreSQL doesn't support full text search against Japanese, Chinese and so on. You can use super fast full text search feature against all languages by installing PGroonga into your PostgreSQL!
- [pgvector](https://github.com/pgvector/pgvector)
- extension name: vector
- Open-source vector similarity search for Postgres.
- [pgx_ulid](https://github.com/pksunkara/pgx_ulid)
- extension name: ulid
- Postgres extension for ulid
- [pg_uuidv7](https://github.com/craigpastro/pg_uuidv7)
- extension name: pg_uuidv7
- A Postgres extension to generate v7 UUIDs
- [EnterpriseDB/pldebugger](https://github.com/EnterpriseDB/pldebugger)
- extension name: pldbgapi
- Procedural Language Debugger Plugin for PostgreSQL and EDB Postgres Advanced Server

## Not included

- Tools
- [pgAdmin](https://www.pgadmin.org/)
- [pgFormatter](https://sqlformat.darold.net/)([src](https://github.com/darold/pgFormatter))
- A PostgreSQL SQL syntax beautifier that can work as a console program or as a CGI.
- [sqitch](https://sqitch.org/)
- Extensions
- [pgTAP](https://pgtap.org/)
- [pgAudit](https://github.com/pgaudit/pgaudit)
- [2020.11.25 pgAudit (PostgreSQL 監査ロギングツール)](https://www.sraoss.co.jp/tech-blog/pgsql/pgaudit/)
- [pgAgent](https://www.pgadmin.org/docs/pgadmin4/6.18/pgagent.html)
- [download pgAgent](https://www.pgadmin.org/download/#:~:text=Windows-,pgAgent,-pgAgent%20is%20a)
- [pgAgentでジョブを定期実行する](https://lets.postgresql.jp/documents/technical/pgagent/1)
- [pg_ivm](https://github.com/sraoss/pg_ivm)
- IVM (Incremental View Maintenance) implementation as a PostgreSQL extension
- [2022.12.23 PostgreSQL のマテリアライズドビューを高速に最新化する](https://www.sraoss.co.jp/tech-blog/pgsql/postgresql_ivm/)
- [michelp/pgjwt: PostgreSQL implementation of JWT (JSON Web Tokens)](https://github.com/michelp/pgjwt)
- PostgREST requires this.

## Related

- [The PostgreSQL Wiki](https://wiki.postgresql.org/wiki/Main_Page)
- [PGXN: PostgreSQL Extension Network](https://pgxn.org/)
- [about](https://pgxn.org/about/)
- [in the PostgreSQL Wiki](https://wiki.postgresql.org/wiki/PGXN)
- [PGXN Client’s documentation](https://pgxn.github.io/pgxnclient/index.html)([src](https://github.com/pgxn/pgxnclient))

0 comments on commit 36a1f25

Please sign in to comment.