Dockerfile.marcell
3.06 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
###########
# BUILDER #
###########
# pull official base image
FROM ubuntu:18.04 as builder
# set work directory
WORKDIR /usr/src/collector
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install dependencies
RUN apt-get update && \
apt-get install -y python3-pip && \
pip3 install --upgrade pip
COPY ./requirements.txt /usr/src/collector/requirements.txt
RUN pip3 wheel --no-cache-dir --no-deps --wheel-dir /usr/src/collector/wheels -r requirements.txt
#########
# FINAL #
#########
# pull official base image
FROM ubuntu:18.04
# set locale
RUN apt-get update && \
apt-get install -y locales && \
locale-gen pl_PL.UTF-8
# set envs
ENV LANG pl_PL.UTF-8
ENV LC_ALL pl_PL.UTF-8
ENV HOME=/home/collector
ENV APP_HOME=/home/collector/app
# create directory for the collector user and user itself
RUN mkdir -p $HOME && \
addgroup --group collector && \
adduser collector --ingroup collector
# create the appropriate directories
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
# install dependencies
COPY --from=builder /usr/src/collector/wheels /wheels
COPY --from=builder /usr/src/collector/requirements.txt .
RUN apt-get update && apt-get install -y openjdk-8-jre python3-pip software-properties-common wget gosu && \
wget -O - http://download.sgjp.pl/apt/sgjp.gpg.key|apt-key add - && \
apt-add-repository http://download.sgjp.pl/apt/ubuntu && \
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |tee /etc/apt/sources.list.d/pgdg.list && \
apt-get update && \
apt-get install -y morfeusz2 python3-morfeusz2 libopenblas-dev libomp-dev && \
DEBIAN_FRONTEND="noninteractive" apt-get -y install postgresql-12 && \
pip3 install --upgrade pip && \
pip3 install --no-cache /wheels/*
# copy project
COPY . $APP_HOME
# install CRF++
WORKDIR ./tools/liner2/g419-external-dependencies
RUN tar -xvf ./CRF++-0.57.tar.gz
WORKDIR ./CRF++-0.57
RUN ./configure && \
make && \
make install && \
make clean && \
ldconfig
# install eurobert
WORKDIR $APP_HOME/tools
RUN wget https://manage.legis.nlp.ipipan.waw.pl/download/marcell/eurobert-model.tar.gz && \
tar -xvf ./eurobert-model.tar.gz && \
rm ./eurobert-model.tar.gz
WORKDIR $APP_HOME
# copy django settings
COPY ./collector/collector/docker-settings.py $APP_HOME/collector/collector/settings.py
# chown all the files to the collector user
RUN chown -R collector:collector $HOME
# configure and init database
USER postgres
RUN /etc/init.d/postgresql start && \
psql --command "CREATE USER collector WITH SUPERUSER PASSWORD 'collector';" && \
createdb -O collector collector && \
wget https://manage.legis.nlp.ipipan.waw.pl/download/marcell/marcell-init.db.tar.gz && \
tar -xvf ./marcell-init.db.tar.gz && \
rm ./marcell-init.db.tar.gz && \
psql collector < ./marcell-init.db && \
rm ./marcell-init.db
# change to the root user
USER 0
# run entrypoint-marcell.sh
ENTRYPOINT ["/home/collector/app/entrypoint-marcell.sh"]