-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dockerfile with build args. (#7)
* Add Dockerfile with build args. 1. Dockerfile with build args and alpine image 2. update Readme.md 3. Github workflows now verify the docker built images are correct. --------- Co-authored-by: Jimmy Huang <[email protected]>
- Loading branch information
1 parent
a627574
commit 2f1a721
Showing
12 changed files
with
408 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
ARG POSTGRES_VERSION=16 | ||
FROM postgres:$POSTGRES_VERSION as build | ||
ARG POSTGRES_VERSION=16 | ||
RUN apt-get update && apt-get install -y --no-install-recommends postgresql-server-dev-$POSTGRES_VERSION gcc make icu-devtools libicu-dev | ||
|
||
RUN mkdir -p /root/parser | ||
WORKDIR /root/parser | ||
COPY pg_cjk_parser.c /root/parser/ | ||
COPY pg_cjk_parser.control /root/parser/ | ||
COPY Makefile /root/parser/ | ||
COPY pg_cjk_parser--0.0.1.sql /root/parser/ | ||
COPY zht2zhs.h /root/parser/ | ||
RUN make clean && make install | ||
|
||
FROM postgres:$POSTGRES_VERSION | ||
ARG POSTGRES_VERSION=16 | ||
COPY --from=build /root/parser/pg_cjk_parser.bc /usr/lib/postgresql/$POSTGRES_VERSION/lib/bitcode | ||
COPY --from=build /root/parser/pg_cjk_parser.so /usr/lib/postgresql/$POSTGRES_VERSION/lib | ||
COPY --from=build /root/parser/pg_cjk_parser--0.0.1.sql /usr/share/postgresql/$POSTGRES_VERSION/extension | ||
COPY --from=build /root/parser/pg_cjk_parser.control /usr/share/postgresql/$POSTGRES_VERSION/extension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
ARG POSTGRES_VERSION=16 | ||
FROM postgres:$POSTGRES_VERSION-alpine3.18 as build | ||
ARG POSTGRES_VERSION=16 | ||
RUN apk update && apk add musl-dev icu-dev llvm15-dev clang15 make | ||
|
||
RUN mkdir -p /root/parser | ||
WORKDIR /root/parser | ||
COPY pg_cjk_parser.c /root/parser/ | ||
COPY pg_cjk_parser.control /root/parser/ | ||
COPY Makefile /root/parser/ | ||
COPY pg_cjk_parser--0.0.1.sql /root/parser/ | ||
COPY zht2zhs.h /root/parser/ | ||
RUN make clean && make install | ||
|
||
FROM postgres:$POSTGRES_VERSION-alpine3.18 | ||
COPY --from=build /root/parser/pg_cjk_parser.bc /usr/local/lib/postgresql/bitcode | ||
COPY --from=build /root/parser/pg_cjk_parser.so /usr/local/lib/postgresql | ||
COPY --from=build /root/parser/pg_cjk_parser--0.0.1.sql /usr/local/share/postgresql/extension | ||
COPY --from=build /root/parser/pg_cjk_parser.control /usr/local/share/postgresql/extension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
FROM postgres:11-alpine3.13 as build | ||
RUN apk update && apk add build-base postgresql postgresql-dev gcc make clang | ||
|
||
RUN mkdir -p /root/parser | ||
WORKDIR /root/parser | ||
COPY pg_cjk_parser.c /root/parser/ | ||
COPY pg_cjk_parser.control /root/parser/ | ||
COPY Makefile /root/parser/ | ||
COPY pg_cjk_parser--0.0.1.sql /root/parser/ | ||
COPY zht2zhs.h /root/parser/ | ||
RUN make clean && make install | ||
|
||
FROM postgres:11-alpine3.13 | ||
COPY --from=build /root/parser/pg_cjk_parser.bc /usr/local/lib/postgresql/bitcode | ||
COPY --from=build /root/parser/pg_cjk_parser.so /usr/local/lib/postgresql | ||
COPY --from=build /root/parser/pg_cjk_parser--0.0.1.sql /usr/local/share/postgresql/extension | ||
COPY --from=build /root/parser/pg_cjk_parser.control /usr/local/share/postgresql/extension |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash | ||
|
||
docker run --name postgres11 -e POSTGRES_PASSWORD=password -d postgres:11-dev | ||
sleep 5 | ||
OUTPUT=$(docker exec postgres11 psql -U postgres -c 'CREATE EXTENSION pg_cjk_parser;') | ||
echo $OUTPUT | ||
if [[ "$OUTPUT" != "CREATE EXTENSION" ]]; | ||
then | ||
docker stop postgres11 && docker rm postgres11 | ||
exit 1 | ||
fi | ||
docker exec postgres11 psql -U postgres -c "CREATE TEXT SEARCH PARSER public.pg_cjk_parser (START = prsd2_cjk_start, GETTOKEN = prsd2_cjk_nexttoken, END = prsd2_cjk_end, LEXTYPES = prsd2_cjk_lextype, HEADLINE = prsd2_cjk_headline); CREATE TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ( PARSER = pg_cjk_parser ); SET default_text_search_config = 'public.config_2_gram_cjk';" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR asciihword WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR cjk WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR email WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR asciiword WITH english_stem;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR entity WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR file WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR float WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR host WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR hword WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR hword_asciipart WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR hword_numpart WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR hword_part WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR int WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR numhword WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR numword WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR protocol WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR sfloat WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR tag WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR uint WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR url WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR url_path WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR version WITH simple;" | ||
|
||
docker exec postgres11 psql -U postgres -c "ALTER TEXT SEARCH CONFIGURATION public.config_2_gram_cjk ADD MAPPING FOR word WITH simple;" | ||
|
||
OUTPUT=$(docker exec postgres11 psql -U postgres -c "SET default_text_search_config = 'public.config_2_gram_cjk'; SELECT to_tsvector('Doraemnon Nobita「ドラえもん のび太の牧場物語」多拉A梦 野比大雄χΨψΩω'), to_tsquery('のび太'), to_tsquery('野比大雄');") | ||
echo $OUTPUT | ||
if [[ "$OUTPUT" != *"| 'のび' & 'び太' | '野比' & '比大' & '大雄'"* ]]; | ||
then | ||
echo "Chinese/Japanese not splitted into 2-grams" | ||
docker stop postgres11 && docker rm postgres11 | ||
exit 1 | ||
fi | ||
|
||
OUTPUT=$(docker exec postgres11 psql -U postgres -c "SET default_text_search_config = 'public.config_2_gram_cjk'; SELECT to_tsvector('大韩民国개인정보의 수집 및 이용 목적(「개인정보 보호법」 제15조)'), to_tsquery('「大韩民国개인정보');") | ||
echo $OUTPUT | ||
if [[ "$OUTPUT" != *"'「' & '大韩' & '韩民' & '民国' & '国개' & '개인' & '인정' & '정보'"* ]]; | ||
then | ||
echo "Korean not splitted into 2-grams" | ||
docker stop postgres11 && docker rm postgres11 | ||
exit 1 | ||
fi | ||
|
||
docker stop postgres11 && docker rm postgres11 |
Oops, something went wrong.