remove liara.json & workflow/liara.yaml - add Dockerfile & docker-compose file
This commit is contained in:
15
.env.dev
Normal file
15
.env.dev
Normal file
@@ -0,0 +1,15 @@
|
||||
# Django secrets
|
||||
SECRET_KEY=super-insecure-django-key
|
||||
DEBUG=True
|
||||
ALLOWED_HOSTS=*
|
||||
ENV_NAME=DEV
|
||||
|
||||
# Datbase secrets
|
||||
DB_HOST=localhost
|
||||
DB_PORT=5432
|
||||
DB_NAME=example_db
|
||||
DB_USERNAME=postgres
|
||||
DB_PASSWORD=12345678
|
||||
|
||||
# Super user information
|
||||
SUPERUSER_EMAIL=superuser@example.com
|
||||
20
.github/workflows/liara.yaml
vendored
20
.github/workflows/liara.yaml
vendored
@@ -1,20 +0,0 @@
|
||||
name: CD-Liara
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "22"
|
||||
- name: update-liara
|
||||
env:
|
||||
LIARA_TOKEN: ${{ secrets.LIARA_API_TOKEN }}
|
||||
run: |
|
||||
npm i -g @liara/cli@7
|
||||
liara deploy --app="apidam" --api-token="$LIARA_TOKEN" --no-app-logs
|
||||
24
Dockerfile
Normal file
24
Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
||||
# pull official base image
|
||||
FROM python:3.10.0-slim-buster
|
||||
|
||||
# Create the app directory
|
||||
RUN mkdir /app
|
||||
|
||||
# set work directory
|
||||
WORKDIR app/
|
||||
|
||||
# set environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
# install dependencies
|
||||
RUN pip install --upgrade pip
|
||||
COPY ./requirements.txt /app/
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
# copy project
|
||||
COPY . /app/
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
CMD ["python", "manage.py", "runserver", "0.0.0.0:5000"]
|
||||
@@ -39,7 +39,8 @@ ALLOWED_HOSTS = [
|
||||
'https://dam.rasadyar.net'
|
||||
'http://localhost:3000',
|
||||
'http://192.168.88.130:3000',
|
||||
'https://rasaddam-front.liara.run'
|
||||
'https://rasaddam-front.liara.run',
|
||||
'ns0ck4ksk0koks8ksw0ss08g.31.7.78.133.sslip.io' # noqa
|
||||
]
|
||||
|
||||
# Application definition
|
||||
@@ -346,7 +347,8 @@ CORS_ALLOWED_ORIGINS = (
|
||||
'http://192.168.88.130:3000',
|
||||
'https://rasadyar.net',
|
||||
'https://rasaddam-front.liara.run',
|
||||
'https://dam.rasadyar.net'
|
||||
'https://dam.rasadyar.net',
|
||||
'http://ns0ck4ksk0koks8ksw0ss08g.31.7.78.133.sslip.io' # noqa
|
||||
)
|
||||
|
||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||
@@ -354,7 +356,7 @@ SECURE_SSL_REDIRECT = False
|
||||
SESSION_COOKIE_SECURE = False
|
||||
CSRF_COOKIE_SECURE = False
|
||||
|
||||
JAZZMIN_SETTINGS = {
|
||||
JAZZMIN_SETTINGS = { # noqa
|
||||
# title of the window (Will default to current_admin_site.site_title if absent or None)
|
||||
"site_title": "Library Admin",
|
||||
|
||||
|
||||
@@ -47,22 +47,51 @@ def pos_organizations_sharing_information(
|
||||
})
|
||||
|
||||
# if device owner is an agency organization
|
||||
# if owner_org.type.name == 'AGC':
|
||||
agc_share_amount = owner_org.pos_stake_holders.filter(
|
||||
if owner_org.type.name == 'AGC':
|
||||
sharing_information_list = agency_organization_pos_info(
|
||||
agency=owner_org,
|
||||
pos_sharing_list=sharing_information_list,
|
||||
device=device,
|
||||
distribution=distribution
|
||||
)
|
||||
|
||||
return sharing_information_list
|
||||
|
||||
|
||||
def agency_organization_pos_info(
|
||||
agency: Organization = None,
|
||||
pos_sharing_list: list = None,
|
||||
device: Device = None,
|
||||
distribution: QuotaDistribution = None
|
||||
) -> typing.Any:
|
||||
"""
|
||||
if pos org owner is an agency, calculate share amount of agency
|
||||
and share amount of parent organization
|
||||
"""
|
||||
|
||||
# get agency share amount
|
||||
agc_share_amount = agency.pos_stake_holders.filter(
|
||||
device=device,
|
||||
).first().holders_share_amount.filter(
|
||||
quota_distribution=distribution
|
||||
)
|
||||
sharing_information_list.append({
|
||||
"organization_name": owner_org.name,
|
||||
"bank_account": {
|
||||
"credit_card": owner_org.bank_information.first().card,
|
||||
"sheba": owner_org.bank_information.first().sheba,
|
||||
"account": owner_org.bank_information.first().account,
|
||||
} if owner_org.bank_information.exists() else {},
|
||||
"amount": agc_share_amount.first().share_amount if agc_share_amount else None,
|
||||
"agency": True,
|
||||
"default_account": True
|
||||
})
|
||||
agc_share_amount = agc_share_amount.first().share_amount if agc_share_amount else None
|
||||
|
||||
return sharing_information_list
|
||||
# calculate agency parent share amount
|
||||
agc_parent_amount = next((item for item in pos_sharing_list if item.get('default_account')), None)
|
||||
if agc_parent_amount and agc_share_amount:
|
||||
agc_parent_amount['amount'] = agc_parent_amount['amount'] - agc_share_amount
|
||||
|
||||
pos_sharing_list.append({
|
||||
"organization_name": agency.name,
|
||||
"bank_account": {
|
||||
"credit_card": agency.bank_information.first().card,
|
||||
"sheba": agency.bank_information.first().sheba,
|
||||
"account": agency.bank_information.first().account,
|
||||
} if agency.bank_information.exists() else {},
|
||||
"amount": agc_share_amount,
|
||||
"agency": True,
|
||||
"default_account": True
|
||||
})
|
||||
|
||||
return pos_sharing_list
|
||||
|
||||
10
docker-compose.yml
Normal file
10
docker-compose.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
version: '3.10'
|
||||
|
||||
services:
|
||||
web:
|
||||
build: ./
|
||||
command: python manage.py runserver 0.0.0.0:5000
|
||||
volumes:
|
||||
- ./app/:/usr/src/app/
|
||||
ports:
|
||||
- "5000:5000"
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"app": "apidam",
|
||||
"port": 80,
|
||||
"build": {
|
||||
"location": "iran"
|
||||
},
|
||||
"disks": []
|
||||
}
|
||||
@@ -40,7 +40,6 @@ openpyxl
|
||||
packaging
|
||||
pillow==9.5.0
|
||||
prompt-toolkit
|
||||
psycopg2
|
||||
psycopg2-binary
|
||||
pyasn1
|
||||
pycparser
|
||||
|
||||
Reference in New Issue
Block a user