Compare commits
3 Commits
612fbe2055
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 4820888ff9 | |||
| bcb4714778 | |||
| 7fec4bc575 |
16
.dockerignore
Normal file
16
.dockerignore
Normal file
@@ -0,0 +1,16 @@
|
||||
.git
|
||||
.github
|
||||
.gitea
|
||||
.venv
|
||||
__pycache__
|
||||
*.py[cod]
|
||||
.pytest_cache
|
||||
.ruff_cache
|
||||
.coverage
|
||||
htmlcov
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
tests
|
||||
.cursor
|
||||
*.plan.md
|
||||
38
.github/workflows/build-docker.yml
vendored
Normal file
38
.github/workflows/build-docker.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
name: Build and Publish Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ secrets.DOCKER_REGISTRY }}
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
${{ secrets.DOCKER_REGISTRY }}/${{ secrets.DOCKER_USERNAME }}/notebook-tools:${{ gitea.sha }}
|
||||
${{ secrets.DOCKER_REGISTRY }}/${{ secrets.DOCKER_USERNAME }}/notebook-tools:latest
|
||||
labels: |
|
||||
org.opencontainers.image.source=${{ gitea.server_url }}/${{ gitea.repository }}
|
||||
org.opencontainers.image.description=Notebook tools — Paperless + llama.cpp OCR API
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
19
Dockerfile
Normal file
19
Dockerfile
Normal file
@@ -0,0 +1,19 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# Production image: uv sync (frozen lockfile), run FastAPI with uvicorn.
|
||||
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV UV_COMPILE_BYTECODE=1 \
|
||||
UV_LINK_MODE=copy
|
||||
|
||||
COPY pyproject.toml uv.lock README.md ./
|
||||
COPY src ./src
|
||||
|
||||
RUN uv sync --frozen --no-dev
|
||||
|
||||
ENV PATH="/app/.venv/bin:$PATH"
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["uvicorn", "notebook_tools.api:app", "--host", "0.0.0.0", "--port", "8080"]
|
||||
45
README.md
45
README.md
@@ -33,6 +33,51 @@ Then open the docs at:
|
||||
|
||||
If other machines still can’t connect, check your macOS firewall and any router/network rules.
|
||||
|
||||
## Docker
|
||||
|
||||
Build and run (pass env via file or `-e`; the app reads `.env` only if you mount it):
|
||||
|
||||
```bash
|
||||
docker build -t notebook-tools:local .
|
||||
docker run --rm -p 8080:8080 --env-file .env notebook-tools:local
|
||||
```
|
||||
|
||||
`LLAMA_BASE_URL` / `PAPERLESS_BASE_URL` must be reachable **from inside the container** (use `host.docker.internal` on Docker Desktop, or your LAN IP, not `127.0.0.1` for services on the host).
|
||||
|
||||
### Docker Compose
|
||||
|
||||
Save as `compose.yaml` (any directory with your `.env`):
|
||||
|
||||
```yaml
|
||||
services:
|
||||
notebook-tools:
|
||||
image: git.danhenry.dev/daniel/notebook-tools:latest
|
||||
ports:
|
||||
- "8080:8080"
|
||||
env_file:
|
||||
- .env
|
||||
# Lets the container reach services bound on the host (e.g. llama on :9292).
|
||||
# Linux: requires Docker 20.10+ / Compose v2; omit on Docker Desktop if already available.
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
```
|
||||
|
||||
```bash
|
||||
docker compose pull && docker compose up
|
||||
```
|
||||
|
||||
Log in to `git.danhenry.dev` first if the registry requires auth: `docker login git.danhenry.dev`.
|
||||
|
||||
For llama running **on the host**, set in `.env`:
|
||||
|
||||
```bash
|
||||
LLAMA_BASE_URL="http://host.docker.internal:9292"
|
||||
```
|
||||
|
||||
`PAPERLESS_BASE_URL` can stay a normal `https://…` URL if the container has network access to it.
|
||||
|
||||
CI: on push to `main`, [.github/workflows/build-docker.yml](.github/workflows/build-docker.yml) builds and pushes using the same secrets pattern as your other Gitea repos (`DOCKER_REGISTRY`, `DOCKER_USERNAME`, `DOCKER_PASSWORD`). For Docker Hub, set `DOCKER_REGISTRY` to `docker.io` (or leave per your runner docs).
|
||||
|
||||
## Example `.env`
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user