Skip to content

Commit

Permalink
Test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ldamasio committed Aug 20, 2023
1 parent ab6c9b4 commit bf65ef8
Show file tree
Hide file tree
Showing 15 changed files with 198 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
**/.env
**/node_modules/
**/__pycache__
**/venv
**/.venv

# Logs
logs
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ The command interface makes it possible to activate a Dashboard with its main in

## The Dashboard offers special string conversion calculators.

For example, if you need to withdraw an amount of BRL, but would like to convert your USDT to ADA before transferring, in addition to needing to anticipate spread values from other financial services.
For example, if you need to withdraw an amount of BRL, but would like to convert your USDT to ADA before transferring, in addition to needing to anticipate spread values from other financial services.

## Development Environment

In wsgi.py and manage.py "backend.settings" was changed to "backend.settings.development"

1 change: 1 addition & 0 deletions backends/monolith/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.venv
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

BASE_DIR = Path(__file__).resolve().parent.parent

SECRET_KEY = 'django-insecure-2mmpn-2t!ik^g__ixmq3jt0gbel26-faatssu2&9$4m)(xe77^'
SECRET_KEY = config("SECRET_KEY")

DEBUG = True

Expand Down Expand Up @@ -59,17 +59,16 @@

WSGI_APPLICATION = 'backend.wsgi.application'


# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'rbs',
'USER': 'ldamasio',
'PASSWORD': 'admin',
'HOST': 'leandrodamasio.com.br',
'PORT': 5432,
'NAME': config("PG_DATABASE"),
'USER': config("PG_USER"),
'PASSWORD': config("PG_PASSWORD"),
'HOST': config("PG_HOST"),
'PORT': config("PG_PORT"),
}
}

Expand All @@ -90,7 +89,6 @@
},
]


# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/

Expand All @@ -102,7 +100,6 @@

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/

Expand Down
1 change: 1 addition & 0 deletions backends/monolith/backend/settings/development.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from backend.settings.common import *
3 changes: 3 additions & 0 deletions backends/monolith/backend/settings/production.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from backend.settings.common import *

DEBUG = False
2 changes: 1 addition & 1 deletion backends/monolith/backend/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings.development')

application = get_wsgi_application()
2 changes: 1 addition & 1 deletion backends/monolith/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings.development')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand Down
91 changes: 91 additions & 0 deletions backends/monolith/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
aiohttp==3.8.3
aiosignal==1.2.0
asgiref==3.5.2
async-timeout==4.0.2
attrs==19.3.0
Automat==0.8.0
blinker==1.4
certifi==2019.11.28
cffi==1.15.1
chardet==3.0.4
charset-normalizer==2.1.1
Click==7.0
colorama==0.4.3
configobj==5.0.6
constantly==15.1.0
cryptography==2.8
dateparser==1.1.1
distro==1.4.0
Django==4.1.10
django-cors-headers==4.2.0
django-multitenant==3.2.1
djangorestframework==3.14.0
djangorestframework-jwt==1.11.0
djangorestframework-simplejwt==5.2.2
entrypoints==0.3
frozenlist==1.3.1
gevent==22.10.1
greenlet==1.1.3
gunicorn==20.1.0
httplib2==0.14.0
hyperlink==19.0.0
idna==2.8
importlib-metadata==1.5.0
incremental==16.10.1
Jinja2==2.10.1
jsonpatch==1.22
jsonpointer==2.0
jsonschema==3.2.0
keyring==18.0.1
launchpadlib==1.11.0
lazr.restfulclient==0.14.2
lazr.uri==1.0.3
MarkupSafe==1.1.0
more-itertools==4.2.0
multidict==6.0.2
netifaces==0.10.4
numpy==1.23.3
oauthlib==3.1.0
pandas==1.5.0
pbr==5.10.0
pexpect==4.6.0
psycopg2-binary==2.9.7
ptyprocess==0.7.0
pyasn1==0.4.2
pyasn1-modules==0.2.1
pycparser==2.21
PyHamcrest==1.9.0
pyinotify==0.9.6
PyJWT==1.7.1
pymacaroons==0.13.0
PyNaCl==1.3.0
pyOpenSSL==19.0.0
pyrsistent==0.15.5
pyserial==3.4
python-binance==1.0.16
python-dateutil==2.8.2
python-decouple==3.6
pytz==2022.4
pytz-deprecation-shim==0.1.0.post0
PyYAML==5.3.1
regex==2022.3.2
requests==2.22.0
requests-unixsocket==0.2.0
SecretStorage==2.3.1
service-identity==18.1.0
simplejson==3.16.0
six==1.14.0
sqlparse==0.4.2
ssh-import-id==5.10
testresources==2.0.1
Twisted==21.2.0
tzdata==2022.4
tzlocal==4.2
ujson==5.5.0
urllib3==1.25.8
wadllib==1.3.3
websockets==10.3
yarl==1.8.1
zipp==1.0.0
zope.event==4.5.0
zope.interface==5.4.0
14 changes: 9 additions & 5 deletions backends/monolith/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ dateparser==1.1.1
distro==1.4.0
django
django-cors-headers
djangorestframework
djangorestframework-jwt
djangorestframework-simplejwt
django-multitenant
entrypoints==0.3
frozenlist==1.3.1
gevent==21.12.0
greenlet==1.1.2
gevent
greenlet==1.1.3
gunicorn==20.1.0
httplib2==0.14.0
hyperlink==19.0.0
Expand All @@ -33,7 +37,7 @@ jsonpatch==1.22
jsonpointer==2.0
jsonschema==3.2.0
keyring==18.0.1
launchpadlib==1.10.13
launchpadlib
lazr.restfulclient==0.14.2
lazr.uri==1.0.3
MarkupSafe==1.1.0
Expand All @@ -45,7 +49,7 @@ oauthlib==3.1.0
pandas==1.5.0
pbr==5.10.0
pexpect==4.6.0
psycopg2-binary==2.9.4
psycopg2-binary
ptyprocess==0.7.0
pyasn1==0.4.2
pyasn1-modules==0.2.1
Expand Down Expand Up @@ -74,7 +78,7 @@ six==1.14.0
sqlparse==0.4.2
ssh-import-id==5.10
testresources==2.0.1
Twisted==18.9.0
Twisted
tzdata==2022.4
tzlocal==4.2
ujson==5.5.0
Expand Down
42 changes: 34 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,58 @@
version: "3"
services:
robsondb:
container_name: robsonDatabase
image: citusdata/citus
environment:
POSTGRES_USER: 'postgres'
POSTGRES_PASSWORD: 'mypass'
POSTGRES_DB: 'postgres'
# volumes:
# - pgdata:${PG_DATA}
ports:
- 5450:5432
restart: always

