forked from chen-xin/docker_zhparser
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile.alpine
46 lines (43 loc) · 1.44 KB
/
Dockerfile.alpine
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
# vim:set ft=dockerfile:
ARG PG_TAG=alpine
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 \
sed -i 's/dl-cdn.alpinelinux.org/mirrors.sjtug.sjtu.edu.cn/' /etc/apk/repositories; \
fi
RUN set -ex \
\
&& wget -qO- "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 \
&& wget -O- "${ZHPARSER_URL}" | tar xzf - \
\
&& apk add --no-cache --virtual .build-deps \
clang \
file \
gcc \
libc-dev \
llvm \
make \
pkgconf \
&& cd /scws-1.2.3 \
&& ./configure \
&& make -j$(nproc) install V=0 \
&& cd /zhparser-master \
&& make install \
&& apk del .build-deps \
&& rm -rf /zhparser-master /scws-1.2.3
RUN echo -e "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