mirror of https://github.com/interlegis/sapl.git
Browse Source
* Criando app painel websocket * desfazendo painel websocket e implantando docker-compose para desenvolvimento * Inserindo desenvolvimento com docker na documentacao de instalacaopull/2824/head
Ricardo Lima Canela
6 years ago
committed by
Edward
5 changed files with 201 additions and 1 deletions
@ -0,0 +1,34 @@ |
|||||
|
FROM alpine:3.8 |
||||
|
|
||||
|
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 py3-magic postgresql-client poppler-utils antiword \ |
||||
|
curl jq openssh-client vim bash |
||||
|
|
||||
|
RUN apk update --update-cache && apk upgrade |
||||
|
|
||||
|
RUN apk --update add fontconfig ttf-dejavu && fc-cache -fv |
||||
|
|
||||
|
RUN apk add --no-cache python3 nginx tzdata && \ |
||||
|
python3 -m ensurepip && \ |
||||
|
rm -r /usr/lib/python*/ensurepip && \ |
||||
|
pip3 install --upgrade pip setuptools && \ |
||||
|
rm -r /root/.cache && \ |
||||
|
rm -f /etc/nginx/conf.d/* |
||||
|
|
||||
|
RUN mkdir -p /var/interlegis/sapl && \ |
||||
|
apk add --update --no-cache $BUILD_PACKAGES |
||||
|
|
||||
|
ADD . /var/interlegis/sapl/ |
||||
|
|
||||
|
WORKDIR /var/interlegis/sapl/ |
||||
|
|
||||
|
RUN pip install -r /var/interlegis/sapl/requirements/dev-requirements.txt --upgrade setuptools && \ |
||||
|
rm -r /root/.cache |
||||
|
|
||||
|
#RUN python3 manage.py collectstatic --noinput --clear |
||||
|
|
||||
|
RUN chmod +x start_devel.sh |
||||
|
|
||||
|
CMD ["/var/interlegis/sapl/start_devel.sh"] |
||||
|
|
@ -0,0 +1,43 @@ |
|||||
|
sapldb: |
||||
|
image: postgres:10.5-alpine |
||||
|
restart: always |
||||
|
environment: |
||||
|
POSTGRES_PASSWORD: sapl |
||||
|
POSTGRES_USER: sapl |
||||
|
POSTGRES_DB: sapl |
||||
|
PGDATA : /var/lib/postgresql/data/ |
||||
|
volumes: |
||||
|
- sapldb_data:/var/lib/postgresql/data/ |
||||
|
ports: |
||||
|
- "5435:5432" |
||||
|
saplredis: |
||||
|
image: redis:5.0.3-stretch |
||||
|
restart: always |
||||
|
ports: |
||||
|
- "6379:6379" |
||||
|
sapl: |
||||
|
#image: interlegis/sapl:master |
||||
|
build: . |
||||
|
dockerfile: Dockerfile.dev |
||||
|
restart: always |
||||
|
environment: |
||||
|
ADMIN_PASSWORD: interlegis |
||||
|
ADMIN_EMAIL: email@dominio.net |
||||
|
DEBUG: 'True' |
||||
|
EMAIL_PORT: 587 |
||||
|
EMAIL_USE_TLS: 'False' |
||||
|
EMAIL_HOST: smtp.dominio.net |
||||
|
EMAIL_HOST_USER: usuariosmtp |
||||
|
EMAIL_SEND_USER: usuariosmtp |
||||
|
EMAIL_HOST_PASSWORD: senhasmtp |
||||
|
USE_CHANNEL_LAYERS: 'True' |
||||
|
PORT_CHANNEL_LAYERS: 6379 |
||||
|
HOST_CHANNEL_LAYERS: saplredis |
||||
|
TZ: America/Sao_Paulo |
||||
|
volumes: |
||||
|
- ./sapl:/var/interlegis/sapl/sapl |
||||
|
links: |
||||
|
- sapldb |
||||
|
- saplredis |
||||
|
ports: |
||||
|
- "80:80" |
@ -0,0 +1,107 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
create_env() { |
||||
|
echo "[ENV FILE] creating .env file..." |
||||
|
|
||||
|
KEY=`python3 genkey.py` |
||||
|
|
||||
|
FILENAME="/var/interlegis/sapl/sapl/.env" |
||||
|
|
||||
|
if [ -z "${DATABASE_URL:-}" ]; then |
||||
|
DATABASE_URL="postgresql://sapl:sapl@sapldb:5432/sapl" |
||||
|
fi |
||||
|
|
||||
|
touch $FILENAME |
||||
|
|
||||
|
|
||||
|
# explicitly use '>' to erase any previous content |
||||
|
echo "SECRET_KEY="$KEY > $FILENAME |
||||
|
# now only appends |
||||
|
echo "DATABASE_URL = "$DATABASE_URL >> $FILENAME |
||||
|
echo "DEBUG = ""${DEBUG-False}" >> $FILENAME |
||||
|
echo "EMAIL_USE_TLS = ""${USE_TLS-True}" >> $FILENAME |
||||
|
echo "EMAIL_PORT = ""${EMAIL_PORT-587}" >> $FILENAME |
||||
|
echo "EMAIL_HOST = ""${EMAIL_HOST-''}" >> $FILENAME |
||||
|
echo "EMAIL_HOST_USER = ""${EMAIL_HOST_USER-''}" >> $FILENAME |
||||
|
echo "EMAIL_HOST_PASSWORD = ""${EMAIL_HOST_PASSWORD-''}" >> $FILENAME |
||||
|
echo "EMAIL_SEND_USER = ""${EMAIL_HOST_USER-''}" >> $FILENAME |
||||
|
echo "DEFAULT_FROM_EMAIL = ""${EMAIL_HOST_USER-''}" >> $FILENAME |
||||
|
echo "SERVER_EMAIL = ""${EMAIL_HOST_USER-''}" >> $FILENAME |
||||
|
echo "USE_SOLR = ""${USE_SOLR-False}" >> $FILENAME |
||||
|
echo "SOLR_COLLECTION = ""${SOLR_COLLECTION-sapl}" >> $FILENAME |
||||
|
echo "SOLR_URL = ""${SOLR_URL-http://localhost:8983}" >> $FILENAME |
||||
|
echo "USE_CHANNEL_LAYERS = ""${USE_CHANNEL_LAYERS-True}" >> $FILENAME |
||||
|
echo "PORT_CHANNEL_LAYERS = ""${PORT_CHANNEL_LAYERS-6379}" >> $FILENAME |
||||
|
echo "HOST_CHANNEL_LAYERS = ""${HOST_CHANNEL_LAYERS-'saplredis'}" >> $FILENAME |
||||
|
echo "[ENV FILE] done." |
||||
|
} |
||||
|
|
||||
|
create_env |
||||
|
chmod 777 /var/interlegis/sapl/sapl/.env |
||||
|
|
||||
|
/bin/bash busy-wait.sh $DATABASE_URL |
||||
|
|
||||
|
yes yes | python3 manage.py migrate |
||||
|
|
||||
|
|
||||
|
## SOLR |
||||
|
USE_SOLR="${USE_SOLR:=False}" |
||||
|
SOLR_URL="${SOLR_URL:=http://localhost:8983}" |
||||
|
SOLR_COLLECTION="${SOLR_COLLECTION:=sapl}" |
||||
|
|
||||
|
NUM_SHARDS=${NUM_SHARDS:=1} |
||||
|
RF=${RF:=1} |
||||
|
MAX_SHARDS_PER_NODE=${MAX_SHARDS_PER_NODE:=1} |
||||
|
|
||||
|
if [ "${USE_SOLR-False}" == "True" ] || [ "${USE_SOLR-False}" == "true" ]; then |
||||
|
|
||||
|
echo "SOLR configurations" |
||||
|
echo "===================" |
||||
|
echo "URL: $SOLR_URL" |
||||
|
echo "COLLECTION: $SOLR_COLLECTION" |
||||
|
echo "NUM_SHARDS: $NUM_SHARDS" |
||||
|
echo "REPLICATION FACTOR: $RF" |
||||
|
echo "MAX SHARDS PER NODE: $MAX_SHARDS_PER_NODE" |
||||
|
echo "=========================================" |
||||
|
|
||||
|
/bin/bash check_solr.sh $SOLR_URL |
||||
|
|
||||
|
python3 solr_api.py -u $SOLR_URL -c $SOLR_COLLECTION -s $NUM_SHARDS -rf $RF -ms $MAX_SHARDS_PER_NODE & |
||||
|
# python3 manage.py rebuild_index --noinput & |
||||
|
else |
||||
|
echo "Suporte a SOLR não inicializado." |
||||
|
fi |
||||
|
|
||||
|
echo "Criando usuário admin..." |
||||
|
|
||||
|
user_created=$(python3 create_admin.py 2>&1) |
||||
|
|
||||
|
echo $user_created |
||||
|
|
||||
|
cmd=$(echo $user_created | grep 'ADMIN_USER_EXISTS') |
||||
|
user_exists=$? |
||||
|
|
||||
|
cmd=$(echo $user_created | grep 'MISSING_ADMIN_PASSWORD') |
||||
|
lack_pwd=$? |
||||
|
|
||||
|
if [ $user_exists -eq 0 ]; then |
||||
|
echo "[SUPERUSER CREATION] User admin already exists. Not creating" |
||||
|
fi |
||||
|
|
||||
|
if [ $lack_pwd -eq 0 ]; then |
||||
|
echo "[SUPERUSER] Environment variable $ADMIN_PASSWORD for superuser admin was not set. Leaving container" |
||||
|
# return -1 |
||||
|
fi |
||||
|
|
||||
|
echo "-------------------------------------" |
||||
|
echo "| ███████╗ █████╗ ██████╗ ██╗ |" |
||||
|
echo "| ██╔════╝██╔══██╗██╔══██╗██║ |" |
||||
|
echo "| ███████╗███████║██████╔╝██║ |" |
||||
|
echo "| ╚════██║██╔══██║██╔═══╝ ██║ |" |
||||
|
echo "| ███████║██║ ██║██║ ███████╗ |" |
||||
|
echo "| ╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝ |" |
||||
|
echo "-------------------------------------" |
||||
|
|
||||
|
python3 manage.py collectstatic --noinput --clear |
||||
|
|
||||
|
python3 manage.py runserver 0.0.0.0:80 |
Loading…
Reference in new issue