fix: vendor-based Docker build, playwright upgrade, and CI cross-repo checkout
Some checks failed
Build and Push Docker Image / build (push) Failing after 34s
Some checks failed
Build and Push Docker Image / build (push) Failing after 34s
- Dockerfile now installs schwab-scraper from vendor/ dir (no git needed) - Upgrade playwright to latest to match browserless chromium container - CI workflow checks out schwab-scraper into vendor/ before build - Add scripts/build.sh for local builds via docker-test - Add curl to runtime image for compose healthcheck - Increase memory limit to 512M for large account position scraping
This commit is contained in:
@@ -15,6 +15,13 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Checkout schwab-scraper
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: b3nw/schwab-scraper
|
||||||
|
path: vendor/schwab-scraper
|
||||||
|
token: ${{ secrets.CR_PAT }}
|
||||||
|
|
||||||
- name: Login to Gitea Container Registry
|
- name: Login to Gitea Container Registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
@@ -28,5 +35,3 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: gitea.ext.ben.io/${{ gitea.repository }}:latest
|
tags: gitea.ext.ben.io/${{ gitea.repository }}:latest
|
||||||
build-args: |
|
|
||||||
GIT_TOKEN=${{ secrets.CR_PAT }}
|
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@ config.json
|
|||||||
cookies.json
|
cookies.json
|
||||||
.pytest_cache/
|
.pytest_cache/
|
||||||
.ruff_cache/
|
.ruff_cache/
|
||||||
|
vendor/
|
||||||
|
|||||||
28
Dockerfile
28
Dockerfile
@@ -2,39 +2,31 @@ FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS builder
|
|||||||
|
|
||||||
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
|
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
ARG GIT_TOKEN=""
|
|
||||||
RUN if [ -n "$GIT_TOKEN" ]; then \
|
|
||||||
git config --global url."https://gitea.ext.ben.io/".insteadOf "ssh://gitea@git.local.ben.io/" && \
|
|
||||||
git config --global --add url."https://gitea.ext.ben.io/".insteadOf "ssh://git.local.ben.io/" && \
|
|
||||||
echo "machine gitea.ext.ben.io login b3nw password ${GIT_TOKEN}" > /root/.netrc && \
|
|
||||||
chmod 600 /root/.netrc; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
COPY pyproject.toml uv.lock ./
|
COPY pyproject.toml uv.lock ./
|
||||||
RUN uv sync --frozen --no-dev --no-install-project
|
COPY vendor/schwab-scraper /tmp/schwab-scraper
|
||||||
|
|
||||||
|
# Install schwab-scraper from vendored source, then all other deps.
|
||||||
|
# We strip the git dependency from pyproject.toml so uv doesn't try to fetch it.
|
||||||
|
RUN uv venv && \
|
||||||
|
uv pip install /tmp/schwab-scraper && \
|
||||||
|
sed -i '/schwab-scraper/d' pyproject.toml && \
|
||||||
|
uv pip install -r pyproject.toml && \
|
||||||
|
uv pip install --upgrade playwright && \
|
||||||
|
rm -rf /tmp/schwab-scraper
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN uv sync --frozen --no-dev
|
|
||||||
|
|
||||||
FROM python:3.12-slim-bookworm
|
FROM python:3.12-slim-bookworm
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
|
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy the environment from the builder
|
|
||||||
COPY --from=builder /app /app
|
COPY --from=builder /app /app
|
||||||
|
|
||||||
# Set up environment variables
|
|
||||||
ENV PATH="/app/.venv/bin:$PATH"
|
ENV PATH="/app/.venv/bin:$PATH"
|
||||||
ENV PORT=8000
|
ENV PORT=8000
|
||||||
|
|
||||||
# Expose the port
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
# Run the server
|
|
||||||
CMD ["python", "server.py"]
|
CMD ["python", "server.py"]
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ dependencies = [
|
|||||||
"fastapi>=0.136.1",
|
"fastapi>=0.136.1",
|
||||||
"greenlet>=3.2.3",
|
"greenlet>=3.2.3",
|
||||||
"pdfplumber>=0.11.4",
|
"pdfplumber>=0.11.4",
|
||||||
"playwright==1.54.0",
|
"playwright>=1.54.0",
|
||||||
"pyee>=13.0.0",
|
"pyee>=13.0.0",
|
||||||
"typing-extensions>=4.14.0",
|
"typing-extensions>=4.14.0",
|
||||||
]
|
]
|
||||||
|
|||||||
37
scripts/build.sh
Executable file
37
scripts/build.sh
Executable file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||||
|
SCRAPER_DIR="/home/b3nw/projects/financial/schwab-scraper"
|
||||||
|
IMAGE="gitea.ext.ben.io/b3nw/schwab-mcp-custom:latest"
|
||||||
|
BUILD_HOST="${BUILD_HOST:-docker-test}"
|
||||||
|
|
||||||
|
cd "$PROJECT_DIR"
|
||||||
|
|
||||||
|
echo "==> Preparing vendor directory..."
|
||||||
|
rm -rf vendor/schwab-scraper
|
||||||
|
mkdir -p vendor/schwab-scraper
|
||||||
|
git -C "$SCRAPER_DIR" archive HEAD | tar -x -C vendor/schwab-scraper
|
||||||
|
|
||||||
|
echo "==> Syncing build context to $BUILD_HOST..."
|
||||||
|
rsync -az --delete \
|
||||||
|
--exclude '.venv' \
|
||||||
|
--exclude '.git' \
|
||||||
|
--exclude '__pycache__' \
|
||||||
|
--exclude 'cookies.json' \
|
||||||
|
--exclude 'config.json' \
|
||||||
|
--exclude '.env' \
|
||||||
|
"$PROJECT_DIR/" "$BUILD_HOST:/tmp/schwab-mcp-build/"
|
||||||
|
|
||||||
|
echo "==> Building Docker image on $BUILD_HOST..."
|
||||||
|
ssh "$BUILD_HOST" "cd /tmp/schwab-mcp-build && docker build -t $IMAGE ."
|
||||||
|
|
||||||
|
echo "==> Pushing image to registry..."
|
||||||
|
ssh "$BUILD_HOST" "docker push $IMAGE"
|
||||||
|
|
||||||
|
echo "==> Cleaning up..."
|
||||||
|
rm -rf vendor/schwab-scraper
|
||||||
|
ssh "$BUILD_HOST" "rm -rf /tmp/schwab-mcp-build"
|
||||||
|
|
||||||
|
echo "==> Done! Image pushed: $IMAGE"
|
||||||
Reference in New Issue
Block a user