Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ __pycache__/
htmlcov/
.env
.DS_Store

# app_nippon_rfq_matching runtime artifacts
apps/app_nippon_rfq_matching/data/rfq_matching.db
apps/app_nippon_rfq_matching/data/vectors/
apps/app_nippon_rfq_matching/data/uploads/*
!apps/app_nippon_rfq_matching/data/uploads/.gitkeep
apps/app_nippon_rfq_matching/data/storage/*
!apps/app_nippon_rfq_matching/data/storage/.gitkeep
apps/app_nippon_rfq_matching/data/output/
63 changes: 63 additions & 0 deletions apps/app_nippon_rfq_matching/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
*.egg-info/
dist/
build/
*.egg

# Virtual Environment
venv/
env/
ENV/
.venv/

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db

# Git
.git/
.gitignore
.gitattributes

# Data (will be created in container)
data/
*.db
*.db-journal
*.db-shm
*.db-wal

# Logs
*.log
logs/

# Environment
.env
.env.local
.env.*.local

# Testing
.pytest_cache/
.coverage
htmlcov/
.tox/

# Documentation
*.md
docs/

# Docker
Dockerfile
docker-compose.yml
.dockerignore
40 changes: 40 additions & 0 deletions apps/app_nippon_rfq_matching/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# App
APP_NIPPON_RFQ_ENV=development
APP_NIPPON_RFQ_APP_NAME="RFQ Product Matching API"
APP_NIPPON_RFQ_APP_VERSION=0.1.0
APP_NIPPON_RFQ_DEBUG=false
APP_NIPPON_RFQ_DOCS_ENABLED=true

# API
APP_NIPPON_RFQ_API_PREFIX=/api/nippon-rfq
APP_NIPPON_RFQ_API_VERSION=v1

# Database
APP_NIPPON_RFQ_DATABASE_URL=sqlite:///./data/rfq_matching.db

# Storage
APP_NIPPON_RFQ_UPLOAD_DIR=./data/uploads
APP_NIPPON_RFQ_STORAGE_DIR=./data/storage
APP_NIPPON_RFQ_CSV_DIR=./data/storage/csv
APP_NIPPON_RFQ_VECTOR_DB_PATH=./data/vectors

# Matching
APP_NIPPON_RFQ_MIN_MATCH_SCORE=70.0
APP_NIPPON_RFQ_SEMANTIC_MATCH_THRESHOLD=0.85
APP_NIPPON_RFQ_HYBRID_MATCH_THRESHOLD=0.90
APP_NIPPON_RFQ_ENABLE_SEMANTIC_SEARCH=true

# AIS Manager
APP_NIPPON_RFQ_AISMBACKEND_URL=https://aismanager-stg.visiongroup.co

# LlamaParse (third-party, canonical env var)
LLAMAPARSE_API_KEY=
LLAMAPARSE_TIMEOUT=300

# OpenAI (third-party, canonical env vars)
OPENAI_API_KEY=
OPENAI_EMBEDDING_MODEL=text-embedding-3-small
OPENAI_EMBEDDING_DIMENSIONS=512
OPENAI_CHAT_MODEL=gpt-4o-mini
OPENAI_TEMPERATURE=0.0
OPENAI_MAX_TOKENS=4000
142 changes: 142 additions & 0 deletions apps/app_nippon_rfq_matching/.github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: '(NEW) Deploy the Application'
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to deploy from'
required: true
default: 'dev'
target:
description: 'Select deployment target'
required: true
type: choice
options:
- dev
namespace:
description: 'Dev Namespace'
required: false
default: 'default'

pull_request:
types: [closed]
branches:
- prd

jobs:
set-matrix:
name: Set Matrix for Deployment
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix || steps.set-matrix-pr.outputs.matrix }}
branch: ${{ steps.set-matrix.outputs.branch || steps.set-matrix-pr.outputs.branch }}
environment: ${{ steps.set-matrix.outputs.environment || steps.set-matrix-pr.outputs.environment }}
steps:
- name: Set matrix for workflow_dispatch
if: github.event_name == 'workflow_dispatch'
id: set-matrix
run: |
if [ "${{ github.event.inputs.branch }}" == "prd" ]; then
echo "❌ You cannot deploy from the 'prd' branch using workflow_dispatch."
exit 1
fi
echo "matrix={\"target\":[\"${{ github.event.inputs.target }}\"]}" >> $GITHUB_OUTPUT
echo "branch=${{ github.event.inputs.branch }}" >> $GITHUB_OUTPUT
echo "environment=${{ github.event.inputs.target }}" >> $GITHUB_OUTPUT
- name: Set matrix for pull_request on prd branch and closed
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.ref == 'refs/heads/prd'
id: set-matrix-pr
run: |
echo 'matrix={"target":["prd", "prd_fozl"]}' >> $GITHUB_OUTPUT
echo 'branch=prd' >> $GITHUB_OUTPUT
echo 'environment=prd' >> $GITHUB_OUTPUT

build_push_deploy:
name: Build, Push and Deploy (${{ matrix.target }})
needs: set-matrix
if: needs.set-matrix.outputs.matrix != ''
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.set-matrix.outputs.matrix) }}
environment: ${{ matrix.target }}
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
ref: ${{ needs.set-matrix.outputs.branch }}
- name: Get Current Date
id: date
run: echo "date=$(date +'%Y%m%d')" >> "$GITHUB_OUTPUT"
- name: Set Image Tag
id: imgtag
run: |
ROLLING_BUILD_NUM=$((GITHUB_RUN_NUMBER % 100))
TAG="v${{ steps.date.outputs.date }}${ROLLING_BUILD_NUM}"
IMAGE="${{ vars.REGISTRY_URL }}/${{ vars.REGISTRY_PATH }}:$TAG"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "image=$IMAGE" >> "$GITHUB_OUTPUT"
- name: Set Doppler Config
id: dopplerconfig
run: |
if [ "${{ matrix.target }}" = "dev" ]; then
if [ "${{ github.event.inputs.namespace }}" = "default" ]; then
CONFIG="${{ vars.DOPPLER_CONFIG_KEY }}"
else
CONFIG="${{ vars.DOPPLER_CONFIG_KEY }}_${{ github.event.inputs.namespace }}"
fi
else
CONFIG="${{ vars.DOPPLER_CONFIG_KEY }}"
fi
echo "config=$CONFIG" >> "$GITHUB_OUTPUT"

- name: Build Docker image
run: |
docker build \
--platform=linux/amd64 \
--provenance=false \
--build-arg ARG_NODE_ENV=${{ needs.set-matrix.outputs.environment }} \
--build-arg ARG_DOPPLER_TOKEN=${{ secrets.DOPPLER_TOKEN }} \
--build-arg ARG_DOPPLER_PROJECT=${{ vars.PROJECT_NAME }} \
--build-arg ARG_DOPPLER_CONFIG=${{ steps.dopplerconfig.outputs.config }} \
-t ${{ steps.imgtag.outputs.image }} .
- name: Set up Docker credentials
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ vars.REGISTRY_URL }} -u "${{ secrets.REGISTRY_USER }}" --password-stdin

- name: Push Docker image
run: |
docker push ${{ steps.imgtag.outputs.image }}
- name: Checkout CI/CD repo
if: matrix.target == 'dev'
uses: actions/checkout@v4
with:
repository: VisionGrp/VTS_DevOps
ref: main
token: ${{ secrets.CICD_PAT }}
path: cicd
- name: Deploy to Kubernetes
if: matrix.target == 'dev'
env:
NAMESPACE: ${{ github.event.inputs.namespace }}
BUILD_VERSION: ${{ steps.imgtag.outputs.tag }}
IMAGE: ${{ steps.imgtag.outputs.image }}
run: |
export KUBECONFIG=$(pwd)/cicd/k8s/kubeconfig-dev.yaml
kubectl cluster-info
envsubst < cicd/k8s/backend-nippon-rfq/0-namespace.yaml | kubectl apply -f -
kubectl create secret docker-registry acr-secret --docker-server=${{ vars.REGISTRY_URL }} --docker-username=${{ secrets.REGISTRY_USER }} --docker-password=${{ secrets.REGISTRY_PASSWORD }} --docker-email=muhammad.fahmi@visiongroup.co -n ${{ github.event.inputs.namespace }} || true
envsubst < cicd/k8s/backend-nippon-rfq/1-deployment.yaml | kubectl apply -f -
envsubst < cicd/k8s/backend-nippon-rfq/2-service.yaml | kubectl apply -f -
envsubst < cicd/k8s/backend-nippon-rfq/3-ingressroute.yaml | kubectl apply -f -
- name: Add image info to job summary
run: |
echo "## 🚀 Deployment Info" >> $GITHUB_STEP_SUMMARY
echo "- **Build Version:** \`${{ steps.imgtag.outputs.tag }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Target:** \`${{ matrix.target }}\`" >> $GITHUB_STEP_SUMMARY
if [ "${{ github.event.inputs.target }}" == "dev" ]; then
# If target is dev, replace {{NAMESPACE}} inside CHECK_URL with the provided namespace
check_url=$(echo '${{ vars.CHECK_URL }}' | sed 's/{{NAMESPACE}}/${{ github.event.inputs.namespace }}/g')
echo "- **Check URL:** [$check_url]($check_url)" >> $GITHUB_STEP_SUMMARY
else
# Otherwise, just output CHECK_URL as is
echo "- **Check URL:** [${{ vars.CHECK_URL }}](${{ vars.CHECK_URL }})" >> $GITHUB_STEP_SUMMARY
fi
67 changes: 67 additions & 0 deletions apps/app_nippon_rfq_matching/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Virtual Environment
venv/
ENV/
env/

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# Environment
.env

# Data
data/uploads/*
data/storage/*
data/output/*
!data/uploads/.gitkeep
!data/storage/.gitkeep

# Database
*.db
*.db-shm
*.db-wal
*.sqlite
*.sqlite3

# Logs
*.log

# OS
.DS_Store
Thumbs.db

# Jupyter
.ipynb_checkpoints/
*.ipynb

# Testing
.pytest_cache/
.coverage
htmlcov/
tmp/
Loading
Loading