remove liara.json & workflow/liara.yaml - add Dockerfile & docker-compose file

This commit is contained in:
2025-10-18 10:46:54 +03:30
parent 5a2fe5243b
commit d4e14a1e51
8 changed files with 97 additions and 46 deletions

15
.env.dev Normal file
View 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

View File

@@ -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
View 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"]

View File

@@ -39,7 +39,8 @@ ALLOWED_HOSTS = [
'https://dam.rasadyar.net' 'https://dam.rasadyar.net'
'http://localhost:3000', 'http://localhost:3000',
'http://192.168.88.130: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 # Application definition
@@ -346,7 +347,8 @@ CORS_ALLOWED_ORIGINS = (
'http://192.168.88.130:3000', 'http://192.168.88.130:3000',
'https://rasadyar.net', 'https://rasadyar.net',
'https://rasaddam-front.liara.run', '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') SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
@@ -354,7 +356,7 @@ SECURE_SSL_REDIRECT = False
SESSION_COOKIE_SECURE = False SESSION_COOKIE_SECURE = False
CSRF_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) # title of the window (Will default to current_admin_site.site_title if absent or None)
"site_title": "Library Admin", "site_title": "Library Admin",

View File

@@ -47,22 +47,51 @@ def pos_organizations_sharing_information(
}) })
# if device owner is an agency organization # if device owner is an agency organization
# if owner_org.type.name == 'AGC': if owner_org.type.name == 'AGC':
agc_share_amount = owner_org.pos_stake_holders.filter( 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, device=device,
).first().holders_share_amount.filter( ).first().holders_share_amount.filter(
quota_distribution=distribution quota_distribution=distribution
) )
sharing_information_list.append({ agc_share_amount = agc_share_amount.first().share_amount if agc_share_amount else None
"organization_name": owner_org.name,
# 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": { "bank_account": {
"credit_card": owner_org.bank_information.first().card, "credit_card": agency.bank_information.first().card,
"sheba": owner_org.bank_information.first().sheba, "sheba": agency.bank_information.first().sheba,
"account": owner_org.bank_information.first().account, "account": agency.bank_information.first().account,
} if owner_org.bank_information.exists() else {}, } if agency.bank_information.exists() else {},
"amount": agc_share_amount.first().share_amount if agc_share_amount else None, "amount": agc_share_amount,
"agency": True, "agency": True,
"default_account": True "default_account": True
}) })
return sharing_information_list return pos_sharing_list

10
docker-compose.yml Normal file
View 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"

View File

@@ -1,8 +0,0 @@
{
"app": "apidam",
"port": 80,
"build": {
"location": "iran"
},
"disks": []
}

View File

@@ -40,7 +40,6 @@ openpyxl
packaging packaging
pillow==9.5.0 pillow==9.5.0
prompt-toolkit prompt-toolkit
psycopg2
psycopg2-binary psycopg2-binary
pyasn1 pyasn1
pycparser pycparser