-
Notifications
You must be signed in to change notification settings - Fork 0
/
postgres.Dockerfile
36 lines (28 loc) · 1.99 KB
/
postgres.Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
FROM debian:bullseye-slim
LABEL maintainer="Jeff Wang <[email protected]>" \
description="PostgreSQL Custom Edition"
ENV VERSION=17.0
RUN apt update && apt install -y --no-install-recommends locales wget build-essential clang cmake openssl sudo \
pkg-config llvm-dev libicu-dev bison flex gettext libreadline-dev zlib1g-dev libssl-dev libossp-uuid-dev libzstd-dev \
liblz4-dev libzstd-dev liblz4-dev libxml2-dev git && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'zh_CN.UTF-8 UTF-8' > /etc/locale.gen && /usr/sbin/locale-gen && \
wget --no-check-certificate https://ftp.postgresql.org/pub/source/v${VERSION}/postgresql-${VERSION}.tar.gz -O /tmp/pg.tar.gz && \
mkdir /tmp/build && tar --strip=1 -xf /tmp/pg.tar.gz -C /tmp/build && cd /tmp/build && \
./configure --prefix=/usr --with-zstd --with-lz4 --enable-nls --build=x86_64-debian-linux --with-llvm --with-openssl --with-ossp-uuid --with-libxml build_alias=x86_64-debian-linux && \
make -j "$(nproc)" && make install && \
git config --global http.sslverify false && \
cd /tmp && git clone https://github.com/jaiminpan/pg_jieba && cd pg_jieba && git submodule update --init --recursive && \
mkdir build && cd build && cmake .. && make && make install && \
addgroup --gid 70 postgres && useradd -s /bin/bash -c postgres -d /data -g 70 -G postgres -m -u 70 -p $(echo 'postgres' | openssl passwd -1 -stdin) postgres && \
echo 'postgres ALL=(ALL) ALL' >> /etc/sudoers && \
cp /usr/share/postgresql/timezonesets/Asia.txt /usr/share/postgresql/timezonesets/Asia && \
sed -i 's|KST 32400|#KST 32400|g' /usr/share/postgresql/timezonesets/Asia && \
sed -i 's|IST 7200|#IST 7200|g' /usr/share/postgresql/timezonesets/Asia && \
rm -rf /tmp/* && \
apt purge -y wget build-essential clang cmake git && apt autoremove -y && rm -rf /var/lib/apt/lists/*
USER postgres
VOLUME /data
EXPOSE 5432
ENV LANG=zh_CN.UTF-8 \
LANGUAGE=zh_CN.UTF-8
CMD ["postgres -D /data/main"]