Browse Source

Refatora Dockerfile e afins

adicionar-cron-job
Edward Ribeiro 2 years ago
parent
commit
aafdd86bcb
  1. 20
      docker/Dockerfile
  2. 4
      docker/config/env_dockerfile
  3. 4
      docker/start.sh
  4. 4
      docker/wait-for-pg.sh

20
docker/Dockerfile

@ -3,9 +3,9 @@ FROM python:3.9-slim-buster
# Setup env # Setup env
ENV LANG C.UTF-8 ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8 ENV LC_ALL C.UTF-8
ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=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 \ 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 \ python3-dev libxml2-dev libjpeg-dev libssl-dev libffi-dev libxslt1-dev \
@ -14,7 +14,7 @@ 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!!! ## NAO EH PRA TIRAR O vim DA LISTA DE COMANDOS INSTALADOS!!!
ENV RUN_PACKAGES graphviz python3-lxml python3-magic postgresql-client python3-psycopg2 \ ENV RUN_PACKAGES graphviz python3-lxml python3-magic postgresql-client python3-psycopg2 \
poppler-utils curl jq bash vim python3-venv tzdata nodejs \ 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 RUN mkdir -p /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/nginx/nginx.conf /etc/nginx/nginx.conf
COPY docker/config/env_dockerfile /var/interlegis/sapl/sapl/.env 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 RUN python3 manage.py collectstatic --noinput --clear
# Remove .env(fake) e sapl.db da imagem # 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 rm -rf /var/interlegis/sapl/sapl/.env && \
# rm -rf /var/interlegis/sapl/sapl.db
RUN chmod +x /var/interlegis/sapl/start.sh && \ RUN chmod +x /var/interlegis/sapl/start.sh && \
chmod +x /var/interlegis/sapl/wait-for-solr.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 # Debian não possui usuário 'nginx' necessário para o Debian
RUN useradd --no-create-home nginx RUN useradd --no-create-home nginx
ENV DEBIAN_FRONTEND teletype ENV DEBIAN_FRONTEND=teletype
EXPOSE 80/tcp 443/tcp EXPOSE 80/tcp 443/tcp

4
docker/config/env_dockerfile

@ -1,5 +1,5 @@
DATABASE_URL = sqlite:///sapl.db DATABASE_URL = sqlite:////:memory:
SECRET_KEY = 'mzp++@i1y-6y8ez_=^sfbr!dzuyry#^@v(3g^2d1k9%f=+mhlb' SECRET_KEY = 'Temporary Env File'
DEBUG = False DEBUG = False
EMAIL_USE_TLS = True EMAIL_USE_TLS = True
EMAIL_PORT = 587 EMAIL_PORT = 587

4
docker/start.sh

@ -45,6 +45,10 @@ create_env() {
create_env create_env
echo "=============================================="
echo "DATABASE_URL=$DATABASE_URL"
echo "=============================================="
/bin/bash wait-for-pg.sh $DATABASE_URL /bin/bash wait-for-pg.sh $DATABASE_URL
yes yes | python3 manage.py migrate yes yes | python3 manage.py migrate

4
docker/wait-for-pg.sh

@ -5,6 +5,8 @@ while true; do
if ! [ "$COUNT_PG" -eq "0" ]; then if ! [ "$COUNT_PG" -eq "0" ]; then
break break
fi fi
echo "Esperando Database Setup" echo "Waiting for Database Connection $1..."
sleep 10 sleep 10
done done
echo "Database is reachable!"

Loading…
Cancel
Save