# cronjob:
# container_name: dump
# build: ./dump
# environment:
# PG_HOST: ${PG_HOST}
# POSTGRES_USER: ${PG_USER}
# POSTGRES_PASSWORD: ${PG_PASSWORD}
# POSTGRES_DB: ${PG_DATABASE}
# PGDATA: ${PG_DATA}
# PGPORT: ${PG_PORT}
# restart: always

backend-monolith:
container_name: RbsBackendMonolith
container_name: backendMonolith
image: backend-monolith
build: ./backends/monolith
volumes:
- ./backends/monolith:/app-backend
restart: always

frontend-web:
container_name: RbsFrontendWeb
container_name: frontendWeb
image: frontend-web
build: ./frontends/web
ports:
- 3403:3403
volumes:
- ./frontends/web:/app-frontend
ports:
- 3403:3403
depends_on:
- backend-monolith
restart: always

nginx_backend_server:
container_name: rbs_nginx_backend_server
image: rbs_nginx_backend_server_img
depends_on:
- backend-monolith
container_name: nginxMonolith
build: ./backends/nginx_monolith
ports:
- 8403:8403
depends_on:
- backend-monolith
restart: always

volumes:
pgdata:
10 changes: 10 additions & 0 deletions dump/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM ubuntu:latest
RUN apt-get update; apt-get install -y postgresql-client python3 python3-pip
WORKDIR /app
ENV TZ=America/Sao_Paulo
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN pip3 install rocketry
COPY ./rocketry/main.py /app/rocketry/main.py
COPY ./rocketry/dump.sh /app/rocketry/dump.sh
COPY ./rocketry/backup.sh /app/rocketry/backup.sh
CMD ["python3", "/app/rocketry/main.py"]
Empty file added dump/rocketry/backup.sh
Empty file.
3 changes: 3 additions & 0 deletions dump/rocketry/dump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
filepath=/app/$(date +%F_%H-%M-%S).sql
pg_dump -Fc --host=$PG_HOST --port=$PG_PORT --username=$PG_USER --password=$PG_PASSWORD --dbname=$PG_DBNAME -f filename
cp $filepath /app/pg-dump.sql
30 changes: 30 additions & 0 deletions dump/rocketry/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from rocketry import Rocketry
from rocketry.conds import after_success, after_fail, after_finish
from rocketry.log import MinimalRecord
from redbird.repos import CSVFileRepo
import subprocess

repo = CSVFileRepo(filename="tasks.csv", model=MinimalRecord)

app = Rocketry(logger_repo=repo)

@app.task('daily')
def job():
print ("Running a cronjob...")
subprocess.call(['sh', '/app/rocketry/dump.sh'])
return(True)

@app.task(after_success(job))
def do_after_success():
print ("Trying to backup...")
subprocess.call(['sh', '/app/rocketry/backup.sh'])

@app.task(after_fail(job))
def do_after_fail():
print(False)

@app.task(after_finish(job))
def do_after_fail_or_success():
print ("Backup done")

app.run()

0 comments on commit bf65ef8

Please sign in to comment.