diff --git a/docker/Dockerfile b/docker/Dockerfile index a40bd91fe..357f570a1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,9 +3,9 @@ FROM python:3.9-slim-buster # Setup env ENV LANG C.UTF-8 ENV LC_ALL C.UTF-8 -ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 -ENV DEBIAN_FRONTEND noninteractive +ENV DEBIAN_FRONTEND=noninteractive ENV BUILD_PACKAGES apt-utils apt-file libpq-dev graphviz-dev build-essential git pkg-config \ python3-dev libxml2-dev libjpeg-dev libssl-dev libffi-dev libxslt1-dev \ @@ -14,8 +14,8 @@ ENV BUILD_PACKAGES apt-utils apt-file libpq-dev graphviz-dev build-essential git ## NAO EH PRA TIRAR O vim DA LISTA DE COMANDOS INSTALADOS!!! ENV RUN_PACKAGES graphviz python3-lxml python3-magic postgresql-client python3-psycopg2 \ poppler-utils curl jq bash vim python3-venv tzdata nodejs \ - fontconfig ttf-dejavu python nginx - + fontconfig ttf-dejavu python nginx cron + RUN mkdir -p /var/interlegis/sapl WORKDIR /var/interlegis/sapl/ @@ -47,11 +47,17 @@ COPY docker/config/nginx/sapl.conf /etc/nginx/conf.d COPY docker/config/nginx/nginx.conf /etc/nginx/nginx.conf COPY docker/config/env_dockerfile /var/interlegis/sapl/sapl/.env +# Environment variables to run collectstatic +# ENV DATABASE_URL=sqlite:////:memory: +# ENV SECRET_KEY=Development +# ENV DEBUG=True + RUN python3 manage.py collectstatic --noinput --clear -# Remove .env(fake) e sapl.db da imagem -RUN rm -rf /var/interlegis/sapl/sapl/.env && \ - rm -rf /var/interlegis/sapl/sapl.db +# Remove temporary .env +RUN rm -rf /var/interlegis/sapl/sapl/.env +# RUN rm -rf /var/interlegis/sapl/sapl/.env && \ +# rm -rf /var/interlegis/sapl/sapl.db RUN chmod +x /var/interlegis/sapl/start.sh && \ chmod +x /var/interlegis/sapl/wait-for-solr.sh && \ @@ -64,7 +70,7 @@ RUN chmod +x /var/interlegis/sapl/start.sh && \ # Debian não possui usuário 'nginx' necessário para o Debian RUN useradd --no-create-home nginx -ENV DEBIAN_FRONTEND teletype +ENV DEBIAN_FRONTEND=teletype EXPOSE 80/tcp 443/tcp diff --git a/docker/config/env_dockerfile b/docker/config/env_dockerfile index 4b564ee6c..b0e11f7d7 100644 --- a/docker/config/env_dockerfile +++ b/docker/config/env_dockerfile @@ -1,5 +1,5 @@ -DATABASE_URL = sqlite:///sapl.db -SECRET_KEY = 'mzp++@i1y-6y8ez_=^sfbr!dzuyry#^@v(3g^2d1k9%f=+mhlb' +DATABASE_URL = sqlite:////:memory: +SECRET_KEY = 'Temporary Env File' DEBUG = False EMAIL_USE_TLS = True EMAIL_PORT = 587 diff --git a/docker/start.sh b/docker/start.sh index 57b83b484..9f69138da 100755 --- a/docker/start.sh +++ b/docker/start.sh @@ -45,6 +45,10 @@ create_env() { create_env +echo "==============================================" +echo "DATABASE_URL=$DATABASE_URL" +echo "==============================================" + /bin/bash wait-for-pg.sh $DATABASE_URL yes yes | python3 manage.py migrate diff --git a/docker/wait-for-pg.sh b/docker/wait-for-pg.sh index ed07a4262..9ef8ab6b8 100644 --- a/docker/wait-for-pg.sh +++ b/docker/wait-for-pg.sh @@ -5,6 +5,8 @@ while true; do if ! [ "$COUNT_PG" -eq "0" ]; then break fi - echo "Esperando Database Setup" + echo "Waiting for Database Connection $1..." sleep 10 done + +echo "Database is reachable!"