From 1186196343fd223a04340e8822f2d4a933a4a4b1 Mon Sep 17 00:00:00 2001 From: Filipe Lopes Date: Sun, 30 Oct 2022 11:12:26 -0300 Subject: [PATCH 1/6] feat: add folders and files. Cron is running --- .env.example | 7 +++++++ .gitignore | 3 ++- README.md | 5 ++++- cron/Dockerfile | 20 ++++++++++++++++++++ cron/app/__init__.py | 0 cron/app/app.py | 22 ++++++++++++++++++++++ cron/app/requirements.txt | 6 ++++++ cron/crontab.txt | 3 +++ cron/entry.sh | 6 ++++++ cron/script.sh | 5 +++++ cron/wsgi.py | 4 ++++ docker-compose.yml | 15 +++++++++++++++ 12 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 .env.example create mode 100644 cron/Dockerfile create mode 100644 cron/app/__init__.py create mode 100644 cron/app/app.py create mode 100644 cron/app/requirements.txt create mode 100644 cron/crontab.txt create mode 100644 cron/entry.sh create mode 100644 cron/script.sh create mode 100644 cron/wsgi.py diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..3b0cb6a --- /dev/null +++ b/.env.example @@ -0,0 +1,7 @@ +POSTGRES_DB='esus' +POSTGRES_USER='postgres' +POSTGRES_PASSWORD='esus' +POSTGRESQL_PORT=54351 +APP_PORT=88 +PGWEB_PORT=8099 +TIMEZONE='America/Bahia' diff --git a/.gitignore b/.gitignore index 0ae55ed..400949a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ data __pycache__ *.pyc *.backup -.webassets-cache \ No newline at end of file +.webassets-cache +.env \ No newline at end of file diff --git a/README.md b/README.md index 06e084a..1685fd8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # eSUS PEC -É um sistema bastante utilizado por profissionais de saúde da Atenção Básica para registros de pacientes e dados de saúde. Esse repositório se propõe a criar uma estrutura docker com linux para viabilizar o deploy do sistema em qualquer ambiente que tenha docker e facilitar a instalação e atualização. +Compatível e testado com +![version](https://img.shields.io/badge/version-5.0.12-blue) ![version](https://img.shields.io/badge/version-5.0.8-blue) ![version](https://img.shields.io/badge/version-4.5.5-blue) ![version](https://img.shields.io/badge/version-4.2.6-blue) + +É um sistema bastante utilizado por profissionais de saúde da Atenção Básica para registros de pacientes e dados de saúde. Esse repositório se propõe a criar uma estrutura docker com linux para viabilizar o deploy do sistema em qualquer ambiente que tenha docker e facilitar a instalação e atualização do sistema [e-SUS PEC](https://sisaps.saude.gov.br/esus/) ## Preparando pacotes diff --git a/cron/Dockerfile b/cron/Dockerfile new file mode 100644 index 0000000..89580f6 --- /dev/null +++ b/cron/Dockerfile @@ -0,0 +1,20 @@ +FROM python:alpine3.16 + +# instalando dependências para o container +RUN apk add --no-cache postgresql-client + +# Copiando arquivos de uso do cron +ADD crontab.txt /crontab.txt +ADD script.sh /script.sh +COPY entry.sh /entry.sh +RUN chmod 755 /script.sh /entry.sh +RUN /usr/bin/crontab /crontab.txt + +# Criando o cenário para rodar a aplicação python +WORKDIR /home +COPY app . +COPY wsgi.py / +RUN pip install -r requirements.txt + +WORKDIR / +CMD ["/entry.sh"] \ No newline at end of file diff --git a/cron/app/__init__.py b/cron/app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/cron/app/app.py b/cron/app/app.py new file mode 100644 index 0000000..dc1cfc8 --- /dev/null +++ b/cron/app/app.py @@ -0,0 +1,22 @@ +import os +import sys +from flask import Flask + +app = Flask(__name__) + +@app.route("/backup-database") +def backup_database(): + from sh import pg_dump + from datetime import datetime + + now = datetime.now() + + DATABASE_HOST = os.getenv('POSTGRES_HOST', 'psql') + DATABASE_NAME = os.getenv('POSTGRES_DB', 'esus') + DATABASE_USER = os.getenv('POSTGRES_USER', 'postgres') + + + print('Realizando backup do banco de dados...', file=sys.stderr) + pg_dump('--host', DATABASE_HOST, '--port', '5432', '-U', DATABASE_USER, '-w', '--format', 'custom', '--blobs', '--encoding', 'UTF8', '--no-privileges', '--no-tablespaces', '--no-unlogged-table-data', '--file', f'/home/{now.strftime("%Y_%m_%d_%H_%M_%S")}.backup', DATABASE_NAME) + + return "

Hello, World!

