Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
85acbfb
Update CI workflow configuration
justFadel19 Jun 12, 2025
0620ca1
Update .gitignore with new patterns
justFadel19 Jun 12, 2025
4c69758
Update application Dockerfile configuration
justFadel19 Jun 12, 2025
5ffba68
Update web Dockerfile configuration
justFadel19 Jun 12, 2025
078b355
Update project README documentation
justFadel19 Jun 12, 2025
7c7f3c2
Refactor main application entry point
justFadel19 Jun 12, 2025
0bfbd80
Update application dependencies
justFadel19 Jun 12, 2025
b2f7517
Delete app/db/database.py - removing database layer
justFadel19 Jun 12, 2025
7350cf4
Delete app/db/models.py - removing database models
justFadel19 Jun 12, 2025
d9fa7f9
Delete app/requirements_simplified.txt - consolidating requirements
justFadel19 Jun 12, 2025
9705f5d
Delete app/routers/images.py - refactoring router structure
justFadel19 Jun 12, 2025
2ea4f28
Delete app/routers/segmentation.py - refactoring router structure
justFadel19 Jun 12, 2025
588935d
Delete app/schemas/images.py - refactoring schema structure
justFadel19 Jun 12, 2025
e8a229e
Delete app/storage/session_manager_backup.py - removing backup file
justFadel19 Jun 12, 2025
c0ac4fb
Delete app/storage/session_manager_fixed.py - removing temporary file
justFadel19 Jun 12, 2025
4a115e3
Delete app/utils/db_migrate.py - removing database migration utility
justFadel19 Jun 12, 2025
6137ed3
Delete app/utils/test_utils.py - removing test utilities
justFadel19 Jun 12, 2025
b473111
Delete app/websocket_notify.py - removing websocket notification module
justFadel19 Jun 12, 2025
60f1b8b
Delete build.bat - removing Windows build script
justFadel19 Jun 12, 2025
e9ff4da
Delete build.sh - removing Unix build script
justFadel19 Jun 12, 2025
a2164ae
Delete docs/ERD.png - removing entity relationship diagram
justFadel19 Jun 12, 2025
7384e3b
Delete scripts/db/01-init-schema.sql - removing database initializati…
justFadel19 Jun 12, 2025
5fdd859
Delete web/README.md - removing web documentation
justFadel19 Jun 12, 2025
8269ace
Delete web/canvas-debug.html - removing debug HTML file
justFadel19 Jun 12, 2025
1531ad9
Delete web/canvas-test.html - removing test HTML file
justFadel19 Jun 12, 2025
643ed0e
Delete web/debug-minimal.html - removing minimal debug HTML file
justFadel19 Jun 12, 2025
716de3c
Delete web/debug.html - removing debug HTML file
justFadel19 Jun 12, 2025
8dcf8db
Delete web/demo-new.html - removing demo HTML file
justFadel19 Jun 12, 2025
3e792ee
Delete web/demo.html - removing demo HTML file
justFadel19 Jun 12, 2025
5d3a7b5
Delete web/loading-test.html - removing loading test HTML file
justFadel19 Jun 12, 2025
4cad6d9
Delete web/minimal-canvas-test.html - removing minimal canvas test HT…
justFadel19 Jun 12, 2025
ebcf43d
Delete web/package.json - removing web package configuration
justFadel19 Jun 12, 2025
6b6fa21
Delete web/polygon-editing-demo.html - removing polygon editing demo …
justFadel19 Jun 12, 2025
597b0bd
Delete web/test-loading.html - removing test loading HTML file
justFadel19 Jun 12, 2025
a756963
Update app/routers/session_images.py - refactor session image handling
justFadel19 Jun 12, 2025
f910f70
Update app/routers/session_segmentation.py - refactor session segment…
justFadel19 Jun 12, 2025
9b49bcb
Update app/storage/session_manager.py - improve session management
justFadel19 Jun 12, 2025
ea77871
Update app/tests/README.md - update test documentation
justFadel19 Jun 12, 2025
e2aa33f
Update app/tests/run_unittests.py - improve test runner
justFadel19 Jun 12, 2025
df6c686
Update app/tests/unittest_main_api.py - improve API unit tests
justFadel19 Jun 12, 2025
1ca5072
Update app/tests/unittest_session_manager.py - improve session manage…
justFadel19 Jun 12, 2025
546d233
Update app/utils/image_processing.py - improve image processing utili…
justFadel19 Jun 12, 2025
8c796ff
Update app/utils/sam_model.py - improve SAM model utilities
justFadel19 Jun 12, 2025
21b6ac7
Update docker-compose.yml - improve Docker configuration
justFadel19 Jun 12, 2025
84d4a1b
Update web/js/annotations.js - improve annotation functionality
justFadel19 Jun 12, 2025
0c0df60
Update web/js/api.js - improve API handling
justFadel19 Jun 12, 2025
29377ce
Update web/js/app.js - improve main application logic
justFadel19 Jun 12, 2025
bab067e
Update web/js/canvas.js - improve canvas functionality
justFadel19 Jun 12, 2025
065eb49
Update web/js/utils.js - improve utility functions
justFadel19 Jun 12, 2025
afd97c3
Update web/styles.css - improve styling and layout
justFadel19 Jun 12, 2025
e16c36d
fix: resolve CI PyTorch CUDA dependency issue
justFadel19 Jun 12, 2025
4cee0ee
docs: add requirements-ci.txt to project structure in README
justFadel19 Jun 12, 2025
bb123d6
Enhance security: Set httponly flag to true for session cookies
justFadel19 Jun 12, 2025
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
58 changes: 36 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f app/requirements_simplified.txt ]; then pip install -r app/requirements_simplified.txt; fi
# Install PyTorch CPU version first with the correct index
pip install torch==2.5.1+cpu torchvision==0.20.1+cpu --index-url https://download.pytorch.org/whl/cpu
# Install CI-specific requirements (CPU versions)
if [ -f app/requirements-ci.txt ]; then pip install -r app/requirements-ci.txt; fi
# Install test requirements
if [ -f app/tests/test_requirements.txt ]; then pip install -r app/tests/test_requirements.txt; fi
# Install SAM model (may be needed for imports, even though tests use mocks)
pip install git+https://github.com/facebookresearch/segment-anything.git

