-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:hotosm/Drone-TM into feat/create-pr…
…oject-form
- Loading branch information
Showing
28 changed files
with
1,600 additions
and
1,275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# For Database and Backend | ||
POSTGRES_USER=dtm | ||
POSTGRES_DB=dtm_db | ||
POSTGRES_PASSWORD=dtm | ||
POSTGRES_HOST=db | ||
|
||
# For MinIO and Backend | ||
S3_BUCKET_NAME=dtm-bucket | ||
S3_ACCESS_KEY=SAMPLEACCESSKEYFORMINIOROOT | ||
S3_SECRET_KEY=SAMPLESECRETACCESSKEYFORMINIOROOT | ||
|
||
GOOGLE_CLIENT_ID="xxxxxxxxx-xxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com" | ||
GOOGLE_CLIENT_SECRET="GOOGLE_CLIENT_SECRET" | ||
SECRET_KEY=SUPERSECRETKEY | ||
|
||
EXTRA_CORS_ORIGINS=["http://localhost:3040"] | ||
|
||
# For Frontend | ||
SITE_NAME="DTM-Drone Tasking Manager" | ||
|
||
# BACKEND URL USE | ||
BASE_URL=http://localhost:8000/api | ||
API_URL_V1=http://localhost:8000/api | ||
|
||
# Pattern goes as <MINIO_HOST>:<MINIO_PORT>/<MINIO_BUCKET> or any object storage path | ||
STATIC_BASE_URL=http://localhost:9000/frontendstatic/ | ||
|
||
# use development for frontend as dev else live ["development", "live"] | ||
DOCKER_TARGET=development |
4 changes: 3 additions & 1 deletion
4
.github/workflows/build_and_deploy.yml → ...orkflows/build_and_deploy_DTM_backend.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Build and Deploy Drone Tasking Manager Frontend | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- src/frontend/** | ||
workflow_dispatch: | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
env: | ||
AWS_REGION: ap-south-1 | ||
S3_BUCKET: dronetm.naxa.com.np | ||
|
||
jobs: | ||
build: | ||
name: Build JavaScript assets | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: ${{ github.ref_name }} | ||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.ref_name }} | ||
|
||
- name: Use Node.js 19.x | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 19.x | ||
|
||
- name: Install yarn | ||
working-directory: ./src/frontend/ | ||
run: npm install -g yarn | ||
|
||
- name: Cache node_modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: ./src/frontend/node_modules | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- name: Write Environment Variables | ||
id: write_env | ||
working-directory: ./src/frontend/ | ||
run: | | ||
echo ${{ vars.FRONTEND_ENV_VARS }} > .env | ||
- name: Install dependencies | ||
working-directory: ./src/frontend/ | ||
run: yarn | ||
|
||
- name: Generate build | ||
working-directory: ./src/frontend/ | ||
run: | | ||
yarn build | ||
- name: Setup AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
audience: sts.amazonaws.com | ||
aws-region: ${{ env.AWS_REGION }} | ||
role-session-name: GH-Actions-${{ github.run_id }}-${{ github.run_attempt }} | ||
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_ARN }} | ||
|
||
- name: Copy Static Files to S3 | ||
working-directory: ./src/frontend/ | ||
run: | | ||
pwd | ||
ls -alh | ||
aws s3 cp --recursive ./dist s3://${{ env.S3_BUCKET }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,3 +78,6 @@ chart/charts | |
|
||
#Docker | ||
DockerData/ | ||
|
||
#Backend Template | ||
src/backend/templates/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,58 @@ | ||
"""Config for the DTM database connection.""" | ||
|
||
from databases import Database | ||
from app.config import settings | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.orm import declarative_base, sessionmaker | ||
|
||
from app.config import settings | ||
Base = declarative_base() | ||
|
||
engine = create_engine( | ||
settings.DTM_DB_URL.unicode_string(), | ||
pool_size=20, | ||
max_overflow=-1, | ||
) | ||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | ||
|
||
Base = declarative_base() | ||
DtmMetadata = Base.metadata | ||
class DatabaseConnection: | ||
"""Manages database connection (sqlalchemy & encode databases)""" | ||
|
||
def __init__(self): | ||
self.database = Database( | ||
settings.DTM_DB_URL.unicode_string(), min_size=5, max_size=20 | ||
) | ||
# self.database = Database(settings.DTM_DB_URL.unicode_string()) | ||
self.engine = create_engine( | ||
settings.DTM_DB_URL.unicode_string(), | ||
pool_size=20, | ||
max_overflow=-1, | ||
) | ||
self.SessionLocal = sessionmaker( | ||
autocommit=False, autoflush=False, bind=self.engine | ||
) | ||
|
||
async def connect(self): | ||
"""Connect to the database.""" | ||
await self.database.connect() | ||
|
||
async def disconnect(self): | ||
"""Disconnect from the database.""" | ||
await self.database.disconnect() | ||
|
||
def create_db_session(self): | ||
"""Create a new SQLAlchemy DB session.""" | ||
db = self.SessionLocal() | ||
try: | ||
return db | ||
finally: | ||
db.close() | ||
|
||
|
||
db_connection = DatabaseConnection() # Create a single instance | ||
|
||
|
||
def get_db(): | ||
"""Create SQLAlchemy DB session.""" | ||
db = SessionLocal() | ||
"""Yield a new database session.""" | ||
return db_connection.create_db_session() | ||
|
||
|
||
async def encode_db(): | ||
"""Get the encode database connection""" | ||
try: | ||
yield db | ||
await db_connection.connect() | ||
yield db_connection.database | ||
finally: | ||
db.close() | ||
await db_connection.disconnect() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.