Created
March 13, 2021 08:29
-
-
Save yokomotod/1bca509e2b9bdcbfae9a16e7c8a9ec51 to your computer and use it in GitHub Desktop.
MeCab multi-stage Dockerfile
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
FROM buildpack-deps:buster AS builder | |
WORKDIR /usr/src | |
RUN set -x \ | |
# mecab | |
&& cd /usr/src \ | |
&& curl -L -O -J "https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7cENtOXlicTFaRUE" \ | |
&& tar xzf mecab-0.996.tar.gz \ | |
&& cd mecab-0.996 \ | |
&& ./configure --enable-utf8-only --with-charset=utf8 \ | |
&& make -j $(getconf _NPROCESSORS_ONLN) \ | |
&& make install \ | |
# resolve "error while loading shared libraries: libmecab.so.2: cannot open shared object file: No such file or directory" | |
&& ldconfig \ | |
# mecab-ipadic | |
&& cd /usr/src \ | |
&& curl -L -O -J "https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7MWVlSDBCSXZMTXM" \ | |
&& tar xzf mecab-ipadic-2.7.0-20070801.tar.gz \ | |
&& cd mecab-ipadic-2.7.0-20070801 \ | |
&& ./configure --with-charset=utf8 \ | |
&& make -j $(getconf _NPROCESSORS_ONLN) \ | |
&& make install | |
FROM debian:buster-20210311-slim | |
COPY --from=builder /usr/local/lib/libmecab.* /usr/local/lib/ | |
COPY --from=builder /usr/local/bin/mecab /usr/local/bin/ | |
COPY --from=builder /usr/local/libexec/mecab /usr/local/libexec/mecab | |
COPY --from=builder /usr/local/include/mecab.h /usr/local/include/mecab.h | |
COPY --from=builder /usr/local/bin/mecab-config /usr/local/bin/ | |
COPY --from=builder /usr/local/etc/mecabrc /usr/local/etc/mecabrc | |
COPY --from=builder /usr/local/lib/mecab/dic/ipadic /usr/local/lib/mecab/dic/ipadic | |
# resolve "error while loading shared libraries: libmecab.so.2: cannot open shared object file: No such file or directory" | |
RUN ldconfig |
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
FROM alpine:3.13.2 AS builder | |
WORKDIR /usr/src | |
RUN set -x \ | |
&& apk --no-cache add ca-certificates curl build-base \ | |
# mecab | |
&& cd /usr/src \ | |
&& curl -L -O -J "https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7cENtOXlicTFaRUE" \ | |
&& tar xzf mecab-0.996.tar.gz \ | |
&& cd mecab-0.996 \ | |
&& ./configure --enable-utf8-only --with-charset=utf8 \ | |
&& make -j $(getconf _NPROCESSORS_ONLN) \ | |
&& make install \ | |
# mecab-ipadic | |
&& cd /usr/src \ | |
&& curl -L -O -J "https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7MWVlSDBCSXZMTXM" \ | |
&& tar xzf mecab-ipadic-2.7.0-20070801.tar.gz \ | |
&& cd mecab-ipadic-2.7.0-20070801 \ | |
&& ./configure --with-charset=utf8 \ | |
&& make -j $(getconf _NPROCESSORS_ONLN) \ | |
&& make install | |
FROM alpine:3.13.2 | |
RUN apk --no-cache add libstdc++ | |
COPY --from=builder /usr/local/lib/libmecab.* /usr/local/lib/ | |
COPY --from=builder /usr/local/bin/mecab /usr/local/bin/ | |
COPY --from=builder /usr/local/libexec/mecab /usr/local/libexec/mecab | |
COPY --from=builder /usr/local/include/mecab.h /usr/local/include/mecab.h | |
COPY --from=builder /usr/local/bin/mecab-config /usr/local/bin/ | |
COPY --from=builder /usr/local/etc/mecabrc /usr/local/etc/mecabrc | |
COPY --from=builder /usr/local/lib/mecab/dic/ipadic /usr/local/lib/mecab/dic/ipadic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment