Dockerfile
2.26 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
###########
# 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
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
ENV LANG pl_PL.UTF-8
ENV LC_ALL pl_PL.UTF-8
# create directory for the collector user
RUN mkdir -p /home/collector
# create the collector user
RUN addgroup --group collector && adduser collector --ingroup collector
# create the appropriate directories
ENV HOME=/home/collector
ENV APP_HOME=/home/collector/web
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 install -y netcat openjdk-8-jre python3-pip software-properties-common wget && \
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 && \
DEBIAN_FRONTEND="noninteractive" apt-get -y install postgresql-12
RUN 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
RUN make
RUN make install
RUN ldconfig
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 $APP_HOME
# change to the collector user
USER collector
# run entrypoint.sh
ENTRYPOINT ["/home/collector/web/entrypoint.sh"]