" \ No newline at end of file diff --git a/cron/app/requirements.txt b/cron/app/requirements.txt new file mode 100644 index 0000000..d7c342a --- /dev/null +++ b/cron/app/requirements.txt @@ -0,0 +1,6 @@ +Flask==2.2.2 +gunicorn==20.1.0 +sh==1.14.3 +google-api-python-client +google-auth-httplib2 +google-auth-oauthlib \ No newline at end of file diff --git a/cron/crontab.txt b/cron/crontab.txt new file mode 100644 index 0000000..2861c4b --- /dev/null +++ b/cron/crontab.txt @@ -0,0 +1,3 @@ +# m h dom mon dow user command +*/5 * * * * /script.sh >> /var/log/script.log + \ No newline at end of file diff --git a/cron/entry.sh b/cron/entry.sh new file mode 100644 index 0000000..d22b09f --- /dev/null +++ b/cron/entry.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +# start python app +gunicorn --bind 0.0.0.0:5000 -D --enable-stdio-inheritance --capture-output --log-level debug wsgi:app +# start cron +/usr/sbin/crond -f -l 8 \ No newline at end of file diff --git a/cron/script.sh b/cron/script.sh new file mode 100644 index 0000000..cf64061 --- /dev/null +++ b/cron/script.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +# code goes here. +wget http://localhost:5000/backup-database +echo "This is a script, run by cron!" diff --git a/cron/wsgi.py b/cron/wsgi.py new file mode 100644 index 0000000..7172746 --- /dev/null +++ b/cron/wsgi.py @@ -0,0 +1,4 @@ +from home.app import app + +if __name__ == "__main__": + app.run() \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index a62563d..1a2e250 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,3 +33,18 @@ services: - "${APP_PORT}:8080" depends_on: - psql + cron: + container_name: esus_cron + restart: always + build: + context: cron + dockerfile: Dockerfile + volumes: + - ./cron/crontab.txt:/crontab.txt + - ./cron/app:/home + environment: + - POSTGRES_DB=${POSTGRES_DB} + - POSTGRES_USER=${POSTGRES_USER} + - PGPASSWORD=${POSTGRES_PASSWORD} + depends_on: + - psql From fca67052537203a7396418f9cc4dc080cef7203d Mon Sep 17 00:00:00 2001 From: Filipe Lopes Date: Fri, 4 Nov 2022 06:29:04 -0300 Subject: [PATCH 2/6] feat: update google-auth flow --- .env | 1 + .env.example | 1 + .gitignore | 4 +- Makefile | 6 ++- README.md | 9 ++++ cron/app/app.py | 100 ++++++++++++++++++++++++++++++++++++----- cron/app/quickstart.py | 59 ++++++++++++++++++++++++ cron/crontab.txt | 2 +- cron/entry.sh | 2 +- docker-compose.yml | 3 ++ 10 files changed, 172 insertions(+), 15 deletions(-) create mode 100644 cron/app/quickstart.py diff --git a/.env b/.env index 3b0cb6a..ccecb58 100644 --- a/.env +++ b/.env @@ -5,3 +5,4 @@ POSTGRESQL_PORT=54351 APP_PORT=88 PGWEB_PORT=8099 TIMEZONE='America/Bahia' +CRON_PORT='89' \ No newline at end of file diff --git a/.env.example b/.env.example index 3b0cb6a..ccecb58 100644 --- a/.env.example +++ b/.env.example @@ -5,3 +5,4 @@ POSTGRESQL_PORT=54351 APP_PORT=88 PGWEB_PORT=8099 TIMEZONE='America/Bahia' +CRON_PORT='89' \ No newline at end of file diff --git a/.gitignore b/.gitignore index 400949a..f26de81 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ __pycache__ *.pyc *.backup .webassets-cache -.env \ No newline at end of file +.env +client_secret_*.json +credentials.json \ No newline at end of file diff --git a/Makefile b/Makefile index 052540a..6e64654 100644 --- a/Makefile +++ b/Makefile @@ -21,4 +21,8 @@ dev-update: terminal: docker exec -it esus_app bash db-terminal: - docker exec -it esus_psql bash \ No newline at end of file + docker exec -it esus_psql bash +prod-google-api: + docker exec -it esus_cron sh -c "python /home/app.py" +google-oauth-quickstart: + docker exec -it esus_cron sh -c "python /home/quickstart.py" \ No newline at end of file diff --git a/README.md b/README.md index 1685fd8..c7da5d7 100644 --- a/README.md +++ b/README.md @@ -93,3 +93,12 @@ sh build.sh -f eSUS-AB-PEC-5.0.8-Linux64.jar - Testes realizados com versão `4.2.7` e `4.2.8` não foram bem sucedidos - A versão 4.2.8 está com erro no formulário de cadastro, nas requisições ao banco de dados, pelo endpoint graphql, retorna "Não autorizado" - Verificar sempre a memória caso queira fazer depois em servidor. Senão ele trará no console um `Killed` inesperado https://stackoverflow.com/questions/37071106/spring-boot-application-quits-unexpectedly-with-killed + +## Serviço de backup + +Para fazer funcionar o serviço de backup na nuvem ela deve estar relacionada a um Google Drive, se assim não for irá armazenar os backups apenas localmente. Para o uso de backup na nuvem é necessário: + +1. [Criar uma chave de Client ID Google](https://developers.google.com/drive/api/quickstart/python) +2. Salve o arquivo json baixado com segurança e cole na pasta `cron/app/credentials.json` +3. Execute `make prod-google-api` para iniciar autenticação Google e permitir acessos + diff --git a/cron/app/app.py b/cron/app/app.py index dc1cfc8..d93a6e7 100644 --- a/cron/app/app.py +++ b/cron/app/app.py @@ -1,22 +1,100 @@ +from __future__ import print_function +from datetime import datetime + import os import sys -from flask import Flask +from flask import Flask, request + +import pickle +import os.path +from googleapiclient.discovery import build +from google_auth_oauthlib.flow import InstalledAppFlow +from google.auth.transport.requests import Request +from googleapiclient.http import MediaFileUpload +from google.oauth2.credentials import Credentials + +CRON_PORT = int(os.getenv('CRON_PORT', 89)) + +# If modifying these scopes, delete the file token.pickle. +SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly', + 'https://www.googleapis.com/auth/drive.file'] + + +now = datetime.now() +filename = f'{now.strftime("%Y_%m_%d_%H_%M_%S")}.backup' + +DATABASE_HOST = os.getenv('POSTGRES_HOST', 'psql') +DATABASE_NAME = os.getenv('POSTGRES_DB', 'esus') +DATABASE_USER = os.getenv('POSTGRES_USER', 'postgres') + +google_drive_folder_id = '1osoeAhww2IM2V2W_xbgcRoROHEk_DAPw' + + +def get_google_credentials(): + """Authenticates at Google API""" + creds = None + # The file token.json stores the user's access and refresh tokens, and is + # created automatically when the authorization flow completes for the first + # time. + if os.path.exists('token.json'): + creds = Credentials.from_authorized_user_file('token.json', SCOPES) + # If there are no (valid) credentials available, let the user log in. + if not creds or not creds.valid: + if creds and creds.expired and creds.refresh_token: + creds.refresh(Request()) + else: + flow = InstalledAppFlow.from_client_secrets_file( + os.path.join(os.path.dirname(__file__), 'credentials.json'), SCOPES) + creds = flow.run_local_server( + host='localhost', port=CRON_PORT, open_browser=True) + # Save the credentials for the next run + with open('token.json', 'w') as token: + token.write(creds.to_json()) + + return creds + app = Flask(__name__) + +@app.route("/") +def home(): + code = request.args.get('code') + flow = InstalledAppFlow.from_client_secrets_file( + os.path.join(os.path.dirname(__file__), 'credentials.json'), SCOPES, redirect_uri='/api/v1/backup-database') + flow.fetch_token(code=code, include_client_id=True) + return code + @app.route("/backup-database") def backup_database(): from sh import pg_dump - from datetime import datetime - now = datetime.now() + print(os.path.join(os.path.dirname(__file__)), file=sys.stderr) + print(os.path.join(os.path.dirname(__file__), + 'credentials.json'), file=sys.stderr) - DATABASE_HOST = os.getenv('POSTGRES_HOST', 'psql') - DATABASE_NAME = os.getenv('POSTGRES_DB', 'esus') - DATABASE_USER = os.getenv('POSTGRES_USER', 'postgres') - - print('Realizando backup do banco de dados...', file=sys.stderr) - pg_dump('--host', DATABASE_HOST, '--port', '5432', '-U', DATABASE_USER, '-w', '--format', 'custom', '--blobs', '--encoding', 'UTF8', '--no-privileges', '--no-tablespaces', '--no-unlogged-table-data', '--file', f'/home/{now.strftime("%Y_%m_%d_%H_%M_%S")}.backup', DATABASE_NAME) - - return "

Hello, World!

" \ No newline at end of file + pg_dump('--host', DATABASE_HOST, '--port', '5432', '-U', DATABASE_USER, '-w', '--format', 'custom', '--blobs', '--encoding', + 'UTF8', '--no-privileges', '--no-tablespaces', '--no-unlogged-table-data', '--file', f'/home/{filename}', DATABASE_NAME) + + # Google Drive service + service = build('drive', 'v3', credentials=get_google_credentials()) + + print("Folder ID:", google_drive_folder_id) + # upload a file text file + # first, define file metadata, such as the name and the parent folder ID + file_metadata = { + "name": filename, + "parents": [google_drive_folder_id] + } + + # upload + media = MediaFileUpload(f'/home/{filename}', resumable=True) + file = service.files().create(body=file_metadata, + media_body=media, fields='id').execute() + print("File created, id:", file.get("id")) + + return None + +if __name__ == '__main__': + get_google_credentials() diff --git a/cron/app/quickstart.py b/cron/app/quickstart.py new file mode 100644 index 0000000..af4b58c --- /dev/null +++ b/cron/app/quickstart.py @@ -0,0 +1,59 @@ +from __future__ import print_function + +import os.path + +from google.auth.transport.requests import Request +from google.oauth2.credentials import Credentials +from google_auth_oauthlib.flow import InstalledAppFlow +from googleapiclient.discovery import build +from googleapiclient.errors import HttpError + +# If modifying these scopes, delete the file token.json. +SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly'] + +CRON_PORT = int(os.getenv('CRON_PORT', 89)) + + +def main(): + """Shows basic usage of the Drive v3 API. + Prints the names and ids of the first 10 files the user has access to. + """ + creds = None + # The file token.json stores the user's access and refresh tokens, and is + # created automatically when the authorization flow completes for the first + # time. + if os.path.exists('token.json'): + creds = Credentials.from_authorized_user_file('token.json', SCOPES) + # If there are no (valid) credentials available, let the user log in. + if not creds or not creds.valid: + if creds and creds.expired and creds.refresh_token: + creds.refresh(Request()) + else: + flow = InstalledAppFlow.from_client_secrets_file( + os.path.join(os.path.dirname(__file__), 'credentials.json'), SCOPES, redirect_uri='https://filipelopes.me') + creds = flow.run_local_server(host='localhost', port=CRON_PORT, open_browser=True) + # Save the credentials for the next run + with open('token.json', 'w') as token: + token.write(creds.to_json()) + + try: + service = build('drive', 'v3', credentials=creds) + + # Call the Drive v3 API + results = service.files().list( + pageSize=10, fields="nextPageToken, files(id, name)").execute() + items = results.get('files', []) + + if not items: + print('No files found.') + return + print('Files:') + for item in items: + print(u'{0} ({1})'.format(item['name'], item['id'])) + except HttpError as error: + # TODO(developer) - Handle errors from drive API. + print(f'An error occurred: {error}') + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/cron/crontab.txt b/cron/crontab.txt index 2861c4b..e41852f 100644 --- a/cron/crontab.txt +++ b/cron/crontab.txt @@ -1,3 +1,3 @@ # m h dom mon dow user command -*/5 * * * * /script.sh >> /var/log/script.log +0 * * * * /script.sh >> /var/log/script.log \ No newline at end of file diff --git a/cron/entry.sh b/cron/entry.sh index d22b09f..3c37199 100644 --- a/cron/entry.sh +++ b/cron/entry.sh @@ -1,6 +1,6 @@ #!/bin/sh # start python app -gunicorn --bind 0.0.0.0:5000 -D --enable-stdio-inheritance --capture-output --log-level debug wsgi:app +gunicorn --bind 0.0.0.0:5000 -D --enable-stdio-inheritance --capture-output --log-level debug --reload wsgi:app # start cron /usr/sbin/crond -f -l 8 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 1a2e250..5637380 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -46,5 +46,8 @@ services: - POSTGRES_DB=${POSTGRES_DB} - POSTGRES_USER=${POSTGRES_USER} - PGPASSWORD=${POSTGRES_PASSWORD} + - CRON_PORT=${CRON_PORT} + ports: + - "${CRON_PORT}:5000" depends_on: - psql From 926068dc5887bfe265c34c25d9064bd868d50def Mon Sep 17 00:00:00 2001 From: Filipe Lopes Date: Fri, 11 Nov 2022 15:32:27 -0300 Subject: [PATCH 3/6] feat(db-backup): backup database, update and delete old one through Google Drive API --- .env | 3 +- .env.example | 3 +- .gitignore | 4 +- Dockerfile | 2 - Makefile | 15 +++-- README.md | 9 +-- cron/Dockerfile | 11 +++- cron/app/app.py | 137 +++++++++++++++++++--------------------- cron/app/env.py | 13 ++++ cron/app/googleoauth.py | 43 +++++++++++++ cron/app/quickstart.py | 59 ----------------- cron/script.sh | 2 +- docker-compose.yml | 5 +- 13 files changed, 154 insertions(+), 152 deletions(-) create mode 100644 cron/app/env.py create mode 100644 cron/app/googleoauth.py delete mode 100644 cron/app/quickstart.py diff --git a/.env b/.env index ccecb58..1a60b44 100644 --- a/.env +++ b/.env @@ -4,5 +4,4 @@ POSTGRES_PASSWORD='esus' POSTGRESQL_PORT=54351 APP_PORT=88 PGWEB_PORT=8099 -TIMEZONE='America/Bahia' -CRON_PORT='89' \ No newline at end of file +TIMEZONE='America/Bahia' \ No newline at end of file diff --git a/.env.example b/.env.example index ccecb58..1a60b44 100644 --- a/.env.example +++ b/.env.example @@ -4,5 +4,4 @@ POSTGRES_PASSWORD='esus' POSTGRESQL_PORT=54351 APP_PORT=88 PGWEB_PORT=8099 -TIMEZONE='America/Bahia' -CRON_PORT='89' \ No newline at end of file +TIMEZONE='America/Bahia' \ No newline at end of file diff --git a/.gitignore b/.gitignore index f26de81..9582596 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ __pycache__ .webassets-cache .env client_secret_*.json -credentials.json \ No newline at end of file +credentials.json +token.json +venv \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index d77aaeb..29f3a75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,6 +43,4 @@ COPY ./run.sh run.sh RUN chmod +x /var/www/html/install.sh RUN chmod +x /var/www/html/run.sh -EXPOSE 8080 - CMD "/var/www/html/run.sh" \ No newline at end of file diff --git a/Makefile b/Makefile index 6e64654..60590de 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,14 @@ terminal: docker exec -it esus_app bash db-terminal: docker exec -it esus_psql bash -prod-google-api: - docker exec -it esus_cron sh -c "python /home/app.py" -google-oauth-quickstart: - docker exec -it esus_cron sh -c "python /home/quickstart.py" \ No newline at end of file +backup-test: + docker exec -it esus_cron sh -c "curl localhost:5000/backup-database" +google-oauth: + cd cron/app; \ + python3 --version; \ + pip3 install virtualenv; \ + virtualenv cron/app/venv; \ + chmod +x ./venv/bin/activate; \ + ./venv/bin/activate; \ + pip install -r requirements.txt; \ + python googleoauth.py; \ \ No newline at end of file diff --git a/README.md b/README.md index c7da5d7..97a3eeb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # eSUS PEC Compatível e testado com -![version](https://img.shields.io/badge/version-5.0.12-blue) ![version](https://img.shields.io/badge/version-5.0.8-blue) ![version](https://img.shields.io/badge/version-4.5.5-blue) ![version](https://img.shields.io/badge/version-4.2.6-blue) +![version](https://img.shields.io/badge/version-5.0.12-blue) ![version](https://img.shields.io/badge/version-5.0.8-blue) ![version](https://img.shields.io/badge/version-4.5.5-blue) ![version](https://img.shields.io/badge/version-4.2.6-blue) ![version](https://img.shields.io/badge/version-5.0.14-blue) É um sistema bastante utilizado por profissionais de saúde da Atenção Básica para registros de pacientes e dados de saúde. Esse repositório se propõe a criar uma estrutura docker com linux para viabilizar o deploy do sistema em qualquer ambiente que tenha docker e facilitar a instalação e atualização do sistema [e-SUS PEC](https://sisaps.saude.gov.br/esus/) @@ -85,7 +85,7 @@ pg_restore -U "postgres" -d "esus" -1 /home/seu_arquivo.backup Fora do container, na pasta raiz do projeto execute, substituindo o nome do pacote `eSUS-AB-PEC-5.0.8-Linux64.jar` para a versão que você vai instalar em sua máquina. ```sh -sh build.sh -f eSUS-AB-PEC-5.0.8-Linux64.jar +sh build.sh -f eSUS-AB-PEC-5.0.14-Linux64.jar ``` ## Known Issues (Bugs Conhecidos) @@ -93,12 +93,13 @@ sh build.sh -f eSUS-AB-PEC-5.0.8-Linux64.jar - Testes realizados com versão `4.2.7` e `4.2.8` não foram bem sucedidos - A versão 4.2.8 está com erro no formulário de cadastro, nas requisições ao banco de dados, pelo endpoint graphql, retorna "Não autorizado" - Verificar sempre a memória caso queira fazer depois em servidor. Senão ele trará no console um `Killed` inesperado https://stackoverflow.com/questions/37071106/spring-boot-application-quits-unexpectedly-with-killed +- Não instale a versão `5.0.8`, do de cabeça, não carrega alguns exames e atendimentos de forma aparentemente aleatória, corrigido após instalar versão `5.0.14` ## Serviço de backup Para fazer funcionar o serviço de backup na nuvem ela deve estar relacionada a um Google Drive, se assim não for irá armazenar os backups apenas localmente. Para o uso de backup na nuvem é necessário: 1. [Criar uma chave de Client ID Google](https://developers.google.com/drive/api/quickstart/python) -2. Salve o arquivo json baixado com segurança e cole na pasta `cron/app/credentials.json` -3. Execute `make prod-google-api` para iniciar autenticação Google e permitir acessos +2. Salve o arquivo json baixado com segurança e cole na pasta como `cron/app/credentials.json` +3. Execute `make google-oauth` para iniciar autenticação Google e permitir acessos. É necessário para criar o `token.json` que guardará as credenciais. Caso o comando não funcione, provavelmente você não está no linux ou não tem o `python3` instalado no seu linux. **É importante que ao executar o comando você esteja dentro da pasta raiz do projeto. diff --git a/cron/Dockerfile b/cron/Dockerfile index 89580f6..0a3c544 100644 --- a/cron/Dockerfile +++ b/cron/Dockerfile @@ -1,7 +1,16 @@ FROM python:alpine3.16 # instalando dependências para o container -RUN apk add --no-cache postgresql-client +RUN apk add --no-cache postgresql-client tzdata curl + +ARG TIMEZONE + +# Configurando timezone +RUN ls /usr/share/zoneinfo +RUN cp "/usr/share/zoneinfo/${TIMEZONE}" /etc/localtime +RUN echo "${TIMEZONE}" > /etc/timezone +RUN date +RUN apk del tzdata # Copiando arquivos de uso do cron ADD crontab.txt /crontab.txt diff --git a/cron/app/app.py b/cron/app/app.py index d93a6e7..e0b21f1 100644 --- a/cron/app/app.py +++ b/cron/app/app.py @@ -3,98 +3,89 @@ import os import sys -from flask import Flask, request +from flask import Flask, Response -import pickle import os.path from googleapiclient.discovery import build -from google_auth_oauthlib.flow import InstalledAppFlow -from google.auth.transport.requests import Request from googleapiclient.http import MediaFileUpload -from google.oauth2.credentials import Credentials - -CRON_PORT = int(os.getenv('CRON_PORT', 89)) - -# If modifying these scopes, delete the file token.pickle. -SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly', - 'https://www.googleapis.com/auth/drive.file'] - - -now = datetime.now() -filename = f'{now.strftime("%Y_%m_%d_%H_%M_%S")}.backup' - -DATABASE_HOST = os.getenv('POSTGRES_HOST', 'psql') -DATABASE_NAME = os.getenv('POSTGRES_DB', 'esus') -DATABASE_USER = os.getenv('POSTGRES_USER', 'postgres') - -google_drive_folder_id = '1osoeAhww2IM2V2W_xbgcRoROHEk_DAPw' - - -def get_google_credentials(): - """Authenticates at Google API""" - creds = None - # The file token.json stores the user's access and refresh tokens, and is - # created automatically when the authorization flow completes for the first - # time. - if os.path.exists('token.json'): - creds = Credentials.from_authorized_user_file('token.json', SCOPES) - # If there are no (valid) credentials available, let the user log in. - if not creds or not creds.valid: - if creds and creds.expired and creds.refresh_token: - creds.refresh(Request()) - else: - flow = InstalledAppFlow.from_client_secrets_file( - os.path.join(os.path.dirname(__file__), 'credentials.json'), SCOPES) - creds = flow.run_local_server( - host='localhost', port=CRON_PORT, open_browser=True) - # Save the credentials for the next run - with open('token.json', 'w') as token: - token.write(creds.to_json()) - - return creds +from googleapiclient.errors import HttpError +from .env import BACKUP_EXPIRATION_TIME, DATABASE_HOST, DATABASE_NAME, DATABASE_USER, FILENAME, GOOGLE_DRIVE_FOLDER_ID, FILE_EXTENSION +from .googleoauth import get_google_credentials app = Flask(__name__) +def get_file_in_path(filename): + return os.path.join(os.path.dirname(os.path.realpath(__file__)), filename) + +def upload_file(service, filename, mime_type, folder_id): + try: + file_metadata = { + 'name': filename, + 'parents': [folder_id], + 'mimeType': mime_type + } + + media = MediaFileUpload(get_file_in_path(filename), mimetype=mime_type, resumable=True) -@app.route("/") -def home(): - code = request.args.get('code') - flow = InstalledAppFlow.from_client_secrets_file( - os.path.join(os.path.dirname(__file__), 'credentials.json'), SCOPES, redirect_uri='/api/v1/backup-database') - flow.fetch_token(code=code, include_client_id=True) - return code + file = service.files().create( + body=file_metadata, + media_body=media, + fields='id' + ).execute() + except HttpError as error: + print(f'An error occurred: {error}') + file = None + + return file.get('id') @app.route("/backup-database") def backup_database(): from sh import pg_dump - print(os.path.join(os.path.dirname(__file__)), file=sys.stderr) - print(os.path.join(os.path.dirname(__file__), - 'credentials.json'), file=sys.stderr) - print('Realizando backup do banco de dados...', file=sys.stderr) pg_dump('--host', DATABASE_HOST, '--port', '5432', '-U', DATABASE_USER, '-w', '--format', 'custom', '--blobs', '--encoding', - 'UTF8', '--no-privileges', '--no-tablespaces', '--no-unlogged-table-data', '--file', f'/home/{filename}', DATABASE_NAME) + 'UTF8', '--no-privileges', '--no-tablespaces', '--no-unlogged-table-data', '--file', f'/home/{FILENAME}', DATABASE_NAME) - # Google Drive service + + # upload de arquivo + print('Autenticando no Google...', file=sys.stderr) service = build('drive', 'v3', credentials=get_google_credentials()) - print("Folder ID:", google_drive_folder_id) - # upload a file text file - # first, define file metadata, such as the name and the parent folder ID - file_metadata = { - "name": filename, - "parents": [google_drive_folder_id] - } - - # upload - media = MediaFileUpload(f'/home/{filename}', resumable=True) - file = service.files().create(body=file_metadata, - media_body=media, fields='id').execute() - print("File created, id:", file.get("id")) - - return None + print('Realizando upload para Google Drive...', file=sys.stderr) + file_id = upload_file(service=service, filename=FILENAME, mime_type='application/octet-stream', folder_id=GOOGLE_DRIVE_FOLDER_ID) + print('File uploaded:', file_id) + + # Google Drive API: https://developers.google.com/drive/api/v3/reference + print('Listando arquivos na pasta de backup...', file=sys.stderr) + # fields props: https://developers.google.com/drive/api/v3/reference/files + # query props: https://developers.google.com/drive/api/guides/search-files#python + results = service.files().list(q=f'"{GOOGLE_DRIVE_FOLDER_ID}" in parents and trashed = false', orderBy='createdTime desc', + pageSize=20, fields="nextPageToken, files(id, name, mimeType, description, trashed)").execute() + items = results.get('files', []) + + if not items: + print('No files found.', file=sys.stderr) + return + else: + for item in items: + print('{:<40} {:<20} {:<20}'.format(item['name'], item['mimeType'], item['trashed']), file=sys.stderr) + + print('Excluindo arquivos antigos...', file=sys.stderr) + for item in items: + filename_datetime = item['name'].replace(FILE_EXTENSION, '') + try: + print(datetime.now()) + print(BACKUP_EXPIRATION_TIME) + if datetime.strptime(filename_datetime, '%Y_%m_%d_%H_%M_%S') < BACKUP_EXPIRATION_TIME: + filename = f'{filename_datetime}{FILE_EXTENSION}' + print(f'Excluindo {filename}', file=sys.stderr) + os.remove(get_file_in_path(filename)) + service.files().delete(fileId=item['id']).execute() + except Exception as e: + print('error', e) + + return Response('Backup realizado', status=201) if __name__ == '__main__': get_google_credentials() diff --git a/cron/app/env.py b/cron/app/env.py new file mode 100644 index 0000000..4b15cf6 --- /dev/null +++ b/cron/app/env.py @@ -0,0 +1,13 @@ +from datetime import datetime, timedelta +import os + +DATABASE_HOST = os.getenv('POSTGRES_HOST', 'psql') +DATABASE_NAME = os.getenv('POSTGRES_DB', 'esus') +DATABASE_USER = os.getenv('POSTGRES_USER', 'postgres') + +NOW = datetime.now() +FILE_EXTENSION = '.backup' +FILENAME = f'{NOW.strftime("%Y_%m_%d_%H_%M_%S")}{FILE_EXTENSION}' + +GOOGLE_DRIVE_FOLDER_ID = os.getenv('GOOGLE_DRIVE_FOLDER_ID', '1osoeAhww2IM2V2W_xbgcRoROHEk_DAPw') +BACKUP_EXPIRATION_TIME = datetime.now() - timedelta(days=7) \ No newline at end of file diff --git a/cron/app/googleoauth.py b/cron/app/googleoauth.py new file mode 100644 index 0000000..8b47759 --- /dev/null +++ b/cron/app/googleoauth.py @@ -0,0 +1,43 @@ +from __future__ import print_function + +import os.path + +from google.auth.transport.requests import Request +from google.oauth2.credentials import Credentials +from google_auth_oauthlib.flow import InstalledAppFlow + +# If modifying these scopes, delete the file token.json. +SCOPES = [ + 'https://www.googleapis.com/auth/drive.appdata', + 'https://www.googleapis.com/auth/drive.file', + 'https://www.googleapis.com/auth/drive.install', + 'https://www.googleapis.com/auth/drive', + 'https://www.googleapis.com/auth/drive.metadata.readonly' + ] + +CREDEDNTIALS = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'credentials.json') +TOKEN = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'token.json') + +def get_google_credentials(): + creds = None + # The file token.json stores the user's access and refresh tokens, and is + # created automatically when the authorization flow completes for the first + # time. + if os.path.exists(TOKEN): + creds = Credentials.from_authorized_user_file(TOKEN, SCOPES) + # If there are no (valid) credentials available, let the user log in. + if not creds or not creds.valid: + if creds and creds.expired and creds.refresh_token: + creds.refresh(Request()) + else: + flow = InstalledAppFlow.from_client_secrets_file(CREDEDNTIALS, SCOPES) + creds = flow.run_local_server(host='localhost', port=8080, open_browser=False) + # Save the credentials for the next run + with open(TOKEN, 'w') as token: + token.write(creds.to_json()) + + return creds + + +if __name__ == '__main__': + get_google_credentials() \ No newline at end of file diff --git a/cron/app/quickstart.py b/cron/app/quickstart.py deleted file mode 100644 index af4b58c..0000000 --- a/cron/app/quickstart.py +++ /dev/null @@ -1,59 +0,0 @@ -from __future__ import print_function - -import os.path - -from google.auth.transport.requests import Request -from google.oauth2.credentials import Credentials -from google_auth_oauthlib.flow import InstalledAppFlow -from googleapiclient.discovery import build -from googleapiclient.errors import HttpError - -# If modifying these scopes, delete the file token.json. -SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly'] - -CRON_PORT = int(os.getenv('CRON_PORT', 89)) - - -def main(): - """Shows basic usage of the Drive v3 API. - Prints the names and ids of the first 10 files the user has access to. - """ - creds = None - # The file token.json stores the user's access and refresh tokens, and is - # created automatically when the authorization flow completes for the first - # time. - if os.path.exists('token.json'): - creds = Credentials.from_authorized_user_file('token.json', SCOPES) - # If there are no (valid) credentials available, let the user log in. - if not creds or not creds.valid: - if creds and creds.expired and creds.refresh_token: - creds.refresh(Request()) - else: - flow = InstalledAppFlow.from_client_secrets_file( - os.path.join(os.path.dirname(__file__), 'credentials.json'), SCOPES, redirect_uri='https://filipelopes.me') - creds = flow.run_local_server(host='localhost', port=CRON_PORT, open_browser=True) - # Save the credentials for the next run - with open('token.json', 'w') as token: - token.write(creds.to_json()) - - try: - service = build('drive', 'v3', credentials=creds) - - # Call the Drive v3 API - results = service.files().list( - pageSize=10, fields="nextPageToken, files(id, name)").execute() - items = results.get('files', []) - - if not items: - print('No files found.') - return - print('Files:') - for item in items: - print(u'{0} ({1})'.format(item['name'], item['id'])) - except HttpError as error: - # TODO(developer) - Handle errors from drive API. - print(f'An error occurred: {error}') - - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/cron/script.sh b/cron/script.sh index cf64061..3584e37 100644 --- a/cron/script.sh +++ b/cron/script.sh @@ -1,5 +1,5 @@ #!/bin/sh # code goes here. -wget http://localhost:5000/backup-database +curl http://localhost:5000/backup-database echo "This is a script, run by cron!" diff --git a/docker-compose.yml b/docker-compose.yml index 5637380..90f8839 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -39,6 +39,8 @@ services: build: context: cron dockerfile: Dockerfile + args: + - TIMEZONE=${TIMEZONE} volumes: - ./cron/crontab.txt:/crontab.txt - ./cron/app:/home @@ -46,8 +48,5 @@ services: - POSTGRES_DB=${POSTGRES_DB} - POSTGRES_USER=${POSTGRES_USER} - PGPASSWORD=${POSTGRES_PASSWORD} - - CRON_PORT=${CRON_PORT} - ports: - - "${CRON_PORT}:5000" depends_on: - psql From 5a5166a3e3ebcad23e41a3f26f4bef26a5d6cbf3 Mon Sep 17 00:00:00 2001 From: Filipe Lopes Date: Fri, 11 Nov 2022 15:36:40 -0300 Subject: [PATCH 4/6] docs(readme): update readme backup docs --- Makefile | 2 +- README.md | 14 +++- h | 242 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 255 insertions(+), 3 deletions(-) create mode 100644 h diff --git a/Makefile b/Makefile index 60590de..1c5cc44 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ terminal: docker exec -it esus_app bash db-terminal: docker exec -it esus_psql bash -backup-test: +cloud-backup: docker exec -it esus_cron sh -c "curl localhost:5000/backup-database" google-oauth: cd cron/app; \ diff --git a/README.md b/README.md index 97a3eeb..1e0902a 100644 --- a/README.md +++ b/README.md @@ -97,9 +97,19 @@ sh build.sh -f eSUS-AB-PEC-5.0.14-Linux64.jar ## Serviço de backup -Para fazer funcionar o serviço de backup na nuvem ela deve estar relacionada a um Google Drive, se assim não for irá armazenar os backups apenas localmente. Para o uso de backup na nuvem é necessário: +Para fazer funcionar o serviço de backup na nuvem pelo [Google Drive](https://developers.google.com/drive/api/v3/reference) ela deve estar relacionada a um Google Drive, se assim não for irá armazenar os backups apenas localmente. Para o uso de backup na nuvem é necessário: 1. [Criar uma chave de Client ID Google](https://developers.google.com/drive/api/quickstart/python) 2. Salve o arquivo json baixado com segurança e cole na pasta como `cron/app/credentials.json` -3. Execute `make google-oauth` para iniciar autenticação Google e permitir acessos. É necessário para criar o `token.json` que guardará as credenciais. Caso o comando não funcione, provavelmente você não está no linux ou não tem o `python3` instalado no seu linux. **É importante que ao executar o comando você esteja dentro da pasta raiz do projeto. +3. Execute +```sh +make google-oauth +``` +Para iniciar autenticação Google e permitir acessos. É necessário para criar o `token.json` que guardará as credenciais. Caso o comando não funcione, provavelmente você não está no linux ou não tem o `python3` instalado no seu linux. **É importante que ao executar o comando você esteja dentro da pasta raiz do projeto.** + +Para realizar um teste de backup execute: +``` +make cloud-backup +``` +As configurações de tempo de expiração de backup estão disponíveis em `env.py` \ No newline at end of file diff --git a/h b/h new file mode 100644 index 0000000..e5b74df --- /dev/null +++ b/h @@ -0,0 +1,242 @@ +commit 926068dc5887bfe265c34c25d9064bd868d50def (HEAD -> feature/drive-backup) +Author: Filipe Lopes +Date: Fri Nov 11 15:32:27 2022 -0300 + + feat(db-backup): backup database, update and delete old one through Google Drive API + +commit fca67052537203a7396418f9cc4dc080cef7203d (origin/feature/drive-backup) +Author: Filipe Lopes +Date: Fri Nov 4 06:29:04 2022 -0300 + + feat: update google-auth flow + +commit 1186196343fd223a04340e8822f2d4a933a4a4b1 +Author: Filipe Lopes +Date: Sun Oct 30 11:12:26 2022 -0300 + + feat: add folders and files. Cron is running + +commit 2aedc72974ad253a171e951ba9eb25a31eea4bc2 (origin/develop) +Merge: dbf83ff 70d5d15 +Author: filiperochalopes <34348097+filiperochalopes@users.noreply.github.com> +Date: Thu Oct 27 09:52:34 2022 -0300 + + Merge pull request #3 from filiperochalopes/feature/simplify-dev-version + + Simplificando ambiente de produção + +commit 70d5d15e3d1f0bd88da7f6ff98471cd4d8711807 (origin/feature/simplify-dev-version, feature/simplify-dev-version) +Author: Filipe Lopes +Date: Thu Oct 27 09:51:30 2022 -0300 + + build: dev env ready through makefile commands + +commit 20c0b172218015f0959abbc1a42c2c02bcbc892f +Author: Filipe Lopes +Date: Thu Oct 27 09:08:44 2022 -0300 + + build: simplifying folder structure and update timezone + + adds timezone to dotenv file. remove unused folders and apps because it was transfered to another project + + Related to #1 and #2 + +commit dbf83ffc246371bfba15ab3a7d6aaad2e8c51e08 (develop) +Author: Filipe Lopes +Date: Fri Sep 9 13:56:37 2022 -0300 + + build: add api app nginx proxy + +commit 7014c4e0333dfc634f82be22f2b4b64ea8827612 +Author: Filipe Lopes +Date: Thu Sep 8 17:24:51 2022 -0300 + + fix: code from cid10 fixture + +commit 1efebd6b4d4896bec7e026b5286e46dadea42a44 +Author: Filipe Lopes +Date: Wed Jul 6 00:30:07 2022 -0300 + + add more fixtures + +commit 00a3397d5a8fee497c1f89e39d6372edd8efd7cd +Author: Filipe Lopes +Date: Tue Jul 5 23:42:37 2022 -0300 + + update medicamento relationship and its fixture + +commit df1a2ecdf1e09b2b1addfb002f9c3018edf69a6f +Author: Filipe Lopes +Date: Tue Jul 5 08:03:56 2022 -0300 + + update readme + +commit 20e4e238a6ee570c8eff792f74d59462c55ed9e6 +Author: Filipe Lopes +Date: Tue Jul 5 06:57:30 2022 -0300 + + add more fixtures + +commit 6b69d1d48845b4e74be3e294b4da827987330694 +Author: Filipe Lopes +Date: Sun Jul 3 03:59:52 2022 -0300 + + add know issue to readme + +commit 840e6977496626c8d8c3ce6682cd15325554fd1a +Author: Filipe Lopes +Date: Sat Jul 2 19:57:00 2022 -0300 + + change some prod settings + +commit 945ad1f2b976aef07211fd415b0fb55640cf8083 +Author: Filipe Lopes +Date: Sat Jul 2 19:25:52 2022 -0300 + + add prod docker-compose file + +commit 7666ad06fe1234209b05317e3173efa827f0e4f6 +Author: Filipe Lopes +Date: Sat Jul 2 18:57:32 2022 -0300 + + add prod docker-compose + +commit a3f7e8197ffbd9e944e16362de92b53904a58674 +Author: Filipe Lopes +Date: Fri Jul 1 14:36:36 2022 -0300 + + change playground route and dashboard basename + +commit 19bc50728f1b8a4d50892a16dc98159af98960be +Author: Filipe Lopes +Date: Thu Jun 30 08:24:16 2022 -0300 + + update packages and folder structure + +commit c9b1def9897180f268a919dcf39083f31e21341f +Author: Filipe Lopes +Date: Fri Jun 17 17:24:10 2022 -0300 + + add first page to site + +commit 8dede2b01ff3f654c0360c3ddb3e36b6ad386253 +Author: Filipe Lopes +Date: Fri Jun 17 07:23:34 2022 -0300 + + add fixtures and string of medical prescriptions to fill database and training IA + +commit ca6595d59f28ff53a497a38392238962a281eb4e +Author: Filipe Lopes +Date: Wed Jun 8 19:48:17 2022 -0300 + + started with generating Receita list with related models + +commit 69a611fc0d057fae9274d63810a35d58afa96855 +Author: Filipe Lopes +Date: Wed Jun 8 11:04:14 2022 -0300 + + delete pycache folders + +commit 23be1b2ab63093d504ccd825084c5122231fb4d2 +Author: Filipe Lopes +Date: Sun Jun 5 03:47:56 2022 -0300 + + updating readme to the next 4.5.5 release + +commit 804d6bb20233789f079079075d0a7267b879ecf9 +Author: Filipe Lopes +Date: Wed Jun 1 23:32:43 2022 -0300 + + update readme + +commit 11b106acfd18b34fb3c1629c6c08328e705514e6 +Author: Filipe Lopes +Date: Sat Apr 23 20:43:55 2022 -0300 + + update docs + +commit 2c5e62d9ad006c7d4d5db7170ddf5956dce6ada8 +Author: Filipe Lopes +Date: Sun Apr 17 04:11:40 2022 -0300 + + update build flow to migrate pec version + +commit 7b9f02110580361c1d96ffed5d94adafba07bcf3 +Author: Filipe Lopes +Date: Sun Apr 10 03:31:46 2022 -0300 + + change manage folder structure and add functional fixture route + +commit f71216e23873019a22c5405d9b5df32ca9137712 +Author: Filipe Lopes +Date: Wed Apr 6 23:46:17 2022 -0300 + + rename manage app + +commit 168defb2e8e9d08dc30858334113d8397411ba35 +Merge: b0eb864 a050790 +Author: Filipe Lopes +Date: Wed Mar 30 18:28:59 2022 -0300 + + solve merge conflict + +commit a050790b71f0a7edfba4b167011ee29f918fd0c4 (main) +Author: Filipe Lopes +Date: Wed Mar 30 18:26:11 2022 -0300 + + add backup and restore script to readme + +commit b0eb8646cecb0a357478bdb6310237022e278f34 +Author: Filipe Lopes +Date: Sat Feb 19 00:59:07 2022 -0300 + + add managedb app + +commit efc1a2ddca66ef8477e1182e5d8dfa4bd47f0b5b +Merge: 38ff672 3e73309 +Author: Filipe Lopes +Date: Fri Feb 18 13:05:59 2022 -0300 + + Merge branch 'main' of github.com:filiperochalopes/e-SUS-PEC into main + +commit 38ff672e5bb59a712bee24bda9894276f3f66fa8 +Author: Filipe Lopes +Date: Fri Feb 18 13:05:15 2022 -0300 + + define postgres image version because of compatibility + +commit 3e73309c099224b7149d30deb6c1545d66840316 +Author: Filipe Lopes +Date: Sat Nov 20 00:06:44 2021 -0300 + + define postgres image version based on initial dataset + +commit 512423543ebdc99114b8e5040c1fffbc978e06cb +Author: Filipe Lopes +Date: Wed Nov 17 23:06:33 2021 -0300 + + change startup command + +commit c4dfe288f6c7d73ef3596b9b4de78f997c2c74a4 +Author: Filipe Lopes +Date: Mon Aug 30 20:10:18 2021 -0300 + + Update README.md + +commit 0bf6726449cda12538c9ab096f27931cc2f0be27 +Author: Filipe Lopes +Date: Sat Aug 28 00:21:38 2021 -0300 + + update Dockerfile pkg dependencies + +commit 5282814466ed3ae7c2eb88e1ba52302582bb3a84 +Author: Filipe Lopes +Date: Fri Aug 27 22:53:38 2021 -0300 + + remove upstart conf file from Dockerfile cause Im using nohup from now on + +commit 978d32ff32d114286cdc4ce7f98b835efb670c43 +Author: Filipe Lopes +Date: Fri Aug 27 22:37:13 2021 -0300 + + Initial commit From ec227530a06a48aeed600a44fad40f04d858354d Mon Sep 17 00:00:00 2001 From: Filipe Lopes Date: Fri, 11 Nov 2022 16:12:07 -0300 Subject: [PATCH 5/6] refactor(cron): change default schedule to midnight --- cron/crontab.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cron/crontab.txt b/cron/crontab.txt index e41852f..b67519f 100644 --- a/cron/crontab.txt +++ b/cron/crontab.txt @@ -1,3 +1,3 @@ # m h dom mon dow user command -0 * * * * /script.sh >> /var/log/script.log +* 0 * * * /script.sh >> /var/log/script.log \ No newline at end of file From b1b4754bde399818c88d88920a6a4a3514f97706 Mon Sep 17 00:00:00 2001 From: Filipe Lopes Date: Tue, 22 Nov 2022 18:17:21 -0300 Subject: [PATCH 6/6] refactor: remove unused files --- h | 242 -------------------------------------------------------------- 1 file changed, 242 deletions(-) delete mode 100644 h diff --git a/h b/h deleted file mode 100644 index e5b74df..0000000 --- a/h +++ /dev/null @@ -1,242 +0,0 @@ -commit 926068dc5887bfe265c34c25d9064bd868d50def (HEAD -> feature/drive-backup) -Author: Filipe Lopes -Date: Fri Nov 11 15:32:27 2022 -0300 - - feat(db-backup): backup database, update and delete old one through Google Drive API - -commit fca67052537203a7396418f9cc4dc080cef7203d (origin/feature/drive-backup) -Author: Filipe Lopes -Date: Fri Nov 4 06:29:04 2022 -0300 - - feat: update google-auth flow - -commit 1186196343fd223a04340e8822f2d4a933a4a4b1 -Author: Filipe Lopes -Date: Sun Oct 30 11:12:26 2022 -0300 - - feat: add folders and files. Cron is running - -commit 2aedc72974ad253a171e951ba9eb25a31eea4bc2 (origin/develop) -Merge: dbf83ff 70d5d15 -Author: filiperochalopes <34348097+filiperochalopes@users.noreply.github.com> -Date: Thu Oct 27 09:52:34 2022 -0300 - - Merge pull request #3 from filiperochalopes/feature/simplify-dev-version - - Simplificando ambiente de produção - -commit 70d5d15e3d1f0bd88da7f6ff98471cd4d8711807 (origin/feature/simplify-dev-version, feature/simplify-dev-version) -Author: Filipe Lopes -Date: Thu Oct 27 09:51:30 2022 -0300 - - build: dev env ready through makefile commands - -commit 20c0b172218015f0959abbc1a42c2c02bcbc892f -Author: Filipe Lopes -Date: Thu Oct 27 09:08:44 2022 -0300 - - build: simplifying folder structure and update timezone - - adds timezone to dotenv file. remove unused folders and apps because it was transfered to another project - - Related to #1 and #2 - -commit dbf83ffc246371bfba15ab3a7d6aaad2e8c51e08 (develop) -Author: Filipe Lopes -Date: Fri Sep 9 13:56:37 2022 -0300 - - build: add api app nginx proxy - -commit 7014c4e0333dfc634f82be22f2b4b64ea8827612 -Author: Filipe Lopes -Date: Thu Sep 8 17:24:51 2022 -0300 - - fix: code from cid10 fixture - -commit 1efebd6b4d4896bec7e026b5286e46dadea42a44 -Author: Filipe Lopes -Date: Wed Jul 6 00:30:07 2022 -0300 - - add more fixtures - -commit 00a3397d5a8fee497c1f89e39d6372edd8efd7cd -Author: Filipe Lopes -Date: Tue Jul 5 23:42:37 2022 -0300 - - update medicamento relationship and its fixture - -commit df1a2ecdf1e09b2b1addfb002f9c3018edf69a6f -Author: Filipe Lopes -Date: Tue Jul 5 08:03:56 2022 -0300 - - update readme - -commit 20e4e238a6ee570c8eff792f74d59462c55ed9e6 -Author: Filipe Lopes -Date: Tue Jul 5 06:57:30 2022 -0300 - - add more fixtures - -commit 6b69d1d48845b4e74be3e294b4da827987330694 -Author: Filipe Lopes -Date: Sun Jul 3 03:59:52 2022 -0300 - - add know issue to readme - -commit 840e6977496626c8d8c3ce6682cd15325554fd1a -Author: Filipe Lopes -Date: Sat Jul 2 19:57:00 2022 -0300 - - change some prod settings - -commit 945ad1f2b976aef07211fd415b0fb55640cf8083 -Author: Filipe Lopes -Date: Sat Jul 2 19:25:52 2022 -0300 - - add prod docker-compose file - -commit 7666ad06fe1234209b05317e3173efa827f0e4f6 -Author: Filipe Lopes -Date: Sat Jul 2 18:57:32 2022 -0300 - - add prod docker-compose - -commit a3f7e8197ffbd9e944e16362de92b53904a58674 -Author: Filipe Lopes -Date: Fri Jul 1 14:36:36 2022 -0300 - - change playground route and dashboard basename - -commit 19bc50728f1b8a4d50892a16dc98159af98960be -Author: Filipe Lopes -Date: Thu Jun 30 08:24:16 2022 -0300 - - update packages and folder structure - -commit c9b1def9897180f268a919dcf39083f31e21341f -Author: Filipe Lopes -Date: Fri Jun 17 17:24:10 2022 -0300 - - add first page to site - -commit 8dede2b01ff3f654c0360c3ddb3e36b6ad386253 -Author: Filipe Lopes -Date: Fri Jun 17 07:23:34 2022 -0300 - - add fixtures and string of medical prescriptions to fill database and training IA - -commit ca6595d59f28ff53a497a38392238962a281eb4e -Author: Filipe Lopes -Date: Wed Jun 8 19:48:17 2022 -0300 - - started with generating Receita list with related models - -commit 69a611fc0d057fae9274d63810a35d58afa96855 -Author: Filipe Lopes -Date: Wed Jun 8 11:04:14 2022 -0300 - - delete pycache folders - -commit 23be1b2ab63093d504ccd825084c5122231fb4d2 -Author: Filipe Lopes -Date: Sun Jun 5 03:47:56 2022 -0300 - - updating readme to the next 4.5.5 release - -commit 804d6bb20233789f079079075d0a7267b879ecf9 -Author: Filipe Lopes -Date: Wed Jun 1 23:32:43 2022 -0300 - - update readme - -commit 11b106acfd18b34fb3c1629c6c08328e705514e6 -Author: Filipe Lopes -Date: Sat Apr 23 20:43:55 2022 -0300 - - update docs - -commit 2c5e62d9ad006c7d4d5db7170ddf5956dce6ada8 -Author: Filipe Lopes -Date: Sun Apr 17 04:11:40 2022 -0300 - - update build flow to migrate pec version - -commit 7b9f02110580361c1d96ffed5d94adafba07bcf3 -Author: Filipe Lopes -Date: Sun Apr 10 03:31:46 2022 -0300 - - change manage folder structure and add functional fixture route - -commit f71216e23873019a22c5405d9b5df32ca9137712 -Author: Filipe Lopes -Date: Wed Apr 6 23:46:17 2022 -0300 - - rename manage app - -commit 168defb2e8e9d08dc30858334113d8397411ba35 -Merge: b0eb864 a050790 -Author: Filipe Lopes -Date: Wed Mar 30 18:28:59 2022 -0300 - - solve merge conflict - -commit a050790b71f0a7edfba4b167011ee29f918fd0c4 (main) -Author: Filipe Lopes -Date: Wed Mar 30 18:26:11 2022 -0300 - - add backup and restore script to readme - -commit b0eb8646cecb0a357478bdb6310237022e278f34 -Author: Filipe Lopes -Date: Sat Feb 19 00:59:07 2022 -0300 - - add managedb app - -commit efc1a2ddca66ef8477e1182e5d8dfa4bd47f0b5b -Merge: 38ff672 3e73309 -Author: Filipe Lopes -Date: Fri Feb 18 13:05:59 2022 -0300 - - Merge branch 'main' of github.com:filiperochalopes/e-SUS-PEC into main - -commit 38ff672e5bb59a712bee24bda9894276f3f66fa8 -Author: Filipe Lopes -Date: Fri Feb 18 13:05:15 2022 -0300 - - define postgres image version because of compatibility - -commit 3e73309c099224b7149d30deb6c1545d66840316 -Author: Filipe Lopes -Date: Sat Nov 20 00:06:44 2021 -0300 - - define postgres image version based on initial dataset - -commit 512423543ebdc99114b8e5040c1fffbc978e06cb -Author: Filipe Lopes -Date: Wed Nov 17 23:06:33 2021 -0300 - - change startup command - -commit c4dfe288f6c7d73ef3596b9b4de78f997c2c74a4 -Author: Filipe Lopes -Date: Mon Aug 30 20:10:18 2021 -0300 - - Update README.md - -commit 0bf6726449cda12538c9ab096f27931cc2f0be27 -Author: Filipe Lopes -Date: Sat Aug 28 00:21:38 2021 -0300 - - update Dockerfile pkg dependencies - -commit 5282814466ed3ae7c2eb88e1ba52302582bb3a84 -Author: Filipe Lopes -Date: Fri Aug 27 22:53:38 2021 -0300 - - remove upstart conf file from Dockerfile cause Im using nohup from now on - -commit 978d32ff32d114286cdc4ce7f98b835efb670c43 -Author: Filipe Lopes -Date: Fri Aug 27 22:37:13 2021 -0300 - - Initial commit