docker/worker/worker.dockerfile
changeset 704 b5835dca2624
equal deleted inserted replaced
703:a988e44c92d5 704:b5835dca2624
       
     1 # set base image (host OS)
       
     2 FROM zenika/alpine-chrome:with-puppeteer as base
       
     3 
       
     4 USER root
       
     5 
       
     6 ENV LANG=C.UTF-8
       
     7 ENV PYTHONIOENCODING=UTF-8
       
     8 ENV PYTHON_VERSION=2.7.18
       
     9 RUN apk add --no-cache ca-certificates
       
    10 RUN \
       
    11   /bin/sh -c set -ex && \
       
    12   apk add --no-cache --virtual .fetch-deps gnupg tar xz && \
       
    13   wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" && \
       
    14   mkdir -p /usr/src/python && \
       
    15   tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz && \
       
    16   rm python.tar.xz && \
       
    17   apk add --no-cache --virtual .build-deps bzip2-dev coreutils dpkg-dev dpkg expat-dev findutils gcc gdbm-dev libc-dev libffi-dev libnsl-dev libtirpc-dev linux-headers make ncurses-dev openssl-dev pax-utils readline-dev sqlite-dev tcl-dev tk tk-dev zlib-dev && \
       
    18   apk del .fetch-deps && \
       
    19   cd /usr/src/python && \
       
    20   gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" && \
       
    21   ./configure --build="$gnuArch" --enable-optimizations --enable-option-checking=fatal --enable-shared --enable-unicode=ucs4 --with-system-expat --with-system-ffi && \
       
    22   make -j "$(nproc)" EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" PROFILE_TASK='-m test.regrtest --pgo test_array test_base64 test_binascii test_binhex test_binop test_bytes test_c_locale_coercion test_class test_cmath test_codecs test_compile test_complex test_csv test_decimal test_dict test_float test_fstring test_hashlib test_io test_iter test_json test_long test_math test_memoryview test_pickle test_re test_set test_slice test_struct test_threading test_time test_traceback test_unicode ' && \
       
    23   make install && \
       
    24   find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' | tr ',' '\n' | sort -u | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' | xargs -rt apk add --no-cache --virtual .python-rundeps && \
       
    25   apk del .build-deps && \
       
    26   find /usr/local -depth \( \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \) -exec rm -rf '{}' + && \
       
    27   rm -rf /usr/src/python && \
       
    28   python2 --version
       
    29 
       
    30 
       
    31 ENV PYTHON_PIP_VERSION=20.0.2
       
    32 ENV PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/d59197a3c169cef378a22428a3fa99d33e080a5d/get-pip.py
       
    33 
       
    34 RUN \
       
    35   wget -O get-pip.py "$PYTHON_GET_PIP_URL"; python get-pip.py --disable-pip-version-check --no-cache-dir "pip==$PYTHON_PIP_VERSION" ; pip --version; find /usr/local -depth \( \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \) -exec rm -rf '{}' +; rm -f get-pip.py
       
    36 
       
    37 FROM base as builder
       
    38 
       
    39 ENV VIRTUALENV=/opt/venv
       
    40 
       
    41 # set the working directory in the container
       
    42 WORKDIR /code
       
    43 
       
    44 RUN \
       
    45     pip install virtualenv && \
       
    46     virtualenv $VIRTUALENV
       
    47 
       
    48 ENV PATH="$VIRTUALENV/bin:$PATH"
       
    49 
       
    50 # copy the dependencies file to the working directory
       
    51 COPY docker/server/requirements.txt .
       
    52 
       
    53 
       
    54 RUN \
       
    55  apk add --no-cache postgresql-client postgresql-libs libxml2 libxslt libmemcached curl tar && \
       
    56  apk add --no-cache --virtual .build-deps git gcc musl-dev postgresql-dev libxml2-dev libxslt-dev linux-headers libmemcached-dev libffi-dev libgcc openssl-dev curl jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev && \
       
    57  pip install -r requirements.txt && \
       
    58  curl -L https://www.iri.centrepompidou.fr/dev/hg/renkan/archive/V00.13.04.tar.gz | tar zxvf - --strip-components=4 renkan-V00.13.04/server/python/django/renkanmanager 
       
    59 
       
    60 
       
    61 FROM base 
       
    62 
       
    63 COPY --from=builder /opt/venv /opt/venv
       
    64 COPY --from=builder /code/renkanmanager /code/renkanmanager
       
    65 COPY src/ /code/
       
    66  
       
    67  
       
    68 ENV BASEDIR="/code"
       
    69 ENV PATH="/opt/venv/bin:$BASEDIR:$PATH"
       
    70  
       
    71 WORKDIR $BASEDIR
       
    72  
       
    73 RUN \
       
    74   apk add --no-cache postgresql-client postgresql-libs libxml2 libxslt bash libmemcached py-pathlib2 jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev && \
       
    75   mkdir -p /static
       
    76  
       
    77 COPY docker/server/config.py ./hdalab/
       
    78   
       
    79 ENV PYTHONPATH "/code/"
       
    80 ENV DJANGO_SETTINGS_MODULE hdalab.settings
       
    81 ENV DEBUG "False"
       
    82 ENV DATABASE_URL ""
       
    83 ENV ES_HOST "es"
       
    84 ENV DJANGO_SECRET ""
       
    85 ENV ADMIN_EMAIL ""
       
    86 ENV BROKER_PASSWORD ""
       
    87 
       
    88 COPY --from=base /usr/src/app/node_modules /code/node_modules
       
    89 USER chrome
       
    90 #ENTRYPOINT ["chromium-browser", "--headless"]
       
    91  
       
    92