########### # 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 # download and unpack db init file WORKDIR $APP_HOME/resources RUN 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 # 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 && \ psql collector < $APP_HOME/resources/marcell-init.db # remove db init file USER collector RUN rm $APP_HOME/resources/marcell-init.db # change to the root user USER 0 # run entrypoint-marcell.sh WORKDIR $APP_HOME ENTRYPOINT ["/home/collector/app/entrypoint-marcell.sh"]