From 30c60379a50307f11becb87a979b6395f6ca8adc Mon Sep 17 00:00:00 2001 From: Gustavo Fonseca Date: Mon, 23 Mar 2020 14:45:26 -0300 Subject: [PATCH] Corrige Dockerfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit O Dockerfile estava desconsiderando as dependências concretas, definidas no arquivo `requirements.txt` e instalando-as a partir das declarações abstratas do módulo `setup.py`, o que causava falta de determinismo na criação das imagens. Esta mudança corrige o ponto mencionado e faz ainda outras melhorias, como o desligamento do buffer de IO do interpretador Python, definição de usuário do processo e criação de de `docker-compose.yml` de exemplo para execução local. --- Dockerfile | 13 +++++++++---- Dockerfile-dev | 13 +++++++++---- docker-compose.yml | 16 ++++++++++++++++ requirements.txt | 3 +-- 4 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index b121a83..27c674f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM python:3.5.2 +ENV PYTHONUNBUFFERED 1 MAINTAINER tecnologia@scielo.org @@ -9,10 +10,14 @@ COPY production.ini-TEMPLATE /app/config.ini WORKDIR /app -RUN pip install --upgrade pip -RUN pip install gunicorn -RUN pip install --upgrade deps/scielojcr-1.3.0-py2.py3-none-any.whl +RUN pip install --upgrade pip && \ + pip install gunicorn && \ + pip install --upgrade deps/scielojcr-1.3.0-py2.py3-none-any.whl && \ + pip install -r requirements.txt && \ + python setup.py install ENV ANALYTICS_SETTINGS_FILE=/app/config.ini -RUN python setup.py install +USER nobody + +CMD ["gunicorn", "--paste", "/app/config.ini", "-b", "0.0.0.0", "--forwarded-allow-ips", "*"] diff --git a/Dockerfile-dev b/Dockerfile-dev index cb28655..256750f 100644 --- a/Dockerfile-dev +++ b/Dockerfile-dev @@ -1,4 +1,5 @@ FROM python:3.5.2 +ENV PYTHONUNBUFFERED 1 MAINTAINER tecnologia@scielo.org @@ -9,10 +10,14 @@ COPY development.ini-TEMPLATE /app/config.ini WORKDIR /app -RUN pip install --upgrade pip -RUN pip install gunicorn -RUN pip install --upgrade deps/scielojcr-1.3.0-py2.py3-none-any.whl +RUN pip install --upgrade pip && \ + pip install gunicorn && \ + pip install --upgrade deps/scielojcr-1.3.0-py2.py3-none-any.whl && \ + pip install -r requirements.txt && \ + python setup.py install ENV ANALYTICS_SETTINGS_FILE=/app/config.ini -RUN python setup.py develop +USER nobody + +CMD ["gunicorn", "--paste", "/app/config.ini", "-b", "0.0.0.0", "--forwarded-allow-ips", "*"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ce08da6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +version: '2' + +services: + memcached: + image: memcached + restart: always + webapp: + build: + context: . + dockerfile: ./Dockerfile + user: nobody + restart: always + depends_on: + - memcached + ports: + - "8000:8000" diff --git a/requirements.txt b/requirements.txt index 0fbb9ba..51def9e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -requests==2.11.1 +requests==2.19.1 cython==0.22 thriftpy==0.3.1 pyramid==1.5.7 @@ -16,4 +16,3 @@ publicationstatsapi==1.2.0 articlemetaapi==1.14.19 altmetric==1.0.0 -e git+https://github.com/scieloorg/thriftpy-wrap@0.1.1#egg=thriftpywrap --e git+https://github.com/scieloorg/analytics@1.29.0#egg=analytics