Browse Source

Ajusta busy-wait.sh script para sincronizar o banco(postgres) com a aplicação django no docker

pull/999/head
Matheus Veleci 9 years ago
committed by Edward Ribeiro
parent
commit
4bc0cf91e1
  1. 2
      Dockerfile
  2. 8
      busy-wait.sh
  3. 4
      docker-compose.yml
  4. 2
      sapl/.env_test

2
Dockerfile

@ -2,7 +2,7 @@ FROM alpine:3.5
ENV BUILD_PACKAGES postgresql-dev graphviz-dev graphviz build-base git pkgconfig \ ENV BUILD_PACKAGES postgresql-dev graphviz-dev graphviz build-base git pkgconfig \
python3-dev libxml2-dev jpeg-dev libressl-dev libffi-dev libxslt-dev nodejs py3-lxml \ python3-dev libxml2-dev jpeg-dev libressl-dev libffi-dev libxslt-dev nodejs py3-lxml \
py3-magic py3-magic postgresql-client
RUN apk add --no-cache python3 && \ RUN apk add --no-cache python3 && \
python3 -m ensurepip && \ python3 -m ensurepip && \

8
busy-wait.sh

@ -1,12 +1,10 @@
#!/bin/sh #!/bin/sh
#
while true; do while true; do
COUNT_PG=`netstat -an | grep "tcp.*:5532.*LISTEN"| wc -l` COUNT_PG=`psql --dbname=postgresql://sapl:sapl@sapldb/sapl -c '\l \q' | grep sapl | wc -l`
if ! [ "$COUNT_PG" -eq "0" ]; then if ! [ "$COUNT_PG" -eq "0" ]; then
break break
fi fi
echo "Esperando BD" echo "Esperando Database Setup"
sleep 5 sleep 10
done done

4
docker-compose.yml

@ -8,7 +8,7 @@ server:
- web - web
links: links:
- web - web
sapl_db: sapldb:
image: postgres image: postgres
environment: environment:
POSTGRES_PASSWORD: sapl POSTGRES_PASSWORD: sapl
@ -25,4 +25,4 @@ web:
volumes: volumes:
- .:/sapl - .:/sapl
links: links:
- sapl_db - sapldb

2
sapl/.env_test

@ -1,4 +1,4 @@
DATABASE_URL = postgresql://postgres:@localhost:/sapl DATABASE_URL = postgresql://postgres:@sapldb:/sapl
SECRET_KEY=TravisTest SECRET_KEY=TravisTest
DEBUG=False DEBUG=False
EMAIL_USE_TLS = True EMAIL_USE_TLS = True

Loading…
Cancel
Save