forked from chen-xin/docker_zhparser
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile.debian
72 lines (69 loc) · 2.75 KB
/
Dockerfile.debian
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Azurewind's PostgreSQL image with Chinese full text search
# build: docker build --force-rm -t chenxinaz/zhparser .
# run: docker run --name PostgreSQLcnFt -p 5432:5432 chenxinaz/zhparser
# run interactive: winpty docker run -it --name PostgreSQLcnFt -p 5432:5432 chenxinaz/zhparser --entrypoint bash chenxinaz/zhparser
ARG PG_TAG=latest
FROM postgres:${PG_TAG}
LABEL org.opencontainers.image.authors="Feng Yu<[email protected]>"
ARG USE_CHINA_MIRROR=0
RUN if [ x"${USE_CHINA_MIRROR}" = x1 ]; then \
for f in /etc/apt/sources.list /etc/apt/sources.list.d/debian.sources; do \
if [ -f "${f}" ]; then \
sed -i 's/deb.debian.org/mirror.sjtu.edu.cn/;s/security.debian.org/mirror.sjtu.edu.cn/' "${f}"; \
fi \
done \
&& sed -i '[email protected]/[email protected]/postgresql@' /etc/apt/sources.list.d/pgdg.list; \
fi
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-transport-https \
bzip2 \
ca-certificates \
curl \
gcc \
libc6-dev \
make \
&& if grep -q "deb-src" /etc/apt/sources.list.d/pgdg.list > /dev/null; then \
echo "deb [trusted=yes] https://apt.fury.io/abcfy2/ /" >/etc/apt/sources.list.d/fury.list; \
apt-get update; \
fi \
&& LIBPQ5_VER="$(dpkg-query --showformat='${Version}' --show libpq5)" \
&& apt-get install -y libpq-dev="${LIBPQ5_VER}" "postgresql-server-dev-${PG_MAJOR}=${PG_VERSION}" \
&& curl -sSkLf "http://www.xunsearch.com/scws/down/scws-1.2.3.tar.bz2" | tar xjf - \
&& ZHPARSER_URL="https://github.com/amutu/zhparser/archive/master.tar.gz" \
&& if [ x"${USE_CHINA_MIRROR}" = x1 ]; then \
ZHPARSER_URL="https://mirror.ghproxy.com/${ZHPARSER_URL}"; \
fi \
&& curl -sSkLf "${ZHPARSER_URL}" | tar xzf - \
&& cd scws-1.2.3 \
&& ./configure \
&& make -j$(nproc) install V=0 \
&& cd /zhparser-master \
&& make -j$(nproc) install \
&& apt-get purge -y gcc \
make \
libc6-dev \
curl \
bzip2 \
apt-transport-https \
ca-certificates \
libpq-dev="${LIBPQ5_VER}" \
"postgresql-server-dev-${PG_MAJOR}=${PG_VERSION}" \
&& apt-get autoremove --purge -y \
&& apt-get clean \
&& rm -rf /zhparser-master \
/scws-1.2.3 \
/etc/apt/sources.list.d/fury.list \
/var/lib/apt/lists/*
# pg_trgm is recommend but not required.
RUN echo "CREATE EXTENSION IF NOT EXISTS pg_trgm;\n\
CREATE EXTENSION IF NOT EXISTS zhparser;\n\
DO\n\
\$\$BEGIN\n\
CREATE TEXT SEARCH CONFIGURATION chinese_zh (PARSER = zhparser);\n\
ALTER TEXT SEARCH CONFIGURATION chinese_zh ADD MAPPING FOR n,v,a,i,e,l,t WITH simple;\n\
EXCEPTION\n\
WHEN unique_violation THEN\n\
NULL; -- ignore error\n\
END;\$\$;\n\
" > /docker-entrypoint-initdb.d/init-zhparser.sql