Skip to content

FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.

git workflow update

tilakpatel2231b1cc2ba80a
diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
index 78240f9dd..5a93134ca 100644
--- a/.github/workflows/docker-image.yml
+++ b/.github/workflows/docker-image.yml
@@ -2,7 +2,7 @@ name: Docker Image CI
on:
push:
- branches: [ "main" ]
+ branches: [ "main", "develop" ]
pull_request:
branches: [ "main" ]
workflow_dispatch: # Allow manual triggering
@@ -17,13 +17,26 @@ jobs:
permissions:
contents: read
packages: write
+ security-events: write # For security scanning
steps:
- name: Checkout repository
uses: actions/checkout@v4
+ - name: Free up disk space
+ run: |
+ sudo rm -rf /usr/local/lib/android
+ sudo rm -rf /usr/share/dotnet
+ sudo rm -rf /opt/ghc
+ sudo rm -rf /usr/local/share/boost
+ sudo apt-get clean
+ docker system prune -af
+
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
+ with:
+ driver-opts: |
+ network=host
- name: Log in to Container Registry
if: github.event_name != 'pull_request'
@@ -48,13 +61,37 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
- file: ./Dockerfile
+ file: ./Dockerfile.optimized
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- platforms: linux/amd64,linux/arm64
+ platforms: linux/amd64
+ build-args: |
+ BUILDKIT_INLINE_CACHE=1
+
+ - name: Image size check
+ if: github.event_name != 'pull_request'
+ run: |
+ # Get the latest tag for size checking
+ LATEST_TAG="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
+ docker pull $LATEST_TAG
+ IMAGE_SIZE=$(docker images $LATEST_TAG --format "table {{.Size}}" | tail -n +2)
+ echo "Final image size: $IMAGE_SIZE"
+
+ # Convert size to MB for comparison (rough estimation)
+ if echo $IMAGE_SIZE | grep -q "GB"; then
+ SIZE_NUM=$(echo $IMAGE_SIZE | sed 's/GB.*//')
+ if (( $(echo "$SIZE_NUM > 2" | bc -l) )); then
+ echo "Warning: Image size ($IMAGE_SIZE) is larger than 2GB"
+ echo "Consider further optimization"
+ else
+ echo "Image size is acceptable: $IMAGE_SIZE"
+ fi
+ else
+ echo "Image size is acceptable: $IMAGE_SIZE"
+ fi
test:
runs-on: ubuntu-latest
@@ -65,6 +102,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
+ - name: Free up disk space
+ run: |
+ sudo rm -rf /usr/local/lib/android
+ sudo rm -rf /usr/share/dotnet
+ docker system prune -af
+
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@@ -72,15 +115,61 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
- file: ./Dockerfile
+ file: ./Dockerfile.optimized
load: true
tags: test-image:latest
cache-from: type=gha
- - name: Test Docker image
+ - name: Test Docker image basic functionality
+ run: |
+ echo "Testing if optimized container starts successfully..."
+ docker run --rm test-image:latest python -c "
+ import sys
+ print('Python version:', sys.version)
+ print('Container test passed!')
+
+ # Test core imports that should be available
+ try:
+ import pandas as pd
+ import numpy as np
+ import requests
+ print('Core dependencies imported successfully')
+ except ImportError as e:
+ print('Import failed:', e)
+ sys.exit(1)
+ "
+
+ - name: Test application structure
run: |
- echo "Testing if container starts successfully..."
- docker run --rm test-image:latest python -c "print('Container test passed!')"
+ echo "Testing application structure..."
+ docker run --rm test-image:latest python -c "
+ import sys
+ import os
+
+ # Check if application files exist
+ app_files = [
+ '/app/fincept_terminal',
+ '/app/pyproject.toml'
+ ]
+
+ for file_path in app_files:
+ if os.path.exists(file_path):
+ print(f'{file_path} exists')
+ else:
+ print(f'{file_path} not found')
+
+ # Test virtual environment
+ if os.path.exists('/app/.venv'):
+ print('Virtual environment found')
+ else:
+ print('Virtual environment not found')
+ "
+
+ - name: Check final image size
+ run: |
+ SIZE=$(docker images test-image:latest --format "table {{.Size}}" | tail -n +2)
+ echo "Final optimized image size: $SIZE"
+ echo "size=$SIZE" >> $GITHUB_OUTPUT
security-scan:
runs-on: ubuntu-latest
@@ -91,7 +180,7 @@ jobs:
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
- image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
+ image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
format: 'sarif'
output: 'trivy-results.sarif'
@@ -99,4 +188,30 @@ jobs:
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
- sarif_file: 'trivy-results.sarif'
\ No newline at end of file
+ sarif_file: 'trivy-results.sarif'
+
+ notify:
+ runs-on: ubuntu-latest
+ needs: [build, security-scan]
+ if: always() && github.event_name != 'pull_request'
+
+ steps:
+ - name: Build Status Summary
+ run: |
+ echo "## Docker Build Summary" >> $GITHUB_STEP_SUMMARY
+ echo "" >> $GITHUB_STEP_SUMMARY
+ echo "| Component | Status |" >> $GITHUB_STEP_SUMMARY
+ echo "|-----------|--------|" >> $GITHUB_STEP_SUMMARY
+ echo "| Build | ${{ needs.build.result == 'success' && 'Success' || 'Failed' }} |" >> $GITHUB_STEP_SUMMARY
+ echo "| Security Scan | ${{ needs.security-scan.result == 'success' && 'Passed' || 'Issues Found' }} |" >> $GITHUB_STEP_SUMMARY
+ echo "" >> $GITHUB_STEP_SUMMARY
+ echo "### Usage:" >> $GITHUB_STEP_SUMMARY
+ echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
+ echo "# Pull the optimized image" >> $GITHUB_STEP_SUMMARY
+ echo "docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_STEP_SUMMARY
+ echo "" >> $GITHUB_STEP_SUMMARY
+ echo "# Run the container" >> $GITHUB_STEP_SUMMARY
+ echo "docker run -p 8000:8000 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_STEP_SUMMARY
+ echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
+ echo "" >> $GITHUB_STEP_SUMMARY
+ echo "Expected image size: 800MB-1.2GB (down from 10GB)" >> $GITHUB_STEP_SUMMAR
\ No newline at end of file