mirror of
https://github.com/guillaumemeyer/watermarks-remover.git
synced 2026-08-22 13:11:57 +02:00
* feat: split skill from service, add HTTP API and Docker distribution The agent skill (skills/remove-ai-marks/) is now a code-free remote client: all implementation moved to service/scripts/ and runs behind a stdlib HTTP service (server.py) with /health, /capabilities, /inspect, /clean and a dynamically generated OpenAPI 3.0.3 spec at /openapi.json. - Move scripts/ and the backend Dockerfiles under service/ - server.py: JSON/base64 HTTP entrypoint with size caps, binary guard, atomic writes, loopback default, optional bearer auth - Core Dockerfile (exiftool/qpdf/c2patool preinstalled) and a GHCR publish workflow for the core/markllm/markdiffusion images - compose.yaml (wr-* services, harness/heavy profiles) + compose-check.sh to validate the running stack (exit code only) - Fix markllm image build (tokenizers 0.22.2, CPU-only torch) and ctrlregen build (python:3.11 base for the 2023-era research pins) - Fix markllm/markdiffusion harness images missing common.py at runtime * docs: add .env.example and service configuration guide * fix: disable chain-of-thought for openai-compatible Layer B rewrites deepseek-v4-flash is a reasoning model: a one-line paraphrase burned 9,894 reasoning tokens (~100s) and hit the default timeout. Send reasoning_effort=none by default for the openai-compatible backend (--reasoning-effort / WATERMARKS_REWRITE_REASONING_EFFORT; 'off' omits the parameter), cutting the same rewrite to ~1s / 12 tokens. Tested end-to-end against api.deepseek.com. * fix: sanitize client-supplied filename in HTTP service CodeQL 'uncontrolled data in path expression' (server.py): a name like '../../x' flowed into Path(tmpdir) / name, letting an upload escape the request temp dir on write. Sanitize name to its basename in _decode_input (_safe_name) and refuse any joined path whose parent is not the tmpdir at the write sites (_tmp_path). Tests cover traversal names. * chore: gitignore .env (contains local rewrite credentials) * chore: deny-by-default gitignore and dockerignore; document compose env config .gitignore and service/.dockerignore now exclude everything by default and explicitly allow only what is publishable/needed: tracked source, docs, tests, .github, and (for images) the service/scripts/ tree that every Dockerfile COPYs. Root .dockerignore documents that all builds use service/ as context. README Configuration section now covers .env setup for docker compose, host-side export for CLI runs, and the full variable table.
67 lines
2.4 KiB
Docker
67 lines
2.4 KiB
Docker
# Core HTTP service image: text Layer A, file/metadata cleaners, and the
|
|
# optional system tools (exiftool / qpdf / c2patool) those cleaners shell out to.
|
|
#
|
|
# Build from the repository root (build context = service/):
|
|
# docker build -f service/Dockerfile -t watermarks-remover service/
|
|
#
|
|
# Run (HTTP on loopback host port, unprivileged, read-only rootfs):
|
|
# docker run --rm -p 127.0.0.1:8765:8765 \
|
|
# --read-only --tmpfs /tmp \
|
|
# watermarks-remover
|
|
#
|
|
# Any CLI stays runnable by overriding the command:
|
|
# docker run --rm -v "$(pwd):/data" watermarks-remover \
|
|
# /app/scripts/clean_file.py /data/notes.md -o /data/notes.cleaned.md
|
|
#
|
|
# Hardening mirrors the backend images:
|
|
# - base image pinned by digest (no moving tag drift)
|
|
# - c2patool pinned by release tag + sha256
|
|
# - pip pinned (no unpinned bootstrap step)
|
|
# - runs as an unprivileged user (a parser bug in a crafted file can no
|
|
# longer write files as root inside the container)
|
|
|
|
ARG C2PATOOL_VERSION=c2patool-v0.27.15
|
|
ARG C2PATOOL_SHA256=7a035b727a6cdda8ad08d98fe94b3c20febee4aea4e7c1de02571b295730faf0
|
|
ARG VERSION=dev
|
|
|
|
# python:3.14-slim linux/amd64 digest.
|
|
FROM python:3.14-slim@sha256:ce40764625a4ff50df3548277632e7f96c4e77fe75fa848aae9885476e7df5a4
|
|
|
|
ARG C2PATOOL_VERSION
|
|
ARG C2PATOOL_SHA256
|
|
ARG VERSION
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
ca-certificates \
|
|
curl \
|
|
libimage-exiftool-perl \
|
|
passwd \
|
|
qpdf \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN curl -fsSL -o /tmp/c2patool.tar.gz \
|
|
"https://github.com/contentauth/c2pa-rs/releases/download/${C2PATOOL_VERSION}/${C2PATOOL_VERSION}-x86_64-unknown-linux-gnu.tar.gz" \
|
|
&& echo "${C2PATOOL_SHA256} /tmp/c2patool.tar.gz" | sha256sum -c - \
|
|
&& tar -xzf /tmp/c2patool.tar.gz -C /tmp \
|
|
&& install -m 0755 /tmp/c2patool/c2patool /usr/local/bin/c2patool \
|
|
&& rm -rf /tmp/c2patool /tmp/c2patool.tar.gz
|
|
|
|
COPY scripts /app/scripts
|
|
|
|
RUN python3 -m pip install --no-cache-dir "pip==26.2.1"
|
|
|
|
# Unprivileged runtime user. The service only reads request bodies and writes
|
|
# to temp files / stdout, so nothing under /app needs root.
|
|
RUN useradd --create-home --uid 10001 --shell /usr/sbin/nologin remover
|
|
USER remover
|
|
|
|
ENV WATERMARKS_SERVER_VERSION=${VERSION} \
|
|
PYTHONUNBUFFERED=1 \
|
|
PYTHONDONTWRITEBYTECODE=1
|
|
|
|
WORKDIR /app
|
|
EXPOSE 8765
|
|
ENTRYPOINT ["python3"]
|
|
CMD ["/app/scripts/server.py", "--host", "0.0.0.0"]
|