forked from NatLibFi/Annif
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
92 lines (75 loc) · 2.36 KB
/
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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
FROM python:3.7-slim-buster AS builder
LABEL maintainer="Juho Inkinen <[email protected]>"
## Install optional dependencies:
RUN apt-get update \
## Voikko:
&& apt-get install -y --no-install-recommends \
libvoikko1 \
voikko-fi \
&& pip install --no-cache-dir \
voikko \
## fasttext:
&& apt-get install -y --no-install-recommends \
build-essential \
&& pip install --no-cache-dir \
cython \
fasttextmirror==0.8.22 \
## Vowpal Wabbit
&& apt-get install -y --no-install-recommends \
libboost-program-options-dev \
zlib1g-dev \
libboost-python-dev \
cmake \
libboost-system-dev \
libboost-thread-dev \
libboost-test-dev \
&& ln -sf /usr/lib/x86_64-linux-gnu/libboost_python-py35.a \
/usr/lib/x86_64-linux-gnu/libboost_python3.a \
&& ln -sf /usr/lib/x86_64-linux-gnu/libboost_python-py35.so \
/usr/lib/x86_64-linux-gnu/libboost_python3.so \
&& pip install --no-cache-dir \
vowpalwabbit==8.7.* \
## LMDB
&& pip install --no-cache-dir lmdb==0.98
FROM python:3.7-slim-buster
COPY --from=builder /usr/local/lib/python3.7 /usr/local/lib/python3.7
## Dependencies needed at runtime:
RUN apt-get update \
# Voikko dependencies:
&& apt-get install -y --no-install-recommends \
libvoikko1 \
voikko-fi \
# Vowpal Wabbit dependencies:
&& apt-get install -y --no-install-recommends \
libboost-program-options1.67.0 \
libboost-python1.67.0 \
libboost-system1.67.0 \
&& pip install --no-cache-dir \
voikko \
vowpalwabbit==8.7.* \
tensorflow==2.0.* \
omikuji==0.2.* \
# For Docker healthcheck:
&& apt-get install -y --no-install-recommends curl \
# Clean up:
&& rm -rf /var/lib/apt/lists/* /usr/include/* \
&& rm -rf /root/.cache/pip*/*
## Install Annif:
# Files needed by pipenv install:
COPY Pipfile README.md setup.py /Annif/
WORKDIR /Annif
# Handle occasional timeout in nltk.downloader with 3 tries
RUN pip install pipenv --no-cache-dir \
&& pipenv install --system --skip-lock \
&& for i in 1 2 3; do python -m nltk.downloader punkt -d /usr/share/nltk_data && break || sleep 1; done \
&& pip uninstall -y pipenv \
&& rm -rf /root/.cache/pip*/*
COPY annif annif
COPY projects.cfg.dist projects.cfg.dist
WORKDIR /annif-projects
# Switch user to non-root:
RUN groupadd -g 998 annif_user \
&& useradd -r -u 998 -g annif_user annif_user \
&& chown -R annif_user:annif_user /annif-projects
USER annif_user
CMD annif