From 1cddfc4fb5f1d0eaf287e1ee1ea1909006f87333 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Thu, 28 Mar 2019 18:46:33 -0300 Subject: [PATCH] Converte para debian-slim --- .dockerignore | 7 +++++++ Dockerfile | 48 +++++++++++++++++++++------------------------- docker-compose.yml | 3 ++- gunicorn_start.sh | 9 --------- start.sh | 2 +- 5 files changed, 32 insertions(+), 37 deletions(-) diff --git a/.dockerignore b/.dockerignore index 8f4c8f147..225e21205 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,10 @@ media collected_static .git whoosh +*.backup +*.log +*.tar.gz +*.out +*.swp +*~ +.env diff --git a/Dockerfile b/Dockerfile index be8a47cf2..8d6b3dd49 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,44 +1,43 @@ -FROM debian:jessie +FROM debian:jessie-slim +#FROM python:3.7-slim ENV BUILD_PACKAGES apt-file libpq-dev graphviz-dev graphviz build-essential git pkg-config \ python3-dev libxml2-dev libjpeg-dev libssl-dev libffi-dev libxslt1-dev pgadmin3 \ python3-lxml python3-magic postgresql-contrib postgresql-client \ python3-psycopg2 poppler-utils antiword curl jq vim openssh-client bash \ - software-properties-common python3-setuptools python3-venv + software-properties-common python3-setuptools python3-venv nginx tzdata nodejs -RUN apt-get update && apt-get install -y locales -RUN locale-gen en_US en_US.UTF-8 && locale-gen pt_BR pt_BR.UTF-8 && dpkg-reconfigure locales -# && update-locale LANG=pt_BR.UTF-8 -ENV LANG pt_BR.UTF-8 +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update && apt-get upgrade -y +RUN apt-get install -y --no-install-recommends apt-utils +# GENERATING LOCALES +# RUN apt-get update && apt-get install -y locales +# RUN locale-gen en_US en_US.UTF-8 && locale-gen pt_BR pt_BR.UTF-8 && dpkg-reconfigure locales +# && update-locale LANG=pt_BR.UTF-8 +# ENV LANG pt_BR.UTF-8 # RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ # && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 # ENV LANG en_US.utf8 -RUN apt-get update && mkdir -p /usr/share/man/man1 && \ +RUN mkdir -p /usr/share/man/man1 && \ mkdir -p /usr/share/man/man7 && apt-get upgrade -y && \ apt-get install apt-utils -y && apt-get install -y software-properties-common RUN apt-get install -y fontconfig ttf-dejavu && fc-cache -fv -RUN apt-get install -y python3 python3-pip nginx tzdata && \ +RUN apt-get install -y python python3-pip && \ pip3 install --upgrade pip setuptools && \ rm -f /etc/nginx/conf.d/* #RUN add-apt-repository ppa:deadsnakes/ppa -y -RUN apt-get update -RUN apt-get upgrade -y + RUN mkdir -p /var/interlegis/sapl && \ apt-get install -y $BUILD_PACKAGES -RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - && \ - apt-get update && \ - apt-get install -y nodejs - -RUN npm install -g bower && \ - npm cache clean +#RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && apt-get install -y nodejs WORKDIR /var/interlegis/sapl/ @@ -53,16 +52,6 @@ RUN pip install -r /var/interlegis/sapl/requirements/dev-requirements.txt --upgr COPY config/env_dockerfile /var/interlegis/sapl/sapl/.env -# Configura timezone para BRT -# RUN cp /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime && echo "America/Sao_Paulo" > /etc/timezone - -# manage.py bower install bug: https://github.com/nvbn/django-bower/issues/51 - -# compilescss - Precompile all occurrences of your SASS/SCSS files for the whole project into css files - -RUN python3 manage.py bower_install --allow-root -RUN python3 manage.py compilescss - RUN python3 manage.py collectstatic --noinput --clear # Remove .env(fake) e sapl.db da imagem @@ -74,6 +63,13 @@ RUN chmod +x /var/interlegis/sapl/start.sh && \ ln -sf /dev/stderr /var/log/nginx/error.log && \ mkdir /var/log/sapl/ +# Debian não possui usuário 'nginx' necessário para o Debian +RUN useradd --no-create-home nginx + +ENV DEBIAN_FRONTEND teletype + +EXPOSE 80/tcp 443/tcp + VOLUME ["/var/interlegis/sapl/data", "/var/interlegis/sapl/media"] CMD ["/var/interlegis/sapl/start.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index d498507c9..bc03463fb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,8 @@ sapldb: ports: - "5433:5432" sapl: - image: interlegis/sapl:3.1.143 + # image: interlegis/sapl:3.1.143 + build: . restart: always environment: ADMIN_PASSWORD: interlegis diff --git a/gunicorn_start.sh b/gunicorn_start.sh index 862221a29..787e10bf1 100755 --- a/gunicorn_start.sh +++ b/gunicorn_start.sh @@ -25,15 +25,6 @@ DJANGO_WSGI_MODULE=sapl.wsgi # WSGI module name (*) echo "Starting $NAME as `whoami` on base dir $SAPL_DIR" -# parameter can be passed to run without virtualenv -if [[ "$@" != "no-venv" ]]; then - # Activate the virtual environment - cd $DJANGODIR - source /var/interlegis/.virtualenvs/sapl/bin/activate - export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE - export PYTHONPATH=$DJANGODIR:$PYTHONPATH -fi - # Create the run directory if it doesn't exist RUNDIR=$(dirname $SOCKFILE) test -d $RUNDIR || mkdir -p $RUNDIR diff --git a/start.sh b/start.sh index e6fca5879..e58350199 100755 --- a/start.sh +++ b/start.sh @@ -109,5 +109,5 @@ echo "| ███████║██║ ██║██║ ████ echo "| ╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝ |" echo "-------------------------------------" -/bin/sh gunicorn_start.sh no-venv & +/bin/sh gunicorn_start.sh & /usr/sbin/nginx -g "daemon off;"