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
15 changes: 11 additions & 4 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#!/usr/bin/env bash
set -euo pipefail

RUFF=".venv/bin/ruff"
[[ -x "$RUFF" ]] || RUFF="ruff"
if ! command -v uv >/dev/null 2>&1; then
echo "uv is not installed; run scripts/bootstrap.sh first." >&2
exit 1
fi

# `uv run` auto-syncs missing packages; --all-packages --all-groups keeps
# every workspace member + dev tools in the venv so the hook is self-healing
# after a narrow `uv sync` would otherwise have pruned them.
UV_RUN=(uv run --quiet --all-packages --all-groups)

echo "ruff: format check..."
"$RUFF" format --check .
"${UV_RUN[@]}" ruff format --check .

echo "ruff: lint..."
"$RUFF" check .
"${UV_RUN[@]}" ruff check .
15 changes: 8 additions & 7 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/usr/bin/env bash
set -euo pipefail

RUFF=".venv/bin/ruff"
[[ -x "$RUFF" ]] || RUFF="ruff"
if ! command -v uv >/dev/null 2>&1; then
echo "uv is not installed; run scripts/bootstrap.sh first." >&2
exit 1
fi

PYTEST=".venv/bin/pytest"
[[ -x "$PYTEST" ]] || PYTEST="pytest"
UV_RUN=(uv run --quiet --all-packages --all-groups)

echo "ruff: format check..."
"$RUFF" format --check .
"${UV_RUN[@]}" ruff format --check .

echo "ruff: lint..."
"$RUFF" check .
"${UV_RUN[@]}" ruff check .

echo "pytest: running tests..."
"$PYTEST" apps
"${UV_RUN[@]}" pytest apps
2 changes: 0 additions & 2 deletions apps/app_admin/requirements.txt

This file was deleted.

97 changes: 44 additions & 53 deletions apps/app_nippon_rfq_matching/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,70 +1,61 @@
# Use Debian-based Python image
FROM python:3.12-slim
# =====================================================================
# uv workspace-sync build. Build context must be the repo root.
# =====================================================================
FROM python:3.12-slim-bookworm

# Build argument for macOS-specific requirements
ARG INSTALL_MACOS_REQUIREMENTS=false
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=1 \
PATH="/app/.venv/bin:$PATH"

# Prevent Python from generating .pyc files
ENV PYTHONDONTWRITEBYTECODE=1
# Keep Python stdout/stderr from being buffered
ENV PYTHONUNBUFFERED=1

# Install system dependencies and uv
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
curl \
pkg-config \
libgomp1 \
libopenblas-dev \
liblapack-dev \
libfreetype-dev \
libpng-dev \
libjpeg-dev \
libwebp-dev \
libtiff-dev \
libavif-dev \
&& curl -LsSf https://astral.sh/uv/install.sh | sh \
&& apt-get clean \
build-essential \
ca-certificates \
libpq-dev \
pkg-config \
libgomp1 \
libopenblas-dev \
liblapack-dev \
libfreetype-dev \
libpng-dev \
libjpeg-dev \
libwebp-dev \
libtiff-dev \
libavif-dev \
&& rm -rf /var/lib/apt/lists/*

# Add uv to PATH
ENV PATH="/root/.local/bin:${PATH}"

# Set uv environment variables
ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy
COPY --from=ghcr.io/astral-sh/uv:0.5 /uv /usr/local/bin/uv

# Set working directory
WORKDIR /app

# Create non-root user
RUN groupadd -g 1000 appuser && \
useradd -r -u 1000 -g appuser appuser

# Copy requirements first for better caching
COPY requirements.txt .
COPY requirements-macos.txt .
# Workspace manifests first so the dep layer caches independently of source.
COPY pyproject.toml uv.lock* ./
COPY common/pyproject.toml common/pyproject.toml
COPY apps/app_docling_api/pyproject.toml apps/app_docling_api/pyproject.toml
COPY apps/app_docling_worker/pyproject.toml apps/app_docling_worker/pyproject.toml
COPY apps/app_docling_common/pyproject.toml apps/app_docling_common/pyproject.toml
COPY apps/app_admin/pyproject.toml apps/app_admin/pyproject.toml
COPY apps/app_sample/pyproject.toml apps/app_sample/pyproject.toml
COPY apps/app_nippon_rfq_matching/pyproject.toml apps/app_nippon_rfq_matching/pyproject.toml

# Install Python dependencies using uv
RUN uv pip install --system -r requirements.txt && \
if [ "$INSTALL_MACOS_REQUIREMENTS" = "true" ]; then uv pip install --system -r requirements-macos.txt; fi
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev --package app-nippon-rfq-matching --no-install-project

# Copy application code
COPY --chown=appuser:appuser ./app ./app
# Source
COPY common ./common
COPY apps/app_nippon_rfq_matching ./apps/app_nippon_rfq_matching

# Create data directories and set permissions
RUN mkdir -p /app/data/uploads /app/data/storage /app/data/storage/csv /app/data/vectors && \
chown -R appuser:appuser /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev --package app-nippon-rfq-matching

# Copy .env.example as .env if .env doesn't exist (for container startup)
COPY --chown=appuser:appuser .env.example .env.example
RUN groupadd -g 1000 appuser \
&& useradd -r -u 1000 -g appuser appuser \
&& mkdir -p /app/data/uploads /app/data/storage/csv /app/data/vectors \
&& chown -R appuser:appuser /app

# Switch to non-root user
USER appuser

# Expose port
EXPOSE 8000

# Run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
CMD ["uvicorn", "apps.app_nippon_rfq_matching.app.main:app", "--host", "0.0.0.0", "--port", "8000"]
15 changes: 5 additions & 10 deletions apps/app_nippon_rfq_matching/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ rfq_product_matching_nippon_fastapi/
│ └── storage/ # Processed data
│ ├── csv/ # CSV exports
│ └── models/ # Saved ML models
├── requirements.txt # Python dependencies
├── pyproject.toml # Python dependencies (uv workspace member)
└── .env # Environment variables
```

Expand Down Expand Up @@ -72,18 +72,13 @@ rfq_product_matching_nippon_fastapi/

## Installation

1. Create virtual environment:
1. From the repo root, bootstrap the uv workspace:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
./scripts/bootstrap.sh
source .venv/bin/activate
```

2. Install dependencies:
```bash
pip install -r requirements.txt
```

3. Set up environment:
2. Set up environment:
```bash
cp .env.example .env
# Edit .env with your configuration
Expand Down
10 changes: 4 additions & 6 deletions apps/app_nippon_rfq_matching/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ version: '3.8'
services:
api:
build:
context: .
dockerfile: Dockerfile
# Set INSTALL_MACOS_REQUIREMENTS=true only on macOS
# On Windows/Linux, leave as false (default)
args:
INSTALL_MACOS_REQUIREMENTS: "false"
# Build context is the repo root because the Dockerfile COPYs workspace
# manifests + common/ + the app's own dir.
context: ../..
dockerfile: apps/app_nippon_rfq_matching/Dockerfile
container_name: rfq-product-matching-api
ports:
- "8000:8000"
Expand Down
151 changes: 0 additions & 151 deletions apps/app_nippon_rfq_matching/requirements-macos.txt

This file was deleted.

Loading
Loading