Refresh deploy/ and bin/ from the boilerplate at 09e144d (the release split between the distro and Windows, wsl-setup, the server config, USER 1000, python:3.15-slim) with roledesk's facts put back: no frontend stage, desk, plugins and seed copied, the extras passkeys, embeddings and llm, roles as the table the backup and the importer require, bin/pull.sh and bin/worker.sh with their profile commands, and Install Server.md and Install WSL.md as copies in place of the five old deployment docs
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
83e965dfeb
commit
a1f281a23a
40 files changed
+2226
-1287
No files matched your search
@@ -1,14 +0,0 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Run steps 1, 2 and 3: test/promote, build image, push image.
|
||||
.DESCRIPTION
|
||||
Stops on the first failure. Server deployment is a separate operation --
|
||||
nothing here connects to the server. Git branch publication is optional
|
||||
through -PushBranch.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param([switch] $PushBranch)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
& "$PSScriptRoot/1-test-and-promote.ps1" -PushBranch:$PushBranch
|
||||
& "$PSScriptRoot/2-build-image.ps1"
|
||||
& "$PSScriptRoot/3-push-image.ps1"
|
||||
@@ -1,90 +0,0 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Test the latest local main commit and fast-forward production to it.
|
||||
.DESCRIPTION
|
||||
Uses a fixed commit and an isolated worktree. PushBranch optionally publishes
|
||||
production to origin; without it promotion stays local. Does not run Docker.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param([switch] $PushBranch, [switch] $NoTests)
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
. "$PSScriptRoot/_common.ps1"
|
||||
|
||||
$Source = Setting SOURCE 'main'
|
||||
$Branch = Setting BRANCH 'production'
|
||||
$Python = Setting PYTHON (Join-Path $root '.venv\Scripts\python.exe')
|
||||
|
||||
Push-Location $root
|
||||
try {
|
||||
$commit = git rev-parse --verify "$Source^{commit}"
|
||||
Assert-Ok 'resolve source commit'
|
||||
$commit = $commit.Trim()
|
||||
|
||||
# ------------------------------------------------------- test the commit
|
||||
|
||||
# In a throwaway worktree, not here. The tests then run against exactly the
|
||||
# tree that is about to become production, with none of the working copy's
|
||||
# uncommitted edits in the way. Worktrees have no .venv of their own, so the
|
||||
# interpreter comes from the main checkout and the code from the worktree.
|
||||
#
|
||||
# A checkout inside WSL has a Linux .venv, so there the same steps run in
|
||||
# the distro through deploy/test-commit.sh.
|
||||
if (-not $NoTests -and $Wsl.Success) {
|
||||
Write-Step "tests on $Source, in WSL $($Wsl.Groups[1].Value)"
|
||||
wsl.exe -d $Wsl.Groups[1].Value --cd (ConvertTo-LinuxPath $root) -- sh deploy/test-commit.sh $commit
|
||||
Assert-Ok 'tests'
|
||||
} elseif (-not $NoTests) {
|
||||
Write-Step "tests on $Source"
|
||||
if (-not (Test-Path $Python)) {
|
||||
throw "no interpreter at $Python - set PYTHON in deploy\release.env"
|
||||
}
|
||||
$base = Join-Path ([IO.Path]::GetTempPath()) ("$Name-test-" + [guid]::NewGuid().ToString('N').Substring(0, 8))
|
||||
$tree = Join-Path $base $Name
|
||||
try {
|
||||
git worktree add --detach $tree $commit | Out-Null
|
||||
Assert-Ok 'git worktree add'
|
||||
Push-Location $tree
|
||||
try {
|
||||
# Your project's checks. A gate that is red for weeks is not a
|
||||
# gate -- it is a flag you learn to type -- so take one out when
|
||||
# it stops meaning anything, and put it back when it is green.
|
||||
#
|
||||
# The starter's dev group is pytest and httpx, so pytest is the
|
||||
# only gate that can run out of the box. Add ruff and mypy to
|
||||
# [dependency-groups] dev in pyproject.toml, then uncomment the
|
||||
# two lines below -- a gate whose tool is not installed fails
|
||||
# every release for a reason that has nothing to do with the code.
|
||||
& $Python -m pytest -q; Assert-Ok 'pytest'
|
||||
# & $Python -m ruff check .; Assert-Ok 'ruff'
|
||||
# & $Python -m mypy --cache-dir (Join-Path $root '.mypy_cache')
|
||||
# Assert-Ok 'mypy'
|
||||
} finally { Pop-Location }
|
||||
} finally {
|
||||
git worktree remove --force $tree 2>$null | Out-Null
|
||||
Remove-ReleaseTemp @($base)
|
||||
}
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------- promote
|
||||
|
||||
# Fast-forward only. If production has commits main does not, that is a
|
||||
# release made from somewhere else, and this stops rather than discarding it.
|
||||
Write-Step "promote $Source -> $Branch"
|
||||
git show-ref --verify --quiet "refs/heads/$Branch"
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
git merge-base --is-ancestor $Branch $commit
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "$Branch is not an ancestor of $Source - it has commits of its own." -ForegroundColor Red
|
||||
throw "look at: git log --oneline $Source..$Branch"
|
||||
}
|
||||
}
|
||||
# Git publication is optional and independent of the image.
|
||||
git branch -f $Branch $commit; Assert-Ok 'git branch -f'
|
||||
|
||||
if ($PushBranch) {
|
||||
git push origin "${commit}:refs/heads/$Branch"
|
||||
Assert-Ok 'publish production branch'
|
||||
}
|
||||
Write-Host "Promoted $Branch to $commit"
|
||||
} finally { Pop-Location }
|
||||
@@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env bash
|
||||
# Test the latest local main commit, fast-forward production to it, and export
|
||||
# it for the image build on Windows.
|
||||
#
|
||||
# bash deploy/1-test-and-promote.sh [--push-branch] [--no-tests]
|
||||
#
|
||||
# Uses a fixed commit and an isolated worktree. --push-branch optionally
|
||||
# publishes production to origin; without it promotion stays local. --no-tests
|
||||
# skips the gates. The export is the production tree in <RELEASE_DIR>/<folder>/<sha>/
|
||||
# and its sha in <RELEASE_DIR>/<folder>/production, RELEASE_DIR defaulting to
|
||||
# release/ beside the checkout. Uncommitted work is never included.
|
||||
set -euo pipefail
|
||||
# shellcheck source=_common.sh
|
||||
. "$(dirname "${BASH_SOURCE[0]}")/_common.sh"
|
||||
|
||||
push_branch=0 no_tests=0
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--push-branch) push_branch=1 ;;
|
||||
--no-tests) no_tests=1 ;;
|
||||
-h|--help) sed -n '2,11p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
||||
*) die "unknown option $arg" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
need_git
|
||||
SOURCE=$(setting SOURCE main)
|
||||
BRANCH=$(setting BRANCH production)
|
||||
PYTHON=$(setting PYTHON "$root/.venv/bin/python")
|
||||
|
||||
cd "$root"
|
||||
commit=$(resolve_commit "$SOURCE" source)
|
||||
|
||||
# ----------------------------------------------------------- test the commit
|
||||
|
||||
# In a throwaway worktree, not here. The tests then run against exactly the tree
|
||||
# that is about to become production, with none of the working copy's
|
||||
# uncommitted edits in the way. test-commit.sh makes the worktree, runs pytest,
|
||||
# ruff, mypy and the client's check in it, and removes it. Worktrees have no
|
||||
# .venv of their own, so the interpreter comes from this checkout.
|
||||
if ((! no_tests)); then
|
||||
step "tests on $SOURCE"
|
||||
run_or_die tests env PYTHON="$PYTHON" sh "$here/test-commit.sh" "$commit"
|
||||
fi
|
||||
|
||||
# ------------------------------------------------------------------- promote
|
||||
|
||||
# Fast-forward only. If production has commits main does not, that is a release
|
||||
# made from somewhere else, and this stops rather than discarding it.
|
||||
step "promote $SOURCE -> $BRANCH"
|
||||
if git show-ref --verify --quiet "refs/heads/$BRANCH"; then
|
||||
if ! git merge-base --is-ancestor "$BRANCH" "$commit"; then
|
||||
echo "$BRANCH is not an ancestor of $SOURCE - it has commits of its own." >&2
|
||||
die "look at: git log --oneline $SOURCE..$BRANCH"
|
||||
fi
|
||||
fi
|
||||
# Git publication is optional and independent of the image.
|
||||
run_or_die 'git branch -f' git branch -f "$BRANCH" "$commit"
|
||||
|
||||
if ((push_branch)); then
|
||||
run_or_die 'publish production branch' git push origin "$commit:refs/heads/$BRANCH"
|
||||
fi
|
||||
echo "Promoted $BRANCH to $commit"
|
||||
|
||||
# -------------------------------------------------------------------- export
|
||||
|
||||
# The image is built on Windows by wslc (2-build-image.ps1), which reads this
|
||||
# folder through \\wsl.localhost. A tree rather than a tar, so Windows has
|
||||
# nothing to unpack. wslc hands the Dockerfile to the builder on stdin, so the
|
||||
# builder only finds the ignore rules at the root of the context:
|
||||
# Dockerfile.dockerignore is copied there as .dockerignore. A tree that exists
|
||||
# for this sha is kept, not rewritten, because wslc can build from a stale view
|
||||
# of a folder deleted and recreated at the same path (microsoft/WSL#41287).
|
||||
# The promote has happened by now; when the export fails, rerun this step.
|
||||
name=$(basename "$root")
|
||||
release=${RELEASE_DIR:-$(dirname "$root")/release}/$name
|
||||
sha=$(git rev-parse --short "$commit") || die 'resolve image tag failed'
|
||||
tree=$release/$sha
|
||||
step "export $BRANCH ($sha) to $tree"
|
||||
mkdir -p -- "$release" 2>/dev/null && [[ -w $release ]] ||
|
||||
die "cannot write $release; $BRANCH is promoted, rerun this step once it is writable"
|
||||
if [[ ! -d $tree ]]; then
|
||||
part=$release/.part-$sha
|
||||
rm -rf -- "$part"
|
||||
mkdir -- "$part"
|
||||
git archive --format=tar "$commit" | tar -x -C "$part" || die 'export failed'
|
||||
if [[ -f $part/deploy/Dockerfile.dockerignore ]]; then
|
||||
cp -- "$part/deploy/Dockerfile.dockerignore" "$part/.dockerignore"
|
||||
fi
|
||||
mv -- "$part" "$tree"
|
||||
fi
|
||||
for old in "$release"/*/; do
|
||||
[[ ${old%/} == "$tree" ]] || rm -rf -- "${old%/}"
|
||||
done
|
||||
printf '%s\n' "$sha" > "$release/production"
|
||||
echo "Exported $tree"
|
||||
+12
-56
@@ -1,57 +1,13 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Build a local Docker image from the committed production branch.
|
||||
.DESCRIPTION
|
||||
Does not test, promote, push Git branches, use SSH, or start a container.
|
||||
The image stays local. Use 3-push-image.ps1 to publish it separately.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
Set-StrictMode -Version Latest
|
||||
# Step 2, on Windows: build the image from the tree step 1 exported, with wslc.
|
||||
# Tags <IMAGE>:<sha> and <IMAGE>:latest. Never pushes; 3-push-image.ps1 does.
|
||||
$ErrorActionPreference = 'Stop'
|
||||
. "$PSScriptRoot/_common.ps1"
|
||||
|
||||
$Image = Setting IMAGE -Required
|
||||
$Branch = Setting BRANCH 'production'
|
||||
$Platform = Setting PLATFORM 'linux/amd64'
|
||||
|
||||
Push-Location $root
|
||||
try {
|
||||
$commit = git rev-parse --verify "$Branch^{commit}"
|
||||
Assert-Ok 'resolve production commit'
|
||||
$commit = $commit.Trim()
|
||||
$sha = (git rev-parse --short $commit).Trim()
|
||||
Assert-Ok 'resolve image tag'
|
||||
$tagged = "${Image}:${sha}"
|
||||
$latest = "${Image}:latest"
|
||||
|
||||
# --------------------------------------------------------------- build
|
||||
|
||||
# `git archive` to a file and unpack it, rather than piping it. A PowerShell
|
||||
# pipeline carries text: it would re-encode a tar stream and hand docker a
|
||||
# corrupted context. Writing the archive out and building from the directory
|
||||
# keeps the same guarantee -- the context is the committed tree and nothing
|
||||
# else -- without a byte going through a pipe.
|
||||
#
|
||||
# The Dockerfile comes out of that same tree, at deploy/Dockerfile, so the
|
||||
# recipe is versioned with the code it builds. Docker reads the ignore rules
|
||||
# from deploy/Dockerfile.dockerignore beside it.
|
||||
|
||||
Write-Step "build $tagged"
|
||||
$ctx = Join-Path ([IO.Path]::GetTempPath()) "$Name-build-$sha"
|
||||
$tar = "$ctx.tar"
|
||||
Remove-ReleaseTemp @($ctx, $tar)
|
||||
New-Item -ItemType Directory -Path $ctx | Out-Null
|
||||
try {
|
||||
git archive --format=tar -o $tar $commit; Assert-Ok 'git archive'
|
||||
tar -xf $tar -C $ctx; Assert-Ok 'tar -xf'
|
||||
$dockerfile = Join-Path $ctx 'deploy/Dockerfile'
|
||||
docker build --platform $Platform -f $dockerfile -t $tagged -t $latest $ctx
|
||||
Assert-Ok 'docker build'
|
||||
docker image ls $Image --format ' {{.Tag}} {{.Size}}'
|
||||
} finally {
|
||||
Remove-ReleaseTemp @($ctx, $tar)
|
||||
}
|
||||
|
||||
Write-Host "Image: $tagged"
|
||||
} finally { Pop-Location }
|
||||
. "$PSScriptRoot\_common.ps1"
|
||||
Assert-Wslc
|
||||
$sha = Get-ReleaseSha
|
||||
$context = Join-Path $Release $sha
|
||||
Write-Host "== build ${Image}:$sha from $context" -ForegroundColor Cyan
|
||||
# -f is a path wslc opens itself, not one inside the context.
|
||||
wslc build -t "${Image}:$sha" -t "${Image}:latest" -f "$context\deploy\Dockerfile" $context
|
||||
if ($LASTEXITCODE -ne 0) { throw "wslc build failed (exit $LASTEXITCODE)" }
|
||||
wslc image list
|
||||
Write-Host "Image: ${Image}:$sha"
|
||||
+19
-35
@@ -1,36 +1,20 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Publish the already-built production image to the registry.
|
||||
.DESCRIPTION
|
||||
Never rebuilds. If the push fails, fix access or connectivity and run this
|
||||
again; the image is already on disk. `docker login` first, with a token
|
||||
that has package-write access.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
Set-StrictMode -Version Latest
|
||||
# Step 3, on Windows: push the image step 2 built, <IMAGE>:<sha> and :latest,
|
||||
# with wslc. Never rebuilds: after a failed push, fix the login and run it again.
|
||||
$ErrorActionPreference = 'Stop'
|
||||
. "$PSScriptRoot/_common.ps1"
|
||||
|
||||
$Image = Setting IMAGE -Required
|
||||
$Branch = Setting BRANCH 'production'
|
||||
|
||||
Push-Location $root
|
||||
try {
|
||||
$commit = git rev-parse --verify "$Branch^{commit}"
|
||||
Assert-Ok 'resolve production commit'
|
||||
$sha = (git rev-parse --short $commit.Trim()).Trim()
|
||||
Assert-Ok 'resolve image tag'
|
||||
$tagged = "${Image}:${sha}"
|
||||
$latest = "${Image}:latest"
|
||||
docker image inspect $tagged --format '{{.Id}}' | Out-Null
|
||||
Assert-Ok "find local $tagged (run step 2 first)"
|
||||
# latest must name this candidate, even if another image was built since.
|
||||
docker tag $tagged $latest
|
||||
Assert-Ok 'tag latest image'
|
||||
docker push $tagged
|
||||
Assert-Ok 'push commit image'
|
||||
docker push $latest
|
||||
Assert-Ok 'push latest image'
|
||||
Write-Host "Published $tagged and $latest"
|
||||
} finally { Pop-Location }
|
||||
. "$PSScriptRoot\_common.ps1"
|
||||
Assert-Wslc
|
||||
$sha = Get-ReleaseSha
|
||||
wslc image inspect "${Image}:$sha" | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) { throw "no local ${Image}:$sha - run step 2 first" }
|
||||
# latest must name this candidate, even if another image was built since.
|
||||
wslc tag "${Image}:$sha" "${Image}:latest"
|
||||
if ($LASTEXITCODE -ne 0) { throw "wslc tag failed (exit $LASTEXITCODE)" }
|
||||
foreach ($tag in $sha, 'latest') {
|
||||
Write-Host "== push ${Image}:$tag" -ForegroundColor Cyan
|
||||
wslc push "${Image}:$tag"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "If the push was refused: wslc login $(($Image -split '/')[0]) -u <user>, with a token that has package-write access" -ForegroundColor Yellow
|
||||
throw "wslc push ${Image}:$tag failed (exit $LASTEXITCODE)"
|
||||
}
|
||||
}
|
||||
Write-Host "Published ${Image}:$sha and ${Image}:latest"
|
||||
+50
-16
@@ -1,21 +1,28 @@
|
||||
# A Python app, for a server rather than a laptop.
|
||||
#
|
||||
# Two stages so the runtime carries no build tooling: `uv` resolves and
|
||||
# installs into /app/.venv, and the second stage copies that venv and the
|
||||
# source next to it. The install is deliberately editable, which matters if
|
||||
# the app reads a file from beside its package (an example config, a template
|
||||
# directory): that path is true in a checkout and true here, and false in
|
||||
# site-packages.
|
||||
# installs into /app/.venv, and the second stage copies the venv and the source
|
||||
# next to it. The install is deliberately editable, which matters because the
|
||||
# app reads files from beside its package (templates, `app/static`, `seed/`):
|
||||
# that path is true in a checkout and true here, and false in site-packages.
|
||||
# Ours: roledesk has no `frontend/` and no Node stage, since the server renders
|
||||
# Jinja templates and serves `app/static` as it is.
|
||||
#
|
||||
# Already in place at deploy/Dockerfile, with its ignore file beside it.
|
||||
# 2-build-image.ps1 reads it out of a `git archive` of the production commit,
|
||||
# so the recipe is versioned with the code it builds.
|
||||
# 2-build-image.ps1 builds with it from the `git archive` of the production
|
||||
# commit that step 1 exports, so the recipe is versioned with the code it builds.
|
||||
#
|
||||
# The package is `app` and stays `app` — a project started from this repo
|
||||
# renames nothing. Edit the two `uv sync` lines when you add extras.
|
||||
# The package is `app` and stays `app` (the domain noun is `role`). Edit the
|
||||
# two `uv sync` lines when you add extras.
|
||||
#
|
||||
# Each base image is pinned by tag and digest: the tag says which release, the
|
||||
# digest makes a rebuild next month install the same bytes. The digest is the
|
||||
# multi-platform index's. To move on, look up the new tag's digest on its
|
||||
# registry (Docker Hub's tag API for python, ghcr.io for uv) and
|
||||
# replace both halves.
|
||||
|
||||
ARG PYTHON=3.14-slim
|
||||
ARG UV=0.9.17
|
||||
ARG PYTHON=3.15-slim@sha256:2da676046630d7bf14c6764ae1143dc7fa0377a53f94bf5a642f0b214aca5bce
|
||||
ARG UV=0.13.1@sha256:4a1f3666816dafadd20ceb71eac9a7d56d7ef30279f7d64048519ab901ada336
|
||||
|
||||
FROM ghcr.io/astral-sh/uv:${UV} AS uv
|
||||
|
||||
@@ -32,22 +39,38 @@ WORKDIR /app
|
||||
|
||||
# Dependencies first and on their own layer, keyed on the lock file alone, so
|
||||
# editing a Python file rebuilds in seconds rather than re-resolving the tree.
|
||||
# The extras are the same on both `uv sync` lines: `passkeys`, without which
|
||||
# the passkey routes answer 501, `embeddings`, the default ranking backend
|
||||
# (torch comes from the CPU index named in pyproject.toml, [tool.uv.sources],
|
||||
# not the CUDA build; the model itself is downloaded by the first `embed` job
|
||||
# into HOME, which is the /data volume), and `llm`, the SDKs the compose file
|
||||
# passes keys for.
|
||||
COPY pyproject.toml uv.lock README.md ./
|
||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
uv sync --frozen --no-dev --no-install-project
|
||||
uv sync --frozen --no-dev --no-install-project \
|
||||
--extra passkeys --extra embeddings --extra llm
|
||||
|
||||
COPY app app
|
||||
# The two module folders this repo ships beside the app, here and again in the
|
||||
# runtime stage below. `pyproject.toml` lists `pipeline*` and `auth*` in its
|
||||
# packages as well, or the install leaves them out.
|
||||
# The module folders this repo ships beside the app, here and again in the
|
||||
# runtime stage below. `pyproject.toml` lists `pipeline*`, `auth*`, `llm*` and
|
||||
# `desk*` in its packages as well, or the install leaves them out.
|
||||
COPY pipeline pipeline
|
||||
# The door. A project that does not want one drops this line *and* the
|
||||
# `auth.connect` call in `app/main.py` together: dropping the folder and
|
||||
# leaving the call is a container that fails at startup, and dropping the call
|
||||
# and leaving the folder is a container that starts with the door open.
|
||||
COPY auth auth
|
||||
# The model call. Nothing imports it until an app adds its SDKs, and then the
|
||||
# folder has to be here already, so that is not a Dockerfile edit.
|
||||
COPY llm llm
|
||||
# Ours: the source contract and the generic desk modules, the plugin folder the
|
||||
# config's `plugin_paths` names, and the data a first run imports (`seed/`).
|
||||
COPY desk desk
|
||||
COPY plugins plugins
|
||||
COPY seed seed
|
||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
uv sync --frozen --no-dev
|
||||
uv sync --frozen --no-dev \
|
||||
--extra passkeys --extra embeddings --extra llm
|
||||
|
||||
# ---------------------------------------------------------------- runtime
|
||||
|
||||
@@ -69,6 +92,10 @@ COPY pipeline pipeline
|
||||
# The login page and the two scripts are files inside this folder, served from
|
||||
# routes; see the build stage above.
|
||||
COPY auth auth
|
||||
COPY llm llm
|
||||
COPY desk desk
|
||||
COPY plugins plugins
|
||||
COPY seed seed
|
||||
|
||||
ENV PATH=/app/.venv/bin:$PATH \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
@@ -79,6 +106,13 @@ ENV PATH=/app/.venv/bin:$PATH \
|
||||
# /data, and a CLI the app shells out to — the `claude` binary, for one —
|
||||
# wants somewhere to write. An image-baked /home/app would be right for uid
|
||||
# 1000 and unwritable for anyone else.
|
||||
#
|
||||
# The image runs as 1000:1000, the compose file's default PUID:PGID and the
|
||||
# owner docs/Install Server.md gives the data folder, so a `docker run` without a
|
||||
# `user:` does not write root-owned files into it. /data is made here, before
|
||||
# VOLUME, so an anonymous volume starts out owned by that uid too.
|
||||
RUN install -d -o 1000 -g 1000 /data /data/home
|
||||
USER 1000:1000
|
||||
VOLUME /data
|
||||
|
||||
EXPOSE 8787
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
# Named for the Dockerfile beside it: Docker reads `<dockerfile>.dockerignore`
|
||||
# before falling back to one at the root of the context, which is how the ignore
|
||||
# rules get to live next to the recipe they belong to instead of at the top of
|
||||
# the repository.
|
||||
# Named for the Dockerfile beside it. Docker reads `<dockerfile>.dockerignore`
|
||||
# before falling back to one at the root of the context, but wslc hands the
|
||||
# Dockerfile to the builder on stdin, which leaves only the root one: step 1
|
||||
# (1-test-and-promote.sh) copies this file to `.dockerignore` at the root of
|
||||
# the tree it exports, so the rules still live next to the recipe here.
|
||||
#
|
||||
# 2-build-image.ps1 already hands docker a context extracted from `git archive`,
|
||||
# so the untracked heavyweights below are not there to exclude. They are listed
|
||||
# for the other way in — `docker build -f deploy/Dockerfile .` from a checkout —
|
||||
# where .venv alone can be several hundred megabytes.
|
||||
# That tree is a `git archive` of the production commit, so the untracked
|
||||
# heavyweights below are not there to exclude. They are listed for the other
|
||||
# way in, `docker build -f deploy/Dockerfile .` from a checkout, where .venv
|
||||
# alone can be several hundred megabytes.
|
||||
.git
|
||||
.venv
|
||||
.claude
|
||||
@@ -19,6 +20,7 @@ docs
|
||||
# per folder, so a fourth module is a fourth line here.
|
||||
tests
|
||||
pipeline/tests
|
||||
llm/tests
|
||||
auth/tests
|
||||
|
||||
__pycache__
|
||||
|
||||
+45
-21
@@ -1,52 +1,76 @@
|
||||
# Deploy
|
||||
|
||||
Everything needed to put this app on the rittershofer.org box behind SWAG: build an image on Windows, publish it to Gitea, run it as one more service in the compose file that already runs the proxy, back up its database, and give it a password that survives being on the open internet.
|
||||
Everything needed to put roledesk on a server behind SWAG ([../docs/Install Server.md](../docs/Install%20Server.md) is the box it was written for, a copy of the boilerplate's file): test it in WSL, build an image on Windows with `wslc`, publish it to Gitea, run it as one more service in the compose file that already runs the proxy, back up its database, and give it a password that survives being on the open internet.
|
||||
|
||||
Extracted from newsdesk, which is the worked example — every decision here has been run in production at least once, and the comments say why rather than what.
|
||||
This folder is a downstream copy of `../boilerplate/deploy` (commit 09e144d), refreshed with `git archive`; a fix to a shared script lands upstream first. roledesk's own facts are put back after a refresh: the Dockerfile without a frontend stage and with `desk`, `plugins`, `llm` and `seed`, the extras `passkeys`, `embeddings` and `llm`, our image name in `release.env.example`, `server/config.example.yaml` for roledesk's keys, `TABLES` and `REQUIRED_TABLES` naming `roles`, and `bin/pull.sh` and `bin/worker.sh`. `tests/test_deploy.py` pins them.
|
||||
|
||||
**It is already in place.** Nothing has to be copied and nothing has to be renamed: the package is `app`, the environment variables are `APP_`, and the files below are where the scripts expect them. `<app>` in the docs is your *service's* name — the hostname, the data directory, the image tag, the compose service — and it is the one thing you choose.
|
||||
The package is `app`, and the files below are where the scripts expect them: the `APP_` variables, the compose service `app` and the hostname `app.example.com` in the templates are placeholders for the server, and `<app>` in the docs is the service's name: the hostname, the data directory, the image tag, the compose service. The domain noun is `role`, so "job" only ever means queued work.
|
||||
|
||||
## Where each file is
|
||||
|
||||
| Here | | |
|
||||
|---|---|---|
|
||||
| `deploy/*.ps1` | the release scripts, run on Windows | |
|
||||
| `deploy/Dockerfile` | read out of the archived commit by step 2 | copies `app`, `pipeline` and `auth` |
|
||||
| `deploy/Dockerfile.dockerignore` | Docker finds it by that name | |
|
||||
| `deploy/1-test-and-promote.sh`, `test-commit.sh`, `_common.sh`, `db.sh` | the gate, the export and the database moves, run in the WSL distro | |
|
||||
| `deploy/2-build-image.ps1`, `3-push-image.ps1`, `_common.ps1` | the image build and push, run on Windows with `wslc` | the distro is a sealed sandbox and does not hold a container socket |
|
||||
| `deploy/wsl-setup.cmd`, `wsl-setup.ps1` | the profile commands, written once per checkout on Windows | |
|
||||
| `bin/backend.sh`, `check.sh`, and ours `pull.sh`, `worker.sh` | the dev commands, run in the WSL distro: the backend, the gate on the working tree, a pull, the worker | |
|
||||
| `.run/serve`, `pull`, `worker` | PyCharm run configurations, left as they are | `serve --reload` = `bin/backend.sh --reload` = `<folder>-backend --reload`; `pull` = `bin/pull.sh` = `<folder>-pull`; `worker` = `bin/worker.sh` = `<folder>-worker` |
|
||||
| `deploy/Dockerfile` | read out of the tree step 1 exports, by step 2 | no frontend stage; copies `app`, `pipeline`, `auth`, `llm`, `desk`, `plugins` and `seed` |
|
||||
| `deploy/Dockerfile.dockerignore` | copied to `.dockerignore` at the root of the exported tree | `wslc` streams the Dockerfile, so only a root ignore file applies |
|
||||
| `deploy/server/*` | committed here, then installed on the server | |
|
||||
| `deploy/server/compose.yaml` | to `/srv/swag/docker-compose.yml`, as one `services:` block | |
|
||||
| `deploy/server/env.example` | to `/srv/swag/.env`, as appended variables, `chmod 600` | |
|
||||
| `deploy/server/config.example.yaml` | to `$APP_DATA/config.yaml`, with the hostname filled in | `deploy.sh` refuses a config without `database` and `auth.enabled` |
|
||||
| `deploy/server/deploy.sh`, `deploy/server/backup.sh` | to `/srv/swag/`, next to the compose file | |
|
||||
| `deploy/server/import.sh`, `deploy/server/import_database.py` | uploaded and run by `db.sh push` | |
|
||||
| `deploy/server/swag/app.subdomain.conf` | to SWAG's `proxy-confs/`, renamed to `<app>.subdomain.conf` | |
|
||||
|
||||
`db.ps1` expects `server/` beside it, which is why `deploy/server/` is committed here as well as installed on the server.
|
||||
`db.sh` expects `server/` beside it, which is why `deploy/server/` is committed here as well as installed on the server.
|
||||
|
||||
**Keep the `.ps1` files to ASCII.** Windows PowerShell 5.1 reads a script without a byte-order mark as Windows-1252, so an em dash becomes three characters ending in a closing quote: the string ends in the middle of itself and the script fails to parse before it runs a line. Write `--`. newsdesk hit this on a comment nobody thought was code, and `tests/test_packaging.py` here holds every script in this folder to it.
|
||||
**Keep every `.ps1` to ASCII.** Windows PowerShell 5.1 reads a script without a byte-order mark as Windows-1252, so an em dash becomes three characters ending in a closing quote: the string ends in the middle of itself and the script fails to parse before it runs a line. Write `--`. newsdesk hit this on a comment nobody thought was code, and `tests/test_packaging.py` here holds every `.ps1` in this folder to it, the release scripts included.
|
||||
|
||||
`wsl-setup.sh` and `wsl-setup.ps1` are the two halves of setting up a checkout that lives in WSL. `wsl-setup.sh` runs in the distro ([../docs/Install WSL.md, Git](../docs/Install%20WSL.md#git)). `wsl-setup.ps1`, or a double-click on `deploy\wsl-setup.cmd`, writes the commands below into the PowerShell profile, with `<folder>` the checkout folder's name (`jobboard` here) or `-Name`. PowerShell 7, the execution policy, `wslc`, the hand-paste fallback and what to check when a command fails are in [../docs/Install WSL.md, PS Profile commands](../docs/Install%20WSL.md#ps-profile-commands).
|
||||
|
||||
| Command | Runs | Does |
|
||||
|---|---|---|
|
||||
| `<folder>-cd` | `Set-Location` | PowerShell into the checkout's folder |
|
||||
| `<folder>-sh` | `wsl.exe` | a shell in the distro, in the checkout |
|
||||
| `<folder>-backend [-v] [--reload]` | bin/backend.sh in WSL | `uv run app serve` on :8790 |
|
||||
| `<folder>-pull [args]` | bin/pull.sh in WSL | `uv run app job pull`, one pull in the foreground (roledesk's) |
|
||||
| `<folder>-worker [args]` | bin/worker.sh in WSL | `uv run app worker`, the queue drained with no web app (roledesk's) |
|
||||
| `<folder>-check` | bin/check.sh in WSL | the gate on the working tree, without promoting |
|
||||
| `<folder>-1test [--push-branch] [--no-tests]` | deploy/1-test-and-promote.sh in WSL | test local main, fast-forward `production`, export it |
|
||||
| `<folder>-2build` | deploy\2-build-image.ps1 on Windows | build the exported tree with `wslc` |
|
||||
| `<folder>-3push` | deploy\3-push-image.ps1 on Windows | push the built image with `wslc` |
|
||||
| `<folder>-0release [--push-branch] [--no-tests]` | the three above | steps 1, 2 and 3 in order, stopping at the first failure |
|
||||
| `<folder>-db pull\|push` | deploy/db.sh in WSL | the database, to and from the server |
|
||||
|
||||
Each command is one line in the profile: `wsl.exe -d <DISTRO> --cd <CHECKOUT> -- bash <script> @args` for the ones that run in the distro, and for steps 2 and 3 the `.ps1` with the execution policy lifted for that run. `DISTRO` and `CHECKOUT` are read from `deploy/release.env` when the setup runs, so rerun it after either changes. `-backend`, `-pull` and `-worker` stay in the foreground until Ctrl-C. The `-0release` to `-3push` names carry the number of the script's file name, so `0<Tab>` after `<folder>-` finds them.
|
||||
|
||||
`.gitignore` already covers `deploy/release.env` and `deploy/backups/`.
|
||||
|
||||
## The docs
|
||||
|
||||
They are one directory up, in [../docs/](../docs), because they are about the hosting rather than about these scripts.
|
||||
They are one directory up, in [../docs/](../docs), because they are about the hosting rather than about these scripts. `Install Server.md` and `Install WSL.md` are copies of the boilerplate's `documentation/` files; the two proposals stay in the boilerplate checkout.
|
||||
|
||||
- **[../docs/hosting.md](../docs/hosting.md)** — what the box is, the seven steps to add a service, what the templates already decide for you, and the things that have already gone wrong on it. Start here for a service that is not on the box yet.
|
||||
- **[../docs/release.md](../docs/release.md)** — the Windows side: `release.env`, the four numbered scripts, what each one refuses to do, and why the tests run in a throwaway worktree.
|
||||
- **[../docs/server.md](../docs/server.md)** — installing, deploying, backups, moving a SQLite database in either direction, rolling back, and what to verify before relying on any of it.
|
||||
- **[../docs/llm-backends.md](../docs/llm-backends.md)** — asking Claude from a deployed app: API key or subscription token, selected by which one is in the environment, with a self-contained reference implementation.
|
||||
- **[../docs/password-protection.md](../docs/password-protection.md)** — one password on a public hostname: the lockout, sessions, passkeys, and how much throttling is actually worth building. `auth/` is the implementation of it.
|
||||
- **[../docs/Install Server.md](../docs/Install%20Server.md)** — what the box is, the seven steps to add a service, what the templates already decide for you, and the things that have already gone wrong on it. Start here for a service that is not on the box yet.
|
||||
- **[../docs/Install Server.md, Publishing a release](../docs/Install%20Server.md#publishing-a-release)** — the release side: `release.env`, the numbered scripts and where each runs, what each one refuses to do, and why the tests run in a throwaway worktree.
|
||||
- **[../docs/Install Server.md, Operating it](../docs/Install%20Server.md#operating-it)** — installing, deploying, backups, moving a SQLite database in either direction, rolling back, and what to verify before relying on any of it.
|
||||
- **[Proposal LLM Backends.md](../../boilerplate/documentation/Proposal%20LLM%20Backends.md)** (boilerplate checkout) — asking Claude from a deployed app: API key or subscription token, selected by which one is in the environment. `llm/` is the implementation of it, see [../llm/README.md](../llm/README.md).
|
||||
- **[Proposal Password Protection.md](../../boilerplate/documentation/Proposal%20Password%20Protection.md)** (boilerplate checkout) — one password on a public hostname: the lockout, sessions, passkeys, and how much throttling is actually worth building. `auth/` is the implementation of it, see [../auth/README.md](../auth/README.md).
|
||||
|
||||
## A new service, in order
|
||||
|
||||
1. DNS, then certificate, then registry login, then data directory — [../docs/hosting.md](../docs/hosting.md).
|
||||
1. DNS, then certificate, then registry login, then data directory — [../docs/Install Server.md](../docs/Install%20Server.md).
|
||||
2. Copy `release.env.example` to `release.env` and fill it in. That is the only file this step touches: everything else is already committed.
|
||||
3. `.\deploy\0-release.ps1` to test, promote, build and publish.
|
||||
4. Install the server files, edit `.env`, `bash deploy.sh` — [../docs/server.md](../docs/server.md).
|
||||
5. Put the model credential in `.env` if the app needs one — [../docs/llm-backends.md](../docs/llm-backends.md).
|
||||
6. Get in, rotate the bootstrap password, register a passkey — [../docs/password-protection.md](../docs/password-protection.md).
|
||||
3. `<folder>-0release` from Windows to test, promote, build and publish. `wslc` and its registry login are on Windows, [../docs/Install Server.md, Publishing a release](../docs/Install%20Server.md#publishing-a-release).
|
||||
4. Install the server files and `config.yaml`, edit `.env`, `bash deploy.sh` — [../docs/Install Server.md, Operating it](../docs/Install%20Server.md#operating-it).
|
||||
5. Put the model credential in `.env` if the app needs one — [../llm/README.md](../llm/README.md).
|
||||
6. Get in, rotate the bootstrap password, register a passkey — [../auth/README.md](../auth/README.md).
|
||||
7. Schedule `backup.sh`, then restore one of its backups somewhere else to prove it works.
|
||||
|
||||
Step 1 of `0-release.ps1` runs `pytest` in a throwaway worktree, with `ruff` and `mypy` commented out beside it: this repository's dev group is pytest and httpx, and a gate whose tool is not installed fails every release for a reason that has nothing to do with the code. Add the tools, then uncomment the gates.
|
||||
Step 1 runs `pytest` in a throwaway worktree through `test-commit.sh`, with `ruff` and `mypy` commented out beside it, as the release has always run. The dev group has both, so uncommenting them is the owner's call: the tree has to pass them first.
|
||||
|
||||
## What this is not
|
||||
|
||||
Not a framework and not a generator: nothing here is imported or extended, it is copied and edited. That is the point — three services with three edited copies beats three services sharing one abstraction that has to be right for all of them. What this repository changes is only *where the copy comes from*: `boilerplate/deploy/` is the source of truth, and news and health hold copies of it.
|
||||
Not a framework: nothing here is imported or extended, it is copied and edited. `boilerplate/deploy/` is the source of truth, and news, health, jobboard and pocketmoney hold copies of it.
|
||||
+22
-66
@@ -1,76 +1,32 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Shared plumbing for the release scripts. Dot-source it; do not run it.
|
||||
|
||||
.DESCRIPTION
|
||||
Dot-sourcing runs in the caller's scope, so everything defined here --
|
||||
$root, $settings, Setting, Assert-Ok, Write-Step, Remove-ReleaseTemp -- is
|
||||
the caller's afterwards. One copy of the release.env reader, because three
|
||||
copies is three places for it to drift.
|
||||
#>
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
# Dot-sourced by 2-build-image.ps1 and 3-push-image.ps1. Reads deploy\release.env
|
||||
# beside it (KEY=VALUE lines, # comments, never run as code) into $Settings,
|
||||
# and works out where step 1 exported the release: release\<folder> beside the
|
||||
# checkout, in the distro, seen from Windows through \\wsl.localhost.
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
#: The repository root, worked out from this file rather than from the working
|
||||
#: directory, so the scripts can be run from anywhere.
|
||||
$root = Split-Path -Parent $PSScriptRoot
|
||||
|
||||
#: A checkout inside WSL, run from Windows as \\wsl.localhost\<distro>\... Its
|
||||
#: .venv is a Linux one, so the steps that run Python hand that part to the
|
||||
#: distro. $Wsl.Groups[1] is the distro; ConvertTo-LinuxPath turns a path under
|
||||
#: the checkout into the distro's own. See docs/wsl.md.
|
||||
$WslPattern = '^\\\\wsl(?:\.localhost|\$)\\([^\\]+)(\\.*)$'
|
||||
$Wsl = [regex]::Match($root, $WslPattern)
|
||||
function ConvertTo-LinuxPath([string] $Path) {
|
||||
[regex]::Match($Path, $WslPattern).Groups[2].Value -replace '\\', '/'
|
||||
}
|
||||
|
||||
function Assert-Ok([string] $What) {
|
||||
if ($LASTEXITCODE -ne 0) { throw "$What failed (exit $LASTEXITCODE)" }
|
||||
}
|
||||
|
||||
function Write-Step([string] $Text) {
|
||||
Write-Host ''
|
||||
Write-Host "== $Text" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
$envFile = Join-Path $PSScriptRoot 'release.env'
|
||||
if (-not (Test-Path $envFile)) {
|
||||
throw "no deploy\release.env - copy deploy\release.env.example and fill it in"
|
||||
}
|
||||
$settings = @{}
|
||||
if (-not (Test-Path $envFile)) { throw "no $envFile - copy release.env.example and fill it in" }
|
||||
$Settings = @{}
|
||||
foreach ($line in Get-Content $envFile) {
|
||||
if ($line -match '^\s*(#|$)') { continue }
|
||||
# A line with no `=` is a typo, not a setting. Say so here rather than
|
||||
# letting it surface later as a null reference three functions away.
|
||||
if ($line -notmatch '=') { throw "release.env: not a KEY=VALUE line: $line" }
|
||||
$key, $value = $line -split '=', 2
|
||||
$settings[$key.Trim()] = $value.Trim().Trim('"')
|
||||
$Settings[$key.Trim()] = "$value".Trim().Trim('"')
|
||||
}
|
||||
|
||||
function Setting([string] $Name, [string] $Default, [switch] $Required) {
|
||||
if ($settings.ContainsKey($Name) -and $settings[$Name]) { return $settings[$Name] }
|
||||
if ($Required) { throw "set $Name in deploy\release.env" }
|
||||
return $Default
|
||||
foreach ($key in 'DISTRO', 'CHECKOUT', 'IMAGE') {
|
||||
if (-not $Settings[$key]) { throw "set $key in $envFile" }
|
||||
}
|
||||
$Image = $Settings.IMAGE
|
||||
$Checkout = $Settings.CHECKOUT.TrimEnd('/')
|
||||
$Release = "\\wsl.localhost\$($Settings.DISTRO)" + ($Checkout -replace '/[^/]+$', '' -replace '/', '\') + '\release\' + ($Checkout -replace '^.*/', '')
|
||||
|
||||
#: What temporary directories this release is allowed to delete. Everything
|
||||
#: below is created by these scripts and named for it.
|
||||
$Name = Setting NAME -Required
|
||||
|
||||
# Only ever deletes a <name>-* entry directly under the temp directory. A
|
||||
# guard, not a convenience: these paths are built by string concatenation and
|
||||
# handed to `Remove-Item -Recurse -Force`, and one empty variable in that
|
||||
# sentence is a very bad afternoon.
|
||||
function Remove-ReleaseTemp([string[]] $Paths) {
|
||||
$tempRoot = [IO.Path]::GetFullPath([IO.Path]::GetTempPath()).TrimEnd('\') + '\'
|
||||
foreach ($path in $Paths) {
|
||||
$resolved = [IO.Path]::GetFullPath($path)
|
||||
if (-not $resolved.StartsWith($tempRoot, [StringComparison]::OrdinalIgnoreCase) -or
|
||||
-not ([IO.Path]::GetFileName($resolved)).StartsWith("$Name-")) {
|
||||
throw "Unsafe release temporary path: $resolved"
|
||||
}
|
||||
if (Test-Path -LiteralPath $resolved) { Remove-Item -LiteralPath $resolved -Recurse -Force }
|
||||
function Assert-Wslc {
|
||||
if (-not (Get-Command wslc -ErrorAction SilentlyContinue)) {
|
||||
throw 'wslc is not on PATH - run wsl --update (WSL 2.9.3 or later), see https://learn.microsoft.com/windows/wsl/tutorials/wsl-containers'
|
||||
}
|
||||
}
|
||||
|
||||
# The tag step 1 exported, from release\<folder>\production.
|
||||
function Get-ReleaseSha {
|
||||
$file = Join-Path $Release 'production'
|
||||
if (-not (Test-Path $file)) { throw "no $file - run step 1 first" }
|
||||
(Get-Content $file -TotalCount 1).Trim()
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
# shellcheck shell=bash
|
||||
# Shared plumbing for the release scripts that run in WSL. Source it; do not
|
||||
# run it.
|
||||
#
|
||||
# Sourcing runs in the caller's shell, so everything defined here ($root,
|
||||
# SETTINGS, setting, require_setting, die, step, run_or_die) is the caller's
|
||||
# afterwards. The Windows half (steps 2 and 3) reads the same release.env with
|
||||
# _common.ps1, which parses the same KEY=VALUE lines. The caller sets
|
||||
# `set -euo pipefail` first.
|
||||
|
||||
#: The directory of these scripts and the repository root above it, worked out
|
||||
#: from this file rather than from the working directory, so the scripts can be
|
||||
#: run from anywhere.
|
||||
here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck disable=SC2034 # read by the scripts that source this file
|
||||
root=$(dirname "$here")
|
||||
|
||||
die() { printf 'error: %s\n' "$*" >&2; exit 1; }
|
||||
|
||||
step() { printf '\n== %s\n' "$*"; }
|
||||
|
||||
# Runs a command and, when it fails, stops with the step's name and its exit
|
||||
# code: `run_or_die 'git archive' git archive ...`.
|
||||
run_or_die() {
|
||||
local what=$1 rc=0
|
||||
shift
|
||||
"$@" || rc=$?
|
||||
((rc == 0)) || die "$what failed (exit $rc)"
|
||||
}
|
||||
|
||||
# --------------------------------------------------------------- release.env
|
||||
|
||||
# Read, not sourced: sourcing would run whatever the file says and would break
|
||||
# on a space in a value. A line is blank, a comment, or KEY=VALUE; anything else
|
||||
# is a typo and is reported here rather than as an empty variable later. Keys
|
||||
# and values are trimmed and surrounding double quotes are dropped. A CRLF file
|
||||
# (saved from a Windows editor) reads the same as an LF one.
|
||||
trim() {
|
||||
local s=$1
|
||||
s=${s#"${s%%[![:space:]]*}"}
|
||||
s=${s%"${s##*[![:space:]]}"}
|
||||
printf '%s' "$s"
|
||||
}
|
||||
|
||||
declare -A SETTINGS=()
|
||||
env_file=$here/release.env
|
||||
[[ -f $env_file ]] || die "no deploy/release.env - copy deploy/release.env.example and fill it in"
|
||||
while IFS= read -r line || [[ -n $line ]]; do
|
||||
line=${line%$'\r'}
|
||||
[[ $line =~ ^[[:space:]]*(#|$) ]] && continue
|
||||
[[ $line == *=* ]] || die "release.env: not a KEY=VALUE line: $line"
|
||||
key=$(trim "${line%%=*}")
|
||||
value=$(trim "${line#*=}")
|
||||
while [[ $value == \"* ]]; do value=${value#\"}; done
|
||||
while [[ $value == *\" ]]; do value=${value%\"}; done
|
||||
SETTINGS[$key]=$value
|
||||
done < "$env_file"
|
||||
unset line key value
|
||||
|
||||
# setting NAME [DEFAULT]: the value, or the default when unset or empty.
|
||||
setting() {
|
||||
local value=${SETTINGS[$1]-}
|
||||
if [[ -n $value ]]; then printf '%s' "$value"; else printf '%s' "${2-}"; fi
|
||||
}
|
||||
|
||||
# require_setting NAME: the value, or a stop naming the missing setting.
|
||||
require_setting() {
|
||||
local value
|
||||
value=$(setting "$1")
|
||||
[[ -n $value ]] || die "set $1 in deploy/release.env"
|
||||
printf '%s' "$value"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------- shared checks
|
||||
|
||||
need_git() {
|
||||
command -v git >/dev/null 2>&1 || die "git is not on PATH"
|
||||
}
|
||||
|
||||
# The commit a branch or ref points at, or a stop saying which one did not
|
||||
# resolve.
|
||||
resolve_commit() {
|
||||
local commit
|
||||
commit=$(git rev-parse --verify "$1^{commit}") || die "resolve $2 commit failed"
|
||||
printf '%s' "$commit"
|
||||
}
|
||||
-150
@@ -1,150 +0,0 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
The database, in both directions.
|
||||
|
||||
.DESCRIPTION
|
||||
push this machine's database -> the server
|
||||
pull a fresh snapshot from the server -> .\backups
|
||||
|
||||
`push` is the one-off at the start: production begins knowing what you
|
||||
already have, rather than starting empty. `pull` is the one you keep
|
||||
running -- on a schedule from the server itself (server\backup.sh under
|
||||
cron) and by hand from here whenever you want the copy somewhere the
|
||||
server is not.
|
||||
|
||||
`push` moves the database and nothing else. It does not stop the app before
|
||||
or start it after: a deployment knows what else is moving and in what order,
|
||||
and this does not. Stop the app on the server first -- the import is a file
|
||||
swap under SQLite's feet and is refused while the app is up. Start it again
|
||||
afterwards.
|
||||
|
||||
Both go through SQLite's own `VACUUM INTO`. The database is in WAL mode, so
|
||||
the .db file on disk is always missing whatever is still in the -wal beside
|
||||
it, and copying the three files with the app running is a race you lose
|
||||
quietly -- a database that opens fine and is short a day's writes.
|
||||
|
||||
After a push the two copies diverge from the first thing written on either.
|
||||
There is no merge for that and this does not pretend there is: pick the one
|
||||
that is authoritative, and use the other read-only or not at all.
|
||||
|
||||
.EXAMPLE
|
||||
.\deploy\db.ps1 push
|
||||
|
||||
.EXAMPLE
|
||||
.\deploy\db.ps1 pull
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateSet('push', 'pull')]
|
||||
[string] $Action,
|
||||
|
||||
# Skip the confirmation before replacing the server's database.
|
||||
[switch] $Yes
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
. "$PSScriptRoot/_common.ps1"
|
||||
Set-Location $root
|
||||
|
||||
$SshHost = Setting SSH_HOST -Required
|
||||
$RemoteDir = Setting REMOTE_DIR -Required
|
||||
# Where the data actually is. Beside the compose file unless APP_DATA put it
|
||||
# under a shared root; then REMOTE_DATA has to say so.
|
||||
$RemoteData = Setting REMOTE_DATA "$RemoteDir/data"
|
||||
$Python = Setting PYTHON (Join-Path $root '.venv\Scripts\python.exe')
|
||||
$LocalDb = Setting LOCAL_DB (Join-Path $root "$Name.db")
|
||||
|
||||
switch ($Action) {
|
||||
|
||||
# ---------------------------------------------------------------- push
|
||||
|
||||
'push' {
|
||||
if (-not (Test-Path $LocalDb)) { throw "no $LocalDb" }
|
||||
|
||||
$stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
|
||||
$snap = Join-Path $root "$Name-$stamp.db.gz"
|
||||
Write-Host "snapshotting $LocalDb"
|
||||
|
||||
# One Python call for both halves. `VACUUM INTO` is the only way to get a
|
||||
# consistent single file out of a WAL database, and Python is already the
|
||||
# thing that has to be here -- PowerShell has no gzip that writes the format
|
||||
# the server's `gunzip` expects.
|
||||
$snapshot = @'
|
||||
import gzip, pathlib, shutil, sqlite3, sys, tempfile
|
||||
source, target = sys.argv[1], pathlib.Path(sys.argv[2])
|
||||
with tempfile.TemporaryDirectory() as work:
|
||||
plain = pathlib.Path(work) / "snapshot.db"
|
||||
db = sqlite3.connect(source)
|
||||
try:
|
||||
db.execute("VACUUM INTO ?", (str(plain),))
|
||||
finally:
|
||||
db.close()
|
||||
with plain.open("rb") as raw, gzip.open(target, "wb") as out:
|
||||
shutil.copyfileobj(raw, out)
|
||||
'@
|
||||
# A checkout inside WSL has a Linux .venv, and SQLite cannot lock a WAL
|
||||
# database through the \\wsl.localhost share, so the snapshot is taken in
|
||||
# the distro. The script goes in on stdin, past both shells.
|
||||
if ($Wsl.Success) {
|
||||
$snapshot | wsl.exe -d $Wsl.Groups[1].Value --cd (ConvertTo-LinuxPath $root) --exec .venv/bin/python - (ConvertTo-LinuxPath $LocalDb) (ConvertTo-LinuxPath $snap)
|
||||
} else {
|
||||
& $Python -c $snapshot $LocalDb $snap
|
||||
}
|
||||
Assert-Ok 'snapshot'
|
||||
' {0:N1} MB' -f ((Get-Item $snap).Length / 1MB) | Write-Host
|
||||
|
||||
try {
|
||||
Write-Host ''
|
||||
Write-Host "This replaces the database on $SshHost with this one." -ForegroundColor Yellow
|
||||
Write-Host 'Anything written there since is gone.' -ForegroundColor Yellow
|
||||
Write-Host 'The app must already be stopped there, and stays stopped after.' -ForegroundColor Yellow
|
||||
if (-not $Yes) {
|
||||
$reply = Read-Host 'go ahead? [y/N]'
|
||||
if ($reply -notmatch '^[yY]') { Write-Host 'stopped.'; return }
|
||||
}
|
||||
|
||||
scp -C $snap "${SshHost}:$RemoteData/incoming.db.gz"; Assert-Ok 'scp database'
|
||||
scp (Join-Path $PSScriptRoot 'server\import_database.py') "${SshHost}:$RemoteDir/import_database.py"
|
||||
Assert-Ok 'scp importer'
|
||||
} finally {
|
||||
Remove-Item -Force $snap -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
# Base64 rather than stdin: PowerShell has no `<` for a native command, and
|
||||
# piping the text would rewrite the script's line endings on the way.
|
||||
$b64 = [Convert]::ToBase64String([IO.File]::ReadAllBytes((Join-Path $PSScriptRoot 'server\import.sh')))
|
||||
ssh $SshHost "echo $b64 | base64 -d | bash -s -- '$RemoteDir'"; Assert-Ok 'import'
|
||||
Write-Host "pushed. The app is still stopped; start it when the rest of"
|
||||
Write-Host 'the deployment is in place:'
|
||||
Write-Host " ssh $SshHost `"cd '$RemoteDir' && docker compose up -d --wait $Name`""
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- pull
|
||||
|
||||
'pull' {
|
||||
$into = Join-Path $root 'backups'
|
||||
New-Item -ItemType Directory -Force -Path $into | Out-Null
|
||||
|
||||
# The server's own copy of backup.sh, not a streamed one. It is the same
|
||||
# script cron runs, it is already there, and it locates its own directory
|
||||
# through BASH_SOURCE -- which is exactly the thing a script read from stdin
|
||||
# does not have. import.sh takes its directory as an argument and so can be
|
||||
# streamed; this one cannot.
|
||||
Write-Host "snapshotting on $SshHost"
|
||||
ssh $SshHost "cd '$RemoteDir' && bash backup.sh"; Assert-Ok 'backup'
|
||||
|
||||
$newest = (ssh $SshHost "ls -1t '$RemoteData'/backups/$Name-*.db.gz | head -1").Trim()
|
||||
Assert-Ok 'listing backups'
|
||||
if (-not $newest) { throw 'no backup appeared on the server' }
|
||||
|
||||
scp -C "${SshHost}:$newest" $into; Assert-Ok 'scp'
|
||||
$file = Split-Path -Leaf $newest
|
||||
Write-Host "backups\$file"
|
||||
Write-Host ''
|
||||
Write-Host 'To read it here, gunzip it, or in Python:'
|
||||
Write-Host " import gzip, shutil; shutil.copyfileobj(gzip.open(r'backups\$file'), open('read-only.db','wb'))"
|
||||
}
|
||||
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
#!/usr/bin/env bash
|
||||
# The database, in both directions.
|
||||
#
|
||||
# bash deploy/db.sh push [--yes] this machine's database -> the server
|
||||
# bash deploy/db.sh pull a fresh snapshot from the server -> backups/
|
||||
#
|
||||
# `push` is the one-off at the start: production begins knowing what you already
|
||||
# have, rather than starting empty. `pull` is the one you keep running, on a
|
||||
# schedule from the server itself (server/backup.sh under cron) and by hand from
|
||||
# here whenever you want the copy somewhere the server is not.
|
||||
#
|
||||
# `push` moves the database and nothing else. It does not stop the app before or
|
||||
# start it after: a deployment knows what else is moving and in what order, and
|
||||
# this does not. Stop the app on the server first; the import is a file swap
|
||||
# under SQLite's feet and is refused while the app is up. Start it again
|
||||
# afterwards.
|
||||
#
|
||||
# Both go through SQLite's own `VACUUM INTO`. The database is in WAL mode, so the
|
||||
# .db file on disk is always missing whatever is still in the -wal beside it, and
|
||||
# copying the three files with the app running is a race you lose quietly: a
|
||||
# database that opens fine and is short a day's writes.
|
||||
#
|
||||
# After a push the two copies diverge from the first thing written on either.
|
||||
# There is no merge for that: pick the one that is authoritative, and use the
|
||||
# other read-only or not at all.
|
||||
#
|
||||
# Settings from release.env: SSH_HOST, REMOTE_DIR and NAME (the compose service)
|
||||
# are required; REMOTE_DATA (default REMOTE_DIR/data), PYTHON and LOCAL_DB
|
||||
# (default the database the app's config names) are not.
|
||||
set -euo pipefail
|
||||
# shellcheck source=_common.sh
|
||||
. "$(dirname "${BASH_SOURCE[0]}")/_common.sh"
|
||||
|
||||
action='' yes=0
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
push|pull) action=$arg ;;
|
||||
--yes) yes=1 ;;
|
||||
-h|--help) sed -n '2,29p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
||||
*) die "unknown option $arg" ;;
|
||||
esac
|
||||
done
|
||||
[[ -n $action ]] || die "say push or pull: bash deploy/db.sh push|pull"
|
||||
|
||||
ssh_host=$(require_setting SSH_HOST)
|
||||
remote_dir=$(require_setting REMOTE_DIR)
|
||||
# Where the data actually is. Beside the compose file unless APP_DATA put it
|
||||
# under a shared root; then REMOTE_DATA has to say so.
|
||||
remote_data=$(setting REMOTE_DATA "$remote_dir/data")
|
||||
name=$(require_setting NAME)
|
||||
python=$(setting PYTHON "$root/.venv/bin/python")
|
||||
cd "$root"
|
||||
|
||||
# ---------------------------------------------------------------------- push
|
||||
|
||||
if [[ $action == push ]]; then
|
||||
[[ -x $python ]] || die "no interpreter at $python - run uv sync --all-extras, or set PYTHON in deploy/release.env"
|
||||
# The file the app writes: `database` in config.yaml (or $APP_CONFIG),
|
||||
# roledesk.db without one, asked of the app from the checkout's root.
|
||||
local_db=$(setting LOCAL_DB)
|
||||
if [[ -z $local_db ]]; then
|
||||
local_db=$("$python" -c 'from app.config import load; print(load().database.absolute())') \
|
||||
|| die "could not read the database path from the app's config; set LOCAL_DB in deploy/release.env"
|
||||
fi
|
||||
[[ -f $local_db ]] || die "no $local_db"
|
||||
|
||||
snap=$root/$name-$(date +%Y%m%d-%H%M%S).db.gz
|
||||
trap 'rm -f -- "$snap"' EXIT
|
||||
echo "snapshotting $local_db"
|
||||
|
||||
# One Python call for both halves: `VACUUM INTO` is the only way to get a
|
||||
# consistent single file out of a WAL database, and it writes the gzip the
|
||||
# server's `gunzip` expects.
|
||||
run_or_die snapshot "$python" -c '
|
||||
import gzip, pathlib, shutil, sqlite3, sys, tempfile
|
||||
source, target = sys.argv[1], pathlib.Path(sys.argv[2])
|
||||
with tempfile.TemporaryDirectory() as work:
|
||||
plain = pathlib.Path(work) / "snapshot.db"
|
||||
db = sqlite3.connect(source)
|
||||
try:
|
||||
db.execute("VACUUM INTO ?", (str(plain),))
|
||||
finally:
|
||||
db.close()
|
||||
with plain.open("rb") as raw, gzip.open(target, "wb") as out:
|
||||
shutil.copyfileobj(raw, out)
|
||||
' "$local_db" "$snap"
|
||||
printf ' %s\n' "$(du -h "$snap" | cut -f1)"
|
||||
|
||||
echo
|
||||
echo "This replaces the database on $ssh_host with this one."
|
||||
echo 'Anything written there since is gone.'
|
||||
echo 'The app must already be stopped there, and stays stopped after.'
|
||||
if ((! yes)); then
|
||||
read -r -p 'go ahead? [y/N] ' reply || reply=''
|
||||
[[ $reply =~ ^[yY] ]] || { echo 'stopped.'; exit 0; }
|
||||
fi
|
||||
|
||||
run_or_die 'scp database' scp -C "$snap" "$ssh_host:$remote_data/incoming.db.gz"
|
||||
run_or_die 'scp importer' scp "$here/server/import_database.py" "$ssh_host:$remote_dir/import_database.py"
|
||||
rm -f -- "$snap"
|
||||
|
||||
# import.sh takes its directory as an argument, so it can be streamed.
|
||||
run_or_die import ssh "$ssh_host" "bash -s -- '$remote_dir'" < "$here/server/import.sh"
|
||||
echo 'pushed. The app is still stopped; start it when the rest of'
|
||||
echo 'the deployment is in place:'
|
||||
echo " ssh $ssh_host \"cd '$remote_dir' && docker compose up -d --wait $name\""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ---------------------------------------------------------------------- pull
|
||||
|
||||
into=$root/backups
|
||||
mkdir -p -- "$into"
|
||||
|
||||
# The server's own copy of backup.sh, not a streamed one: it is the same script
|
||||
# cron runs, and it locates its own directory through BASH_SOURCE, which a
|
||||
# script read from stdin does not have.
|
||||
echo "snapshotting on $ssh_host"
|
||||
run_or_die backup ssh "$ssh_host" "cd '$remote_dir' && bash backup.sh"
|
||||
|
||||
# shellcheck disable=SC2029 # the remote command is meant to expand here
|
||||
newest=$(ssh "$ssh_host" "ls -1t '$remote_data'/backups/$name-*.db.gz | head -1") || die 'listing backups failed'
|
||||
[[ -n $newest ]] || die 'no backup appeared on the server'
|
||||
|
||||
run_or_die scp scp -C "$ssh_host:$newest" "$into/"
|
||||
file=$(basename "$newest")
|
||||
echo "backups/$file"
|
||||
echo
|
||||
echo 'To read it here, gunzip it, or in Python:'
|
||||
echo " import gzip, shutil; shutil.copyfileobj(gzip.open('backups/$file'), open('read-only.db','wb'))"
|
||||
+26
-13
@@ -1,28 +1,41 @@
|
||||
# Copy to release.env beside these scripts and fill it in. Never committed:
|
||||
# it names your registry and, for db.ps1, your server.
|
||||
# Copy to release.env. One file, read by both halves of the release: the bash
|
||||
# scripts (_common.sh), which run in the WSL distro that holds the checkout, and
|
||||
# the PowerShell ones (_common.ps1, wsl-setup.ps1), which run on Windows. Both
|
||||
# read KEY=VALUE lines and neither runs the file as shell, so $HOME and ~ are
|
||||
# not expanded. Local main is the source; fetching is your choice. Never
|
||||
# committed: it names your registry and, for db.sh, your server.
|
||||
#
|
||||
# Local main is the source. Fetching it first is your choice, not the script's.
|
||||
# Where the checkout is: the distro's name and the path inside it, as
|
||||
# docs/Install WSL.md lays them out, with the checkout folder's name last.
|
||||
# wsl-setup.ps1 writes them into the profile commands, and steps 2 and 3 find
|
||||
# step 1's export at \\wsl.localhost\<DISTRO>\<CHECKOUT's parent>\release\<folder>.
|
||||
DISTRO=claudebox
|
||||
CHECKOUT=/home/claude/cboxcode/jobboard
|
||||
|
||||
# The service's name. Used for the image tag, for the temporary directories
|
||||
# these scripts create, and for the database file db.ps1 moves. One word, no
|
||||
# spaces — it ends up in paths.
|
||||
# The compose service, SERVICE in deploy/server/*.sh. Used by db.sh, on the
|
||||
# Linux side, for the snapshot names (<NAME>-<stamp>.db.gz, as backup.sh writes
|
||||
# them) and the start command it prints. One word, no spaces.
|
||||
NAME=app
|
||||
|
||||
# Windows side, used by steps 2 and 3. wslc builds for the machine's own
|
||||
# architecture (linux/amd64 here) and has no --platform.
|
||||
IMAGE=git.rittershofer.org/wolf/app
|
||||
PLATFORM=linux/amd64
|
||||
|
||||
# Linux side, used by step 1: which branch is tested, and which one it promotes.
|
||||
BRANCH=production
|
||||
SOURCE=main
|
||||
|
||||
# Defaults to the checkout's .venv/Scripts/python.exe. Only needed for the
|
||||
# tests in step 1 and for db.ps1's snapshot.
|
||||
# PYTHON=C:/Users/Coolkau/code/app/.venv/Scripts/python.exe
|
||||
# Linux side, used by step 1 and by db.sh's snapshot, in the distro. Defaults to
|
||||
# the checkout's .venv/bin/python (a WSL path, /home/<user>/...).
|
||||
# PYTHON=/home/<user>/cboxcode/jobboard/.venv/bin/python
|
||||
|
||||
# db.ps1 uses SSH. The numbered release scripts never do. REMOTE_DIR is the
|
||||
# db.sh uses SSH. The numbered release scripts never do. REMOTE_DIR is the
|
||||
# directory holding the compose file; REMOTE_DATA is where APP_DATA points,
|
||||
# and defaults to REMOTE_DIR/data when left blank.
|
||||
SSH_HOST=
|
||||
REMOTE_DIR=/srv/swag
|
||||
REMOTE_DATA=/srv/data/app
|
||||
|
||||
# The database this machine pushes, if it is not <root>/<NAME>.db.
|
||||
# LOCAL_DB=C:/Users/Coolkau/code/app/app.db
|
||||
# The database this machine pushes, if it is not the one the app's config names
|
||||
# (`database` in config.yaml, roledesk.db in the checkout without one).
|
||||
# LOCAL_DB=/home/<user>/cboxcode/jobboard/roledesk.db
|
||||
+43
-10
@@ -13,9 +13,26 @@
|
||||
# self-contained and compacted file, and never blocks a writer for long enough
|
||||
# to matter on a database of this size.
|
||||
#
|
||||
# Rename `app` and `APP_DATA` to your service's name.
|
||||
# The database is the one the app's own config names, asked of the app inside
|
||||
# the container, and it is opened read-only, so a path that names no file is
|
||||
# an error rather than a new empty database and a snapshot of nothing.
|
||||
#
|
||||
# SERVICE is the compose service (deploy.sh says why it is here); APP_DATA is
|
||||
# renamed with the other APP_ variables, and `from app.config` with the package.
|
||||
|
||||
SERVICE=app
|
||||
# Tables every database this app writes has: the same set as REQUIRED_TABLES in
|
||||
# import_database.py, which a test holds this line to. A snapshot without one
|
||||
# of them is deleted and the run fails.
|
||||
# Ours: `roles` is app/storage/schema.py's first table, where the boilerplate has `ticks`.
|
||||
TABLES="jobs roles"
|
||||
|
||||
set -euo pipefail
|
||||
# A snapshot is the whole database, so it is owner only whatever the caller's
|
||||
# umask is. This covers the folder made below; the umask inside the container
|
||||
# (set in the snippet) covers the .db, and gzip gives the .gz the mode of the
|
||||
# file it compresses.
|
||||
umask 077
|
||||
cd "${1:-$(dirname "$(readlink -f "$0")")}"
|
||||
|
||||
# Same source of truth as the compose file and deploy.sh.
|
||||
@@ -27,18 +44,34 @@ stamp=$(date +%Y%m%d-%H%M%S)
|
||||
|
||||
mkdir -p "$DATA/backups"
|
||||
|
||||
docker compose exec -T app python -c "
|
||||
import sqlite3
|
||||
db = sqlite3.connect('/data/app.db')
|
||||
db.execute('VACUUM INTO ?', ('/data/backups/app-$stamp.db',))
|
||||
db.close()
|
||||
"
|
||||
gzip -f "$DATA/backups/app-$stamp.db"
|
||||
echo "$DATA/backups/app-$stamp.db.gz $(du -h "$DATA/backups/app-$stamp.db.gz" | cut -f1)"
|
||||
# shellcheck disable=SC2086 # TABLES is a list of words on purpose
|
||||
docker compose exec -T "$SERVICE" python - "$SERVICE-$stamp" $TABLES <<'PY'
|
||||
import os, sqlite3, sys
|
||||
from contextlib import closing
|
||||
from pathlib import Path
|
||||
|
||||
from app.config import load
|
||||
|
||||
os.umask(0o077)
|
||||
name, required = sys.argv[1], set(sys.argv[2:])
|
||||
database = load().database.absolute()
|
||||
snapshot = Path("/data/backups") / f"{name}.db"
|
||||
with closing(sqlite3.connect(f"{database.as_uri()}?mode=ro", uri=True)) as db:
|
||||
db.execute("VACUUM INTO ?", (str(snapshot),))
|
||||
with closing(sqlite3.connect(f"{snapshot.as_uri()}?mode=ro", uri=True)) as db:
|
||||
tables = {row[0] for row in db.execute("SELECT name FROM sqlite_master WHERE type='table'")}
|
||||
missing = sorted(required - tables)
|
||||
if missing:
|
||||
snapshot.unlink()
|
||||
sys.exit(f"{database} has no table {', '.join(missing)}: not this app's database")
|
||||
print(f"snapshot of {database}")
|
||||
PY
|
||||
gzip -f "$DATA/backups/$SERVICE-$stamp.db"
|
||||
echo "$DATA/backups/$SERVICE-$stamp.db.gz $(du -h "$DATA/backups/$SERVICE-$stamp.db.gz" | cut -f1)"
|
||||
|
||||
# Oldest first, everything past KEEP goes. Named by timestamp, so sorting the
|
||||
# names sorts them by age.
|
||||
ls -1 "$DATA"/backups/app-*.db.gz 2>/dev/null \
|
||||
ls -1 "$DATA"/backups/"$SERVICE"-*.db.gz 2>/dev/null \
|
||||
| sort \
|
||||
| head -n -"$KEEP" \
|
||||
| while read -r old; do rm -f "$old"; echo "removed $old"; done
|
||||
@@ -9,7 +9,10 @@
|
||||
# `env.example` to the `.env` next to it, and it is `docker compose up -d app`
|
||||
# from then on — which recreates this container and no other.
|
||||
#
|
||||
# Rename `app` and `APP_` throughout to your service's name.
|
||||
# Rename `app` and `APP_` throughout to your service's name. The service and
|
||||
# `container_name` are the name `SERVICE=` in deploy.sh, backup.sh and
|
||||
# import.sh, `$upstream_app` in the proxy conf and `NAME=` in release.env
|
||||
# repeat; tests/test_deploy.py reads it from this file and holds them to it.
|
||||
|
||||
services:
|
||||
app:
|
||||
@@ -33,12 +36,12 @@ services:
|
||||
# Which model answers, decided here rather than in the image. With
|
||||
# `backend: auto` the API key wins when there is one and the
|
||||
# subscription CLI is the fallback, so filling in ANTHROPIC_API_KEY
|
||||
# later switches it over with no rebuild. See docs/llm-backends.md.
|
||||
# later switches it over with no rebuild. See llm/README.md.
|
||||
CLAUDE_CODE_OAUTH_TOKEN: ${CLAUDE_CODE_OAUTH_TOKEN:-}
|
||||
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
|
||||
# Normally empty. Set it to pin the password — the way back in when a
|
||||
# login is lost — then unset it and recreate to hand control of the
|
||||
# password back to the app. See docs/password-protection.md.
|
||||
# password back to the app. See auth/README.md.
|
||||
APP_PASSWORD: ${APP_PASSWORD:-}
|
||||
|
||||
# No `ports:`. Nothing on the host reaches it; SWAG does, by container
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# The server's config.yaml. Copy it to $APP_DATA/config.yaml, which the
|
||||
# container reads as /data/config.yaml (APP_CONFIG in the Dockerfile), and set
|
||||
# the hostname. deploy.sh refuses a config without `database` or `auth.enabled`.
|
||||
# Every key left out keeps its default; ../../config.example.yaml lists them all.
|
||||
# Ours: the keys are roledesk's (app/config.py); an unknown one is an error.
|
||||
|
||||
server:
|
||||
host: 0.0.0.0 # the container's interface; SWAG is in front of it
|
||||
port: 8787 # the port the proxy conf and the HEALTHCHECK use
|
||||
|
||||
database: /data/roledesk.db # in the volume; /app, the working directory, is not writable
|
||||
|
||||
auth:
|
||||
enabled: always # the lock must not depend on how the process was started
|
||||
secure_cookie: always # auto needs uvicorn to trust X-Forwarded-Proto, which only `app serve` off loopback sets
|
||||
rp_id: app.example.com # the hostname passkeys are bound to; changing it voids every passkey
|
||||
origin: https://app.example.com # what the browser's address bar shows, scheme included
|
||||
|
||||
# Who answers when a stage needs a model (extract, summarise, judge). `auto`
|
||||
# takes ANTHROPIC_API_KEY when the compose file passes one and otherwise the
|
||||
# subscription CLI with CLAUDE_CODE_OAUTH_TOKEN, so switching is an .env edit.
|
||||
# The stages themselves are switched under Settings, Sources, Runs.
|
||||
agent:
|
||||
backend: auto
|
||||
|
||||
# The vectors behind prompt and CV closeness. The model is not in the image:
|
||||
# the first `embed` job downloads it (~460 MB) into HOME, the /data volume, so
|
||||
# it happens once per server and not once per release. Changing it re-embeds.
|
||||
embed:
|
||||
model: intfloat/multilingual-e5-small
|
||||
+27
-10
@@ -1,9 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run on the server, next to the compose file, or with its directory as $1.
|
||||
# No remote shell required: the release scripts on Windows publish an image
|
||||
# No remote shell required: the release scripts publish an image
|
||||
# and stop there, and this is the other half.
|
||||
#
|
||||
# Rename `app` and `APP_DATA` to your service's name.
|
||||
# SERVICE is the compose service, the one name a project renames in these
|
||||
# scripts (README, "Starting a project from it"); the tests read it from
|
||||
# compose.yaml and hold every script to it. APP_DATA is renamed with the other
|
||||
# APP_ variables.
|
||||
SERVICE=app
|
||||
|
||||
set -euo pipefail
|
||||
cd "${1:-$(dirname "$(readlink -f "$0")")}"
|
||||
|
||||
@@ -15,24 +20,36 @@ cd "${1:-$(dirname "$(readlink -f "$0")")}"
|
||||
DATA=$(sed -n 's/^[[:space:]]*APP_DATA=\([^#]*\).*/\1/p' .env | tail -1 | xargs || true)
|
||||
DATA=${DATA:-./data}
|
||||
|
||||
[[ -s "$DATA/config.yaml" ]] || {
|
||||
echo "Install $DATA/config.yaml before deploying." >&2
|
||||
config=$DATA/config.yaml
|
||||
[[ -s $config ]] || {
|
||||
echo "Install $config before deploying, from config.example.yaml beside this script." >&2
|
||||
exit 1
|
||||
}
|
||||
# The two keys whose defaults are wrong in a container: `auth.enabled: auto`
|
||||
# ties the lock to how the process was started, and the default
|
||||
# database is wherever the config file happens to be. Read with grep and awk,
|
||||
# because the host need not have a Python with a YAML parser.
|
||||
if ! grep -Eq '^database:[[:space:]]*[^[:space:]#]' "$config" ||
|
||||
! awk '/^auth:/ { a = 1; next } /^[^[:space:]#]/ { a = 0 }
|
||||
a && /^[[:space:]]+enabled:[[:space:]]*[^[:space:]#]/ { found = 1 }
|
||||
END { exit !found }' "$config"; then
|
||||
echo "$config must set database and auth.enabled; config.example.yaml beside this script has both." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Pull explicitly, here and nowhere else: the compose file has no pull policy,
|
||||
# so starting or importing never fetches an image on its own. A registry
|
||||
# failure must leave the running service alone, not deploy a cache.
|
||||
echo 'Pulling the configured image…'
|
||||
if ! docker compose pull app; then
|
||||
echo 'Image pull failed; app was not restarted.' >&2
|
||||
if ! docker compose pull "$SERVICE"; then
|
||||
echo "Image pull failed; $SERVICE was not restarted." >&2
|
||||
exit 1
|
||||
fi
|
||||
# Use the image just pulled. Do not start or recreate other services in the
|
||||
# file. `--wait` holds until the container's own HEALTHCHECK passes.
|
||||
if ! docker compose up -d --no-deps --pull never --wait --wait-timeout 240 app; then
|
||||
docker compose ps app >&2 || true
|
||||
echo 'Deployment failed. Check docker compose logs app.' >&2
|
||||
if ! docker compose up -d --no-deps --pull never --wait --wait-timeout 240 "$SERVICE"; then
|
||||
docker compose ps "$SERVICE" >&2 || true
|
||||
echo "Deployment failed. Check docker compose logs $SERVICE." >&2
|
||||
exit 1
|
||||
fi
|
||||
docker compose ps app
|
||||
docker compose ps "$SERVICE"
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# chmod 600. Rename APP_ to your service's name throughout.
|
||||
|
||||
APP_IMAGE=git.rittershofer.org/wolf/app
|
||||
APP_IMAGE=registry.example/you/app
|
||||
APP_TAG=latest # follows published images; pin a commit tag for rollback
|
||||
|
||||
# Where the app keeps its database, its config and its backups. Relative to
|
||||
@@ -20,7 +20,7 @@ PGID=1000
|
||||
TZ=Europe/Berlin
|
||||
|
||||
# Which model answers. Set one or the other, not both — see
|
||||
# docs/llm-backends.md for what each one means and what it costs.
|
||||
# llm/README.md for what each one means and what it costs.
|
||||
#
|
||||
# CLAUDE_CODE_OAUTH_TOKEN a year-long token for the Claude subscription, from
|
||||
# `claude setup-token` on a machine you are signed in
|
||||
@@ -34,7 +34,7 @@ ANTHROPIC_API_KEY=
|
||||
# `docker compose logs app`; after that it is the app's Account screen's to
|
||||
# change. Fill this in only to force one — it is the way back in — then empty
|
||||
# it again and recreate, or the Account screen refuses to change what the
|
||||
# environment pins. See docs/password-protection.md.
|
||||
# environment pins. See auth/README.md.
|
||||
APP_PASSWORD=
|
||||
|
||||
# Unlimited until the box has been watched through the heaviest thing the app
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
# Called on the server after uploading incoming.db.gz and import_database.py.
|
||||
# `db.ps1 push` does both and then runs this; by hand it is the same two files
|
||||
# `db.sh push` does both and then runs this; by hand it is the same two files
|
||||
# in the same two places.
|
||||
#
|
||||
# This replaces the database and does nothing else. It does not stop the app
|
||||
# and it does not start it: whoever is running a deployment knows what else is
|
||||
# moving and in what order, and a tool that helpfully restarts things underneath
|
||||
# that is a tool fighting its caller. By hand it is
|
||||
# `docker compose stop app` and `docker compose up -d --wait app` around this.
|
||||
# `docker compose stop app` and `docker compose up -d --wait app` around this,
|
||||
# with SERVICE (deploy.sh says why it is here) in place of app.
|
||||
#
|
||||
# What it will not do is import into a running app. The replacement is a file
|
||||
# swap under SQLite's feet, and the live database is checkpointed first, which
|
||||
# needs every writer gone — `import_database.py` refuses a busy database, and
|
||||
# this refuses an app that is up, because the clearer error is the earlier one.
|
||||
SERVICE=app
|
||||
|
||||
set -euo pipefail
|
||||
cd "${1:?server directory required}"
|
||||
|
||||
@@ -22,14 +25,14 @@ DATA=${DATA:-./data}
|
||||
|
||||
[[ -s "$DATA/incoming.db.gz" && -s import_database.py ]]
|
||||
|
||||
if [[ -n "$(docker compose ps -q --status running app 2>/dev/null)" ]]; then
|
||||
echo 'app is running. Stop it before importing:' >&2
|
||||
echo ' docker compose stop app' >&2
|
||||
if [[ -n "$(docker compose ps -q --status running "$SERVICE" 2>/dev/null)" ]]; then
|
||||
echo "$SERVICE is running. Stop it before importing:" >&2
|
||||
echo " docker compose stop $SERVICE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# The one-off container uses compose's uid and its mounted /data. `--pull
|
||||
# never`: an import runs on the image already here, whatever the installed
|
||||
# compose file says about pulling. Getting a new image is deploy.sh's job.
|
||||
docker compose run --rm --no-deps --pull never -T --entrypoint python app - < import_database.py
|
||||
docker compose run --rm --no-deps --pull never -T --entrypoint python "$SERVICE" - < import_database.py
|
||||
rm -f "$DATA/incoming.db.gz"
|
||||
@@ -1,11 +1,13 @@
|
||||
"""Offline database replacement, run as the compose service's uid.
|
||||
|
||||
The app container must be stopped. Only stdlib is used so this can be sent
|
||||
over stdin to either the old or the new image during a deployment.
|
||||
The app container must be stopped. Sent over stdin to the image on the
|
||||
server, whose working directory is the app's: the database is the one the
|
||||
app's config names (`from app.config` follows the package when it is renamed),
|
||||
and the rest is stdlib, so the old image and the new one both run it.
|
||||
|
||||
Two things to edit for your service: `DATABASE` and `REQUIRED_TABLES`. The
|
||||
table check is what stops a right-shaped-but-wrong database — last project's,
|
||||
or a half-downloaded one — from landing on top of a good one.
|
||||
`REQUIRED_TABLES` is the table check, which stops a right-shaped-but-wrong
|
||||
database (last project's, or a half-downloaded one) from landing on top of a
|
||||
good one. `tests/test_deploy.py` fails when the app stops creating one of them.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -19,13 +21,14 @@ from contextlib import closing
|
||||
from datetime import UTC, datetime
|
||||
from pathlib import Path
|
||||
|
||||
DATABASE = Path("/data/app.db")
|
||||
INCOMING = Path("/data/incoming.db.gz")
|
||||
BACKUPS = Path("/data/backups")
|
||||
|
||||
#: Any one of these missing means this is not our database. Name tables that
|
||||
#: have existed since the first schema, not ones a recent migration added.
|
||||
REQUIRED_TABLES = {"items"}
|
||||
#: have existed since the first schema, not ones a recent migration added:
|
||||
#: `jobs` is the queue's and `roles` is `app/storage/schema.py`'s first table
|
||||
#: (the boilerplate has `ticks`). backup.sh's TABLES is the same set.
|
||||
REQUIRED_TABLES = {"jobs", "roles"}
|
||||
|
||||
|
||||
def replace_database(database: Path, archive: Path, backups: Path) -> Path | None:
|
||||
@@ -73,5 +76,10 @@ def replace_database(database: Path, archive: Path, backups: Path) -> Path | Non
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
saved = replace_database(DATABASE, INCOMING, BACKUPS)
|
||||
from app.config import load
|
||||
|
||||
# The snapshot is the whole database, so it is owner only whatever the
|
||||
# container's umask is; the gzip of it is made under the same mask.
|
||||
os.umask(0o077)
|
||||
saved = replace_database(load().database.absolute(), INCOMING, BACKUPS)
|
||||
print(f"Database replaced; previous snapshot: {saved or 'none (first import)'}")
|
||||
@@ -3,7 +3,7 @@
|
||||
##
|
||||
## The subdomain has to exist before this does anything: add <app> to SWAG's
|
||||
## SUBDOMAINS (or run it with a wildcard cert) and point the DNS record at the
|
||||
## same address as the rest of the stack. See docs/hosting.md.
|
||||
## same address as the rest of the stack. See docs/Install Server.md.
|
||||
|
||||
## Per-IP throttle for the login endpoints, if the app has a password. Declared
|
||||
## here at `http` scope — SWAG includes proxy-confs outside any server block,
|
||||
@@ -15,23 +15,30 @@ server {
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
|
||||
server_name app.rittershofer.org;
|
||||
server_name app.example.com;
|
||||
|
||||
include /config/nginx/ssl.conf;
|
||||
# Put proxy defaults at server scope so location timeouts override them
|
||||
# through inheritance, rather than duplicate directives from proxy.conf.
|
||||
include /config/nginx/proxy.conf;
|
||||
|
||||
# 0 is no limit. Set a real one if strangers can post to this app; leave it
|
||||
# off when the only uploads are yours and can be large.
|
||||
client_max_body_size 0;
|
||||
# nginx buffers a request body to disk before it hands it on, and the login
|
||||
# takes one without a session, so no limit here lets anyone spool gigabytes.
|
||||
# This is small. A route that takes a large upload gets its own
|
||||
# `location = /path { client_max_body_size 0; proxy_request_buffering off;
|
||||
# ... }` above `location /`, with the same proxy lines as below; streaming
|
||||
# the body lets the app refuse a request without a session before nginx
|
||||
# has stored any of it.
|
||||
client_max_body_size 1m;
|
||||
|
||||
# Guessing the password is already pointless if the app locks out after a
|
||||
# handful of wrong answers (see docs/password-protection.md). This is the
|
||||
# handful of wrong answers (see auth/README.md). This is the
|
||||
# cheap half of the rest: attempts are slowed per address, at the proxy,
|
||||
# before they reach the app at all. `burst=5 nodelay` lets a person who
|
||||
# fat-fingers it a few times through immediately and then holds the rate.
|
||||
location ~ ^/login(/passkey)?$ {
|
||||
# `/login/passkey/options` is open and writes a challenge row per call, so
|
||||
# it is throttled with the two routes that check a credential.
|
||||
location ~ ^/login(/passkey(/options)?)?$ {
|
||||
limit_req zone=app_login burst=5 nodelay;
|
||||
limit_req_status 429;
|
||||
|
||||
|
||||
+16
-9
@@ -1,17 +1,24 @@
|
||||
#!/bin/sh
|
||||
# Test one commit in a throwaway worktree, with the checkout's Linux .venv.
|
||||
# 1-test-and-promote.ps1 runs this through wsl.exe when the checkout lives
|
||||
# inside WSL, where the .venv has no Windows python.exe to call. The gates are
|
||||
# the same as in that script; keep the two lists in step.
|
||||
# 1-test-and-promote.sh runs this from the checkout root. PYTHON, when set (the
|
||||
# PYTHON line of release.env), names the interpreter instead of .venv/bin/python.
|
||||
# The gates are this project's: roledesk has no `frontend/`, so there is no npm
|
||||
# step, and ruff and mypy stay commented out as the release has run them so far.
|
||||
# Usage: sh deploy/test-commit.sh <commit> (from the checkout root)
|
||||
# sh deploy/test-commit.sh --here (the working tree as it is, no worktree: bin/check.sh)
|
||||
set -eu
|
||||
root=$(pwd)
|
||||
python="$root/.venv/bin/python"
|
||||
[ -x "$python" ] || { echo "no interpreter at $python - run uv sync" >&2; exit 1; }
|
||||
base=$(mktemp -d /tmp/test-commit-XXXXXXXX)
|
||||
tree="$base/tree"
|
||||
trap 'git -C "$root" worktree remove --force "$tree" 2>/dev/null; rm -rf "$base"' EXIT
|
||||
git worktree add --detach "$tree" "$1" >/dev/null
|
||||
python="${PYTHON:-$root/.venv/bin/python}"
|
||||
[ -x "$python" ] || { echo "no interpreter at $python - run uv sync --all-extras, or set PYTHON in deploy/release.env" >&2; exit 1; }
|
||||
target="${1:?usage: sh deploy/test-commit.sh <commit>|--here}"
|
||||
if [ "$target" = "--here" ]; then
|
||||
tree="$root"
|
||||
else
|
||||
base=$(mktemp -d /tmp/release-test-XXXXXXXX)
|
||||
tree="$base/tree"
|
||||
trap 'git -C "$root" worktree remove --force "$tree" 2>/dev/null; rm -rf "$base"' EXIT
|
||||
git worktree add --detach "$tree" "$target" >/dev/null
|
||||
fi
|
||||
cd "$tree"
|
||||
"$python" -m pytest -q
|
||||
# "$python" -m ruff check .
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
@echo off
|
||||
rem Double-click to write this checkout's short commands, folder-cd to
|
||||
rem folder-3push, into the PowerShell profile. It runs deploy\wsl-setup.ps1
|
||||
rem beside it with PowerShell 7 (pwsh) when installed, else Windows PowerShell;
|
||||
rem the profile it writes is that one's. cmd cannot sit in a \\wsl.localhost
|
||||
rem folder, so the "UNC paths are not supported" line it prints is harmless.
|
||||
rem No rem line here holds a redirection or pipe character: cmd still applies
|
||||
rem them after rem, as dostips.com/forum/viewtopic.php?p=15252 shows.
|
||||
where pwsh >nul 2>nul
|
||||
if %errorlevel%==0 (set shell=pwsh) else (set shell=powershell)
|
||||
%shell% -NoProfile -ExecutionPolicy Bypass -File "%~dp0wsl-setup.ps1" %*
|
||||
echo.
|
||||
echo Open a new PowerShell for the commands to appear.
|
||||
pause
|
||||
@@ -0,0 +1,64 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Once per checkout, on Windows: writes this checkout's short commands into
|
||||
the PowerShell profile. See docs/Install WSL.md.
|
||||
.DESCRIPTION
|
||||
Reads DISTRO and CHECKOUT from deploy\release.env beside this script. The
|
||||
prefix is the checkout folder's name (news-, boilerplate-), or -Name. Writes
|
||||
one marked block into $PROFILE and replaces it when run again.
|
||||
#>
|
||||
param([string] $Name)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$envFile = Join-Path $PSScriptRoot 'release.env'
|
||||
if (-not (Test-Path $envFile)) { throw "no $envFile - copy release.env.example and fill it in" }
|
||||
$settings = @{}
|
||||
foreach ($line in Get-Content $envFile) {
|
||||
if ($line -match '^\s*(#|$)') { continue }
|
||||
$key, $value = $line -split '=', 2
|
||||
$settings[$key.Trim()] = "$value".Trim().Trim('"')
|
||||
}
|
||||
$distro = $settings.DISTRO
|
||||
$checkout = "$($settings.CHECKOUT)".TrimEnd('/')
|
||||
if (-not $distro -or -not $checkout) { throw "set DISTRO and CHECKOUT in $envFile" }
|
||||
if (-not $Name) { $Name = Split-Path -Leaf (Split-Path -Parent $PSScriptRoot) }
|
||||
|
||||
# Replaces the block between the two marker lines, or appends it.
|
||||
function Set-ProfileBlock([string] $Key, [string] $Body) {
|
||||
$path = $PROFILE.CurrentUserCurrentHost
|
||||
$begin = "# >>> $Key >>>"
|
||||
$end = "# <<< $Key <<<"
|
||||
$block = "$begin`r`n$Body`r`n$end"
|
||||
$text = if (Test-Path $path) { [IO.File]::ReadAllText($path) } else { '' }
|
||||
$pattern = '(?s)' + [regex]::Escape($begin) + '.*?' + [regex]::Escape($end)
|
||||
if ($text -match $pattern) {
|
||||
$text = [regex]::Replace($text, $pattern, { $block })
|
||||
} else {
|
||||
$text = $text.TrimEnd() + "`r`n`r`n$block`r`n"
|
||||
}
|
||||
New-Item -ItemType Directory -Force -Path (Split-Path $path) | Out-Null
|
||||
[IO.File]::WriteAllText($path, $text)
|
||||
Write-Host "profile: wrote $Key to $path"
|
||||
}
|
||||
|
||||
$unc = "\\wsl.localhost\$distro" + ($checkout -replace '/', '\')
|
||||
$wsl = "wsl.exe -d $distro --cd $checkout"
|
||||
$ps = "& (Get-Process -Id `$PID).Path -NoProfile -ExecutionPolicy Bypass -File"
|
||||
$lines = @(
|
||||
"function $Name-cd { Set-Location '$unc' }"
|
||||
"function $Name-sh { $wsl }"
|
||||
"function $Name-backend { $wsl -- bash bin/backend.sh @args }"
|
||||
# roledesk's additions: the PyCharm run configurations in .run/, from PowerShell.
|
||||
"function $Name-pull { $wsl -- bash bin/pull.sh @args }"
|
||||
"function $Name-worker { $wsl -- bash bin/worker.sh @args }"
|
||||
"function $Name-check { $wsl -- bash bin/check.sh @args }"
|
||||
"function $Name-1test { $wsl -- bash deploy/1-test-and-promote.sh @args }"
|
||||
"function $Name-2build { $ps '$unc\deploy\2-build-image.ps1' }"
|
||||
"function $Name-3push { $ps '$unc\deploy\3-push-image.ps1' }"
|
||||
"function $Name-0release { $Name-1test @args; if (`$LASTEXITCODE -ne 0) { return }; $Name-2build; if (`$LASTEXITCODE -ne 0) { return }; $Name-3push }"
|
||||
)
|
||||
if (Test-Path (Join-Path $PSScriptRoot 'db.sh')) {
|
||||
$lines += "function $Name-db { $wsl -- bash deploy/db.sh @args }"
|
||||
}
|
||||
Set-ProfileBlock "$Name (deploy/wsl-setup.ps1)" ($lines -join "`r`n")
|
||||
Write-Host 'Open a new PowerShell window to load the profile.'
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
# Once, inside the distro, for a checkout that lives in WSL: line endings, the
|
||||
# Linux .venv, and a test run to prove it works. deploy/wsl-setup.ps1 is the
|
||||
# Windows half. See docs/Install WSL.md, section 9 and Working from Windows.
|
||||
# Usage: sh deploy/wsl-setup.sh (from the checkout root)
|
||||
set -eu
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
|
||||
# Windows Git (PyCharm) has core.autocrlf=true, so it writes CRLF into the
|
||||
# working tree, and Linux Git then reports every line of those files changed.
|
||||
# The repository's own setting wins over the Windows one for both.
|
||||
git config core.autocrlf false
|
||||
if [ -n "$(git diff --ignore-cr-at-eol --name-only)" ]; then
|
||||
echo "uncommitted changes beyond line endings - commit or stash them first:" >&2
|
||||
git diff --ignore-cr-at-eol --stat >&2
|
||||
exit 1
|
||||
fi
|
||||
# Rewrites the CRLF copies with LF. Nothing else differs, checked above.
|
||||
git checkout -- .
|
||||
|
||||
uv sync --all-extras
|
||||
uv run pytest -q
|
||||
Reference in new issue
Block a user