mirror of https://github.com/interlegis/sapl.git
Browse Source
* Refatora arquivos Docker * Conserta runtime * Retorna CI antigo Co-authored-by: eribeiro <edwardr@senado.leg.br>pull/3280/head
Edward
4 years ago
committed by
GitHub
28 changed files with 155 additions and 63 deletions
@ -1,7 +1,7 @@ |
|||
FROM python:3.6 |
|||
ENV PYTHONUNBUFFERED 1 |
|||
WORKDIR /sapl-dev |
|||
COPY requirements ./requirements/ |
|||
COPY ../requirements ./requirements/ |
|||
RUN apt update && \ |
|||
apt -y install graphviz-dev && \ |
|||
pip install --upgrade pip && \ |
@ -1,5 +1,5 @@ |
|||
DATABASE_URL = postgresql://postgres:@sapldb:/sapl |
|||
KEY |
|||
SECRET_KEY = 'mzp++@i1y-6y8ez_=^sfbr!dzuyry#^@v(3g^2d1k9%f=+mhlb' |
|||
DEBUG = False |
|||
EMAIL_USE_TLS = True |
|||
EMAIL_PORT = 587 |
@ -1,5 +1,5 @@ |
|||
DATABASE_URL = sqlite:///sapl.db |
|||
SECRET_KEY = 'Dockerfile_Key' |
|||
SECRET_KEY = 'mzp++@i1y-6y8ez_=^sfbr!dzuyry#^@v(3g^2d1k9%f=+mhlb' |
|||
DEBUG = False |
|||
EMAIL_USE_TLS = True |
|||
EMAIL_PORT = 587 |
@ -0,0 +1,9 @@ |
|||
DATABASE_URL=postgresql://sapl:sapl@sapldb:/sapl |
|||
SECRET_KEY=test++@i1y-6y8ez_=^sfbr!dzuyry#^@v(3g^2d1k9%f=+mhlb |
|||
DEBUG=False |
|||
EMAIL_USE_TLS = True |
|||
EMAIL_PORT = 587 |
|||
EMAIL_HOST = '' |
|||
EMAIL_HOST_USER = '' |
|||
EMAIL_SEND_USER = '' |
|||
EMAIL_HOST_PASSWORD = '' |
@ -0,0 +1,75 @@ |
|||
version: "3.7" |
|||
services: |
|||
sapldb: |
|||
image: postgres:10.5-alpine |
|||
restart: always |
|||
container_name: postgres |
|||
labels: |
|||
NAME: "postgres" |
|||
environment: |
|||
POSTGRES_PASSWORD: sapl |
|||
POSTGRES_USER: sapl |
|||
POSTGRES_DB: sapl |
|||
PGDATA : /var/lib/postgresql/data/ |
|||
volumes: |
|||
- sapldb_data:/var/lib/postgresql/data/ |
|||
ports: |
|||
- "5433:5432" |
|||
networks: |
|||
- sapl-net |
|||
saplsolr: |
|||
image: solr:8.3 |
|||
restart: always |
|||
command: bin/solr start -c -f |
|||
container_name: solr |
|||
labels: |
|||
NAME: "solr" |
|||
volumes: |
|||
- solr_data:/opt/solr/server/solr |
|||
- solr_configsets:/opt/solr/server/solr/configsets |
|||
ports: |
|||
- "8983:8983" |
|||
networks: |
|||
- sapl-net |
|||
sapl: |
|||
build: |
|||
context: ../ |
|||
dockerfile: ./docker/Dockerfile |
|||
container_name: sapl |
|||
labels: |
|||
NAME: "sapl" |
|||
restart: always |
|||
environment: |
|||
ADMIN_PASSWORD: interlegis |
|||
ADMIN_EMAIL: email@dominio.net |
|||
DEBUG: 'False' |
|||
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_SOLR: 'True' |
|||
SOLR_COLLECTION: sapl |
|||
SOLR_URL: http://saplsolr:8983 |
|||
TZ: America/Sao_Paulo |
|||
volumes: |
|||
- sapl_data:/var/interlegis/sapl/data |
|||
- sapl_media:/var/interlegis/sapl/media |
|||
depends_on: |
|||
- sapldb |
|||
- saplsolr |
|||
ports: |
|||
- "80:80" |
|||
networks: |
|||
- sapl-net |
|||
networks: |
|||
sapl-net: |
|||
name: sapl-net |
|||
driver: bridge |
|||
volumes: |
|||
sapldb_data: |
|||
sapl_data: |
|||
sapl_media: |
|||
solr_data: |
|||
solr_configsets: |
@ -0,0 +1,38 @@ |
|||
sudo: required |
|||
|
|||
services: |
|||
- docker |
|||
|
|||
env: |
|||
global: |
|||
- DOCKER_COMPOSE_VERSION=1.26.2 |
|||
|
|||
before_install: |
|||
# Install latest versions of docker and docker-compose |
|||
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - |
|||
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" |
|||
- sudo apt-get update |
|||
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce |
|||
- sudo rm /usr/local/bin/docker-compose |
|||
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose |
|||
- chmod +x docker-compose |
|||
- sudo mv docker-compose /usr/local/bin |
|||
- docker --version |
|||
- docker-compose --version |
|||
|
|||
install: |
|||
- sudo service postgresql stop || true |
|||
|
|||
script: |
|||
- cd $TRAVIS_BUILD_DIR/docker |
|||
# Build master images and run the webserver (tests end to end) |
|||
#- docker-compose -f docker-compose.test.yml build |
|||
#- docker-compose up -d |
|||
#- docker logs sapl |
|||
#- docker-compose rm -f -s -v |
|||
- docker-compose -f docker-compose-test.yml run --workdir="/var/interlegis/sapl" sapl bash -c "bash busy-wait.sh postgresql://sapl:sapl@sapldb:5432/sapl && cp docker/config/env_test .env && py.test --create-db" |
|||
|
|||
after_script: |
|||
# Cleanup docker containers, images, and volumes |
|||
- docker-compose rm -f -s -v |
|||
- docker system prune -a -f --volumes |
@ -1,49 +0,0 @@ |
|||
from flask import Flask |
|||
import requests |
|||
import psycopg2 |
|||
import json |
|||
from sapl.settings import DATABASES, USE_SOLR, SOLR_URL |
|||
|
|||
|
|||
app = Flask(__name__) |
|||
|
|||
|
|||
@app.route('/health') |
|||
def health(): |
|||
try: |
|||
db = DATABASES['default'] |
|||
conn = psycopg2.connect(host=db['HOST'], |
|||
user=db['USER'], |
|||
password=db['PASSWORD'], |
|||
database=db['NAME'], |
|||
port=db['PORT']) |
|||
cursor = conn.cursor() |
|||
cursor.execute("SELECT 1;") |
|||
resp = {'DATABASE': 'OK'} |
|||
except Exception as e: |
|||
resp = {'DATABASE': 'ERROR'} |
|||
finally: |
|||
if cursor: |
|||
cursor.close() |
|||
conn.close() |
|||
|
|||
if USE_SOLR: |
|||
r = requests.get(SOLR_URL) |
|||
if r.ok: |
|||
resp.update({'SEARCH_ENGINE': 'OK'}) |
|||
else: |
|||
resp.update({'SEARCH_ENGINE': 'ERROR'}) |
|||
|
|||
else: |
|||
resp.update({'SEARCH_ENGINE': 'NOT_ENABLED'}) |
|||
|
|||
return json.dumps(resp) |
|||
|
|||
|
|||
@app.route('/ping') |
|||
def ping(): |
|||
return "pong" |
|||
|
|||
|
|||
if __name__ == '__main__': |
|||
app.run() |
Loading…
Reference in new issue