- name: Set test mode environment variable
run: |
Expand All @@ -34,34 +40,40 @@ jobs:
cd app/tests
python run_unittests.py

web-build:
web-validation:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: 'web/package.json'

- name: Install dependencies
working-directory: ./web
run: npm ci

- name: Build
working-directory: ./web
run: npm run build
- name: Validate HTML files
run: |
echo "Validating web static files..."
# Check if main HTML files exist
test -f web/index.html || (echo "Missing index.html" && exit 1)
test -f web/styles.css || (echo "Missing styles.css" && exit 1)
test -d web/js || (echo "Missing js directory" && exit 1)
echo "Web files validation passed"

- name: Run linting
working-directory: ./web
run: npm run lint || true
- name: Check JavaScript syntax
run: |
echo "Checking JavaScript syntax..."
# Use Python to check basic JavaScript syntax if Node.js is available
if command -v node >/dev/null 2>&1; then
for js_file in web/js/*.js; do
if [ -f "$js_file" ]; then
echo "Checking $js_file..."
node -c "$js_file" || (echo "Syntax error in $js_file" && exit 1)
fi
done
else
echo "Node.js not available, skipping JS syntax check..."
fi
echo "JavaScript validation completed"

docker-build:
runs-on: ubuntu-latest
needs: [app-tests, web-build]
needs: [app-tests, web-validation]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')

steps:
Expand All @@ -70,9 +82,11 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and tag Docker images
- name: Build and test Docker images
run: |
echo "Building Docker images..."
docker compose build
echo "Docker build completed successfully"

# Uncomment and configure the following if you want to push to Docker Hub or another registry
# - name: Login to Docker Hub
Expand All @@ -83,4 +97,4 @@ jobs:
#
# - name: Push Docker images
# run: |
# docker compose push
# docker compose push
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,9 @@ cython_debug/

# PyPI configuration file
.pypirc

# SAT-Annotator specific directories
annotations/
uploads/
logs/
app/logs/
28 changes: 19 additions & 9 deletions Dockerfile.app
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Build stage
FROM python:3.11-slim as builder
FROM python:3.12-slim as builder

WORKDIR /app

# Install build dependencies
RUN apt-get update && apt-get install -y \
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
wget \
git \
&& apt-get upgrade -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand All @@ -18,23 +19,23 @@ ENV PATH="/opt/venv/bin:$PATH"
# Copy and install requirements
COPY app/requirements.txt .

# Install specific PyTorch CPU-only version to save space
# Install PyTorch (CPU version for smaller Docker image) and other dependencies
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install --no-cache-dir torch==2.2.0+cpu torchvision==0.17.0+cpu -f https://download.pytorch.org/whl/torch_stable.html && \
pip install --no-cache-dir opencv-python-headless pillow fastapi uvicorn python-multipart && \
pip install --no-cache-dir supervision python-jose[cryptography] && \
pip install --no-cache-dir torch==2.5.1+cpu torchvision==0.20.1+cpu --index-url https://download.pytorch.org/whl/cpu && \
pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir 'git+https://github.com/facebookresearch/segment-anything.git'

# Final stage
FROM python:3.11-slim
FROM python:3.12-slim

WORKDIR /app

# Install runtime dependencies only
RUN apt-get update && apt-get install -y \
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1-mesa-glx \
libglib2.0-0 \
wget \
&& apt-get upgrade -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand All @@ -45,11 +46,20 @@ ENV PATH="/opt/venv/bin:$PATH"
# Create necessary directories
RUN mkdir -p /app/models /app/annotations /app/uploads

# Create a non-root user for security
RUN groupadd -r appuser && useradd -r -g appuser appuser

# Download the SAM model checkpoint (only in the final stage)
RUN wget --no-verbose https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth -P /app/models/
RUN wget --no-verbose https://dl.fbaipublicfiles.com/segment-anything/sam_vit_h_4b8939.pth -P /app/models/

# Copy the application
COPY . .

# Change ownership to the non-root user
RUN chown -R appuser:appuser /app

# Switch to the non-root user
USER appuser

# Command to run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
31 changes: 19 additions & 12 deletions Dockerfile.web
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
FROM node:22-alpine
FROM python:3.12-slim

WORKDIR /web

# Install netcat for health checking
RUN apk add --no-cache netcat-openbsd

COPY web/package.json web/package-lock.json ./
RUN npm install
# Install basic tools and security updates
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& apt-get upgrade -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Copy static files
COPY web .

# Make the wait script executable
COPY web/wait-for-backend.sh /wait-for-backend.sh
RUN chmod +x /wait-for-backend.sh
# Create a non-root user for security
RUN groupadd -r webuser && useradd -r -g webuser webuser

# Change ownership to the non-root user
RUN chown -R webuser:webuser /web

# Switch to the non-root user
USER webuser

EXPOSE 5173
EXPOSE 8080

# Use the wait script before starting the app
CMD ["/wait-for-backend.sh", "npm", "run", "dev"]
# Serve static files using Python's built-in server
CMD ["python", "-m", "http.server", "8080"]
Loading