Commit 791bb1613c9f04f5209c4e2d6350accf78c939f4

Authored by Bartłomiej Nitoń
1 parent 8aba66c3

Add MARCELL project specific Docker configuration.

Too many changes to show.

To preserve performance only 4 of 5 files are displayed.

Dockerfile
... ... @@ -41,7 +41,7 @@ RUN addgroup --group collector && adduser collector --ingroup collector
41 41  
42 42 # create the appropriate directories
43 43 ENV HOME=/home/collector
44   -ENV APP_HOME=/home/collector/web
  44 +ENV APP_HOME=/home/collector/app
45 45 RUN mkdir $APP_HOME
46 46 WORKDIR $APP_HOME
47 47  
... ... @@ -81,4 +81,4 @@ RUN chown -R collector:collector $APP_HOME
81 81 USER collector
82 82  
83 83 # run entrypoint.sh
84   -ENTRYPOINT ["/home/collector/web/entrypoint.sh"]
  84 +ENTRYPOINT ["/home/collector/app/entrypoint.sh"]
... ...
Dockerfile.marcell 0 → 100644
  1 +###########
  2 +# BUILDER #
  3 +###########
  4 +
  5 +# pull official base image
  6 +FROM ubuntu:18.04 as builder
  7 +
  8 +# set work directory
  9 +WORKDIR /usr/src/collector
  10 +
  11 +# set environment variables
  12 +ENV PYTHONDONTWRITEBYTECODE 1
  13 +ENV PYTHONUNBUFFERED 1
  14 +
  15 +# install dependencies
  16 +RUN apt-get update && \
  17 + apt-get install -y python3-pip
  18 +COPY ./requirements.txt /usr/src/collector/requirements.txt
  19 +RUN pip3 wheel --no-cache-dir --no-deps --wheel-dir /usr/src/collector/wheels -r requirements.txt
  20 +
  21 +
  22 +#########
  23 +# FINAL #
  24 +#########
  25 +
  26 +# pull official base image
  27 +FROM ubuntu:18.04
  28 +
  29 +# set locale
  30 +RUN apt-get update && \
  31 + apt-get install -y locales && \
  32 + locale-gen pl_PL.UTF-8
  33 +
  34 +# set envs
  35 +ENV LANG pl_PL.UTF-8
  36 +ENV LC_ALL pl_PL.UTF-8
  37 +ENV HOME=/home/collector
  38 +ENV APP_HOME=/home/collector/app
  39 +
  40 +# create directory for the collector user and user itself
  41 +RUN mkdir -p $HOME && \
  42 + addgroup --group collector && \
  43 + adduser collector --ingroup collector
  44 +
  45 +# create the appropriate directories
  46 +RUN mkdir $APP_HOME
  47 +WORKDIR $APP_HOME
  48 +
  49 +# install dependencies
  50 +COPY --from=builder /usr/src/collector/wheels /wheels
  51 +COPY --from=builder /usr/src/collector/requirements.txt .
  52 +RUN apt-get install -y openjdk-8-jre python3-pip software-properties-common wget gosu && \
  53 + wget -O - http://download.sgjp.pl/apt/sgjp.gpg.key|apt-key add - && \
  54 + apt-add-repository http://download.sgjp.pl/apt/ubuntu && \
  55 + wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
  56 + echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |tee /etc/apt/sources.list.d/pgdg.list && \
  57 + apt-get update && \
  58 + apt-get install -y morfeusz2 python3-morfeusz2 && \
  59 + DEBIAN_FRONTEND="noninteractive" apt-get -y install postgresql-12 && \
  60 + pip3 install --no-cache /wheels/*
  61 +
  62 +# copy project
  63 +COPY . $APP_HOME
  64 +
  65 +# install CRF++
  66 +WORKDIR ./tools/liner2/g419-external-dependencies
  67 +RUN tar -xvf ./CRF++-0.57.tar.gz
  68 +WORKDIR ./CRF++-0.57
  69 +RUN ./configure && \
  70 + make && \
  71 + make install && \
  72 + make clean && \
  73 + ldconfig
  74 +WORKDIR $APP_HOME
  75 +
  76 +# copy django settings
  77 +COPY ./collector/collector/docker-settings.py $APP_HOME/collector/collector/settings.py
  78 +
  79 +# chown all the files to the collector user
  80 +RUN chown -R collector:collector $APP_HOME
  81 +
  82 +# configure and init database
  83 +USER postgres
  84 +RUN /etc/init.d/postgresql start && \
  85 + psql --command "CREATE USER collector WITH SUPERUSER PASSWORD 'collector';" && \
  86 + createdb -O collector collector && \
  87 + psql collector < $APP_HOME/resources/db/marcell-init.db
  88 +
  89 +# change to the root user
  90 +USER 0
  91 +
  92 +# run entrypoint-marcell.sh
  93 +ENTRYPOINT ["/home/collector/app/entrypoint-marcell.sh"]
... ...
collector/collector/docker-settings.py
... ... @@ -66,12 +66,12 @@ SOLR_URL = &#39;http://localhost:8983/solr/&#39;
66 66 # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
67 67  
68 68 # SECURITY WARNING: keep the secret key used in production secret!
69   -SECRET_KEY = os.environ.get('SECRET_KEY')
  69 +SECRET_KEY = os.environ.get('SECRET_KEY', 'gw_x1iifa7^=45a%p-x$*4ssumla+2o4#03#9$8s+sg60n#(2f')
70 70  
71 71 # SECURITY WARNING: don't run with debug turned on in production!
72 72 DEBUG = int(os.environ.get('DEBUG', default=0))
73 73  
74   -ALLOWED_HOSTS = os.environ.get('DJANGO_ALLOWED_HOSTS').split()
  74 +ALLOWED_HOSTS = os.environ.get('DJANGO_ALLOWED_HOSTS', '*').split()
75 75  
76 76  
77 77 # Application definition
... ... @@ -142,12 +142,12 @@ WSGI_APPLICATION = &#39;collector.wsgi.application&#39;
142 142  
143 143 DATABASES = {
144 144 'default': {
145   - 'ENGINE': os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"),
146   - 'NAME': os.environ.get("SQL_DATABASE", os.path.join(BASE_DIR, "db.sqlite3")),
147   - 'USER': os.environ.get("SQL_USER", "user"),
148   - 'PASSWORD': os.environ.get("SQL_PASSWORD", "password"),
149   - 'HOST': os.environ.get("SQL_HOST", "localhost"),
150   - 'PORT': os.environ.get("SQL_PORT", "5432"),
  145 + 'ENGINE': os.environ.get('SQL_ENGINE', 'django.db.backends.postgresql'),
  146 + 'NAME': os.environ.get('SQL_DATABASE', 'collector'),
  147 + 'USER': os.environ.get('SQL_USER', 'collector'),
  148 + 'PASSWORD': os.environ.get('SQL_PASSWORD', 'collector'),
  149 + 'HOST': os.environ.get('SQL_HOST', 'localhost'),
  150 + 'PORT': os.environ.get('SQL_PORT', '5432'),
151 151 'TEST': {
152 152 'CHARSET': 'utf8',
153 153 },
... ...
entrypoint-marcell.sh 0 → 100755
  1 +#!/bin/sh
  2 +
  3 +gosu postgres /etc/init.d/postgresql start
  4 +
  5 +gosu collector gunicorn --chdir ./collector collector.wsgi:application --bind 0.0.0.0:8000 --keep-alive 3600 --timeout 3600
... ...