Add typer CLI + production Dockerfile
Context
-------
Closes Phase 0 scaffolding. Image must build and run so infra can
schedule an initial no-op CronJob (the plan's Phase 0 exit criterion)
while Phase 0.5 / 0.75 / 1 land.
This change
-----------
- broker_sync/cli.py: typer app with two commands.
* `version` — prints __version__; used as the no-op CronJob
liveness check.
* `auth-spike` — Phase 0.5 end-to-end live probe: log in to
Wealthfolio, list accounts, exit 0 on success. Credentials read
from env (WF_BASE_URL/USERNAME/PASSWORD) so CronJob + ESO can
inject them without CLI flags.
- Dockerfile: multi-stage, Python 3.12-slim, non-root user 10001
with /data as the shared PVC mount. Poetry virtualenv baked into
/app/.venv, entrypoint is `broker-sync`, default command `version`.
- CLI test via typer.testing.CliRunner.
Test plan
---------
## Automated
- poetry run pytest -q → 32 passed
- poetry run mypy broker_sync tests → Success: no issues found in 19 source files
- poetry run ruff check . → All checks passed!
- poetry run broker-sync version → broker-sync 0.1.0
## Manual Verification
Docker build + run deferred — image will be built via GHA after the
repo is pushed to GitHub in a follow-up session; the pyproject install
has already been verified locally.
This commit is contained in:
parent
e7da408a85
commit
0eb6feefa8
3 changed files with 103 additions and 0 deletions
32
Dockerfile
Normal file
32
Dockerfile
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
FROM python:3.12-slim AS builder
|
||||
|
||||
ENV POETRY_VERSION=1.8.4 \
|
||||
POETRY_HOME=/opt/poetry \
|
||||
POETRY_VIRTUALENVS_IN_PROJECT=true \
|
||||
PIP_NO_CACHE_DIR=1
|
||||
|
||||
RUN pip install --no-cache-dir "poetry==${POETRY_VERSION}"
|
||||
|
||||
WORKDIR /app
|
||||
COPY pyproject.toml poetry.lock ./
|
||||
RUN /opt/poetry/bin/poetry install --only main --no-root
|
||||
|
||||
COPY broker_sync ./broker_sync
|
||||
RUN /opt/poetry/bin/poetry install --only main
|
||||
|
||||
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN useradd --system --uid 10001 --home /app --shell /usr/sbin/nologin broker && \
|
||||
mkdir -p /data && chown -R broker:broker /data
|
||||
|
||||
COPY --from=builder --chown=broker:broker /app /app
|
||||
|
||||
ENV PATH="/app/.venv/bin:${PATH}" \
|
||||
PYTHONUNBUFFERED=1
|
||||
|
||||
USER broker
|
||||
ENTRYPOINT ["broker-sync"]
|
||||
CMD ["version"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue