7 Commits

Author SHA1 Message Date
f298e4a2a6 fix: resolve heredoc parsing error in deploy-oci Makefile target
All checks were successful
Deploy to OCI / deploy (push) Successful in 51s
Extract inline Dockerfile to Dockerfile.oci and scp it instead of
generating it via heredoc over SSH. Make's line-continuation backslash
was causing the heredoc delimiter to be parsed as 'DEOFnFROM' by the
remote shell, breaking the image build step.
2026-04-09 20:32:23 +00:00
b58ba41458 fix: cap watermark dimensions to prevent RangeError on large files
Some checks failed
Deploy to OCI / deploy (push) Failing after 40s
buildWatermark() calls Array.join() on a lines array whose size is
derived from tile dimensions divided by wmFontSize. For files with very
many lines the codeFontSize (and thus wmFontSize) approaches zero,
making charsPerLine and lineCount astronomically large and blowing past
JS's string length limit.

Fix by:
1. Clamping wmFontSize to a minimum of 1.0 to handle pathologically
   large files.
2. Capping charsPerLine at 400 and lineCount at 150 — the watermark is
   purely decorative so this cap has no visible impact.
2026-04-07 10:56:02 +01:00
f45e842370 fix: use aarch64-linux-musl-gcc linker for cross-compile to musl target
Some checks failed
Deploy to OCI / deploy (push) Failing after 40s
2026-04-07 10:46:34 +01:00
Fam Zheng
720c32c485 ci: use login shell (bash -l) to fix npm PATH on host runner
Some checks failed
Deploy to OCI / deploy (push) Failing after 30s
2026-04-07 10:43:17 +01:00
bd3842f854 ci: use absolute /usr/bin/npm path for host runner
Some checks failed
Deploy to OCI / deploy (push) Failing after 0s
2026-04-07 10:42:29 +01:00
8111812d3b ci: fix PATH for host runner - include /usr/bin and cargo bin
Some checks failed
Deploy to OCI / deploy (push) Failing after 0s
2026-04-07 10:41:27 +01:00
73e05ef0ad ci: fix checkout - replace actions/checkout@v4 with raw git (no node in host runner)
Some checks failed
Deploy to OCI / deploy (push) Failing after 0s
2026-04-07 10:40:36 +01:00
5 changed files with 26 additions and 17 deletions

View File

@@ -8,9 +8,17 @@ on:
jobs:
deploy:
runs-on: self-hosted
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v4
run: |
if [ -d .git ]; then
git fetch origin master && git reset --hard origin/master && git clean -fd
else
git clone ${{ gitea.server_url }}/${{ gitea.repository }} . && git checkout ${{ gitea.sha }}
fi
- name: Install frontend dependencies
run: cd web && npm ci

9
Dockerfile.oci Normal file
View File

@@ -0,0 +1,9 @@
FROM alpine:3.21
RUN apk add --no-cache git ca-certificates
WORKDIR /app
COPY repo-vis-server ./
COPY dist ./web/dist/
ENV PORT=8080
ENV FRONTEND_DIR=./web/dist
EXPOSE 8080
CMD ["./repo-vis-server"]

View File

@@ -39,18 +39,9 @@ deploy-oci: build-arm
ssh $(OCI_HOST) "rm -rf $(OCI_TMP) && mkdir -p $(OCI_TMP)"
scp server/target/$(MUSL_TARGET_ARM)/release/repo-vis-server $(OCI_HOST):$(OCI_TMP)/
cd web && tar czf /tmp/_rv_dist.tar.gz dist && scp /tmp/_rv_dist.tar.gz $(OCI_HOST):$(OCI_TMP)/
scp Dockerfile.oci $(OCI_HOST):$(OCI_TMP)/Dockerfile
@echo "==> Building image on OCI..."
ssh $(OCI_HOST) 'cd $(OCI_TMP) && tar xzf _rv_dist.tar.gz && cat > Dockerfile <<DEOF\n\
FROM alpine:3.21\n\
RUN apk add --no-cache git ca-certificates\n\
WORKDIR /app\n\
COPY repo-vis-server ./\n\
COPY dist ./web/dist/\n\
ENV PORT=8080\n\
ENV FRONTEND_DIR=./web/dist\n\
EXPOSE 8080\n\
CMD ["./repo-vis-server"]\n\
DEOF\n\
ssh $(OCI_HOST) 'cd $(OCI_TMP) && tar xzf _rv_dist.tar.gz && \
sudo docker build -t repo-vis:latest . && \
sudo docker save repo-vis:latest -o /tmp/_rv.tar && \
sudo k3s ctr images import /tmp/_rv.tar'

View File

@@ -1,2 +1,2 @@
[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-gnu-gcc"
linker = "aarch64-linux-musl-gcc"

View File

@@ -302,11 +302,12 @@ export class RepoRenderer {
// Watermark — tiled path text, 45° rotated, slightly larger than code font
if (!tile.watermark) {
const codeFontSize = (d.h / d.lines) * 0.65;
const wmFontSize = codeFontSize * 2.5;
// Clamp wmFontSize to avoid degenerate tiny values on files with huge line counts
const wmFontSize = Math.max(codeFontSize * 2.5, 1.0);
const wmLabel = `${this.repoName}/${d.path}`;
// Estimate how many repetitions to fill the area
const charsPerLine = Math.ceil(Math.max(d.w, d.h) * 1.5 / (wmFontSize * 0.5));
const lineCount = Math.ceil(Math.max(d.w, d.h) * 1.5 / (wmFontSize * 1.5));
// Estimate how many repetitions to fill the area; cap to prevent RangeError on massive tiles
const charsPerLine = Math.min(Math.ceil(Math.max(d.w, d.h) * 1.5 / (wmFontSize * 0.5)), 400);
const lineCount = Math.min(Math.ceil(Math.max(d.w, d.h) * 1.5 / (wmFontSize * 1.5)), 150);
const wmContent = buildWatermark(wmLabel, charsPerLine, lineCount);
const wm = new Text();