mirror of
https://github.com/phantomptr/ps5upload.git
synced 2026-10-19 02:20:02 -05:00
* Implement PS5UPLOAD_BASE_URL environment variable * Format engine Rust sources * Check and remove trailing slash on VITE_BASE_URL * Add base path to logo-square.png * Fix Base URL 404 error * Update Docs * Comment Backend code * fix(engine): clear two latent toolchain-gate failures on current stable Both reproduce on a clean checkout with the engine CI's own commands on current stable Rust; CI only passes today because its cargo cache carries forward lint/compile results from an earlier toolchain, so any cache miss or contributor build fails. - ps5upload-fpkg `free_bytes`: `st.f_bavail as u64 * st.f_frsize as u64` trips clippy `unnecessary_cast` (`-D warnings`) because the statvfs fields are already u64 on Linux. The cast is still needed on macOS, where they are u32, so keep it, silence the lint on the targets where it is a no-op, and use `saturating_mul` so the 32-bit path cannot overflow (the bare `*` would panic in debug). - ps5upload-core fs_ops test: `AtomicU8::try_update` is an unstable library feature (E0658) on current stable, so `cargo test -p ps5upload-core` fails to compile. Switch to the stable `fetch_update`; the call only inspects `.is_ok()`, which is true for both exactly when the closure returns `Some`, so behaviour is unchanged. Verified: `cargo clippy --workspace -- -D warnings` and `cargo test -p ps5upload-core` both pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DtgLppKgEWNbr47WHg1tsu * test(ava1): lane-scaling measurement is checked locally, not on CI `lanes_grow_on_a_link_that_scales_with_them` asserts the governor opens a fourth lane when extra lanes raise throughput through a per-lane cap. That only holds at native speed: a shared CI runner cannot always give the fourth lane the headroom to pay off (3 lanes seen on main, 4+ on the same commit in its PR), and under coverage the instrumented sender stalls the capped 160 MiB transfer outright. Skip the coverage run entirely and the lane-count assertion on CI; the transfer-succeeds assertion still runs everywhere. This is the same fix as PR #389 (identical diff), ported here so this PR's `rust (engine workspace)` job goes green on its own; it no-ops once the base carries either copy. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DtgLppKgEWNbr47WHg1tsu * fix(ava1): a stalled upload cancels its job so the destination frees for a resume When an upload stalls fatally (no frame fits the receiver's window and nothing is sent, received or credited for the stall limit), the sender broke with a Protocol error but, unlike every other fatal exit (ERR_IO, ERR_VERIFY, ERR_CANCELLED), sent the console no JobCancel. The console was never told the job died, so it kept the job alive holding the destination. The next attempt's JobOpen was then refused BUSY ("another transfer is writing to this destination") until its retries ran out — the two failures a user sees back to back: a 600 s credit stall on one attempt, then "stayed busy for 12 retries" on the next. Send a JobCancel (reason ERR_STALLED) before giving up, matching the other fatal paths. The journal and the .ava-part stay, so this frees the destination for a clean resume rather than a conflict. Extends the existing `a_grant_smaller_than_one_group_fails_loudly_instead_of_hanging` test to assert the receiver sees the cancel. This does not change why a console grants a sub-group window and stops returning credit (the stall's root cause is in the console-side AVA1 receiver); it makes the stall tear down cleanly so a retry can recover. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DtgLppKgEWNbr47WHg1tsu * test(ava1): de-flake two C-interop tests that failed CI on timing, not on bugs The gating `rust (engine workspace)` ctest step flaked on a rotating set of timing-sensitive tests under CI load (all pre-existing on main, none caused by this PR). Two of them are now robust: - `a_rate_capped_link_is_reported_as_the_network` (governor.rs): a bottleneck *classification* assertion, meaningful only at native speed. On a shared CI runner the debug sender is slower than the 8 MiB/s cap, so the link is not the sole bottleneck and the label describes the runner, not the code. Add the `CI` arm to the skip guard that already covers the sanitizers and coverage — the same guard its sibling `a_slow_disk_is_reported_as_the_bottleneck` already carries. The transfer-succeeds assertion still runs everywhere. - `lane_killed_mid_chunk_requeues_and_completes` (upload.rs): asserts a data-lane kill never costs the session (`sessions == 1`). It killed "the newest connection" via ChaosProxy, which races onto the control connection right after a reconnect or before the first lane opens — dropping the session and failing the assertion (reproduced on clean main, ~1 in 3 locally). Add `ChaosProxy::kill_newest_lane`, which never targets the control connection (the oldest live one), and use it here. The session now survives the kill by construction; the assertion is unchanged and passed 8/8 locally after the fix. Not a weakening of either test: the first keeps its transfer check and only drops an environment-dependent label on CI (matching the existing sibling); the second still proves a lane kill is absorbed, now without the control-connection race. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DtgLppKgEWNbr47WHg1tsu --------- Co-authored-by: GosDev <39804434+GospelBG@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
112 lines
5.6 KiB
Docker
112 lines
5.6 KiB
Docker
# Full-stack web UI image for ps5upload-engine.
|
|
# Serves the complete React frontend at http://<host>:19113 so any browser
|
|
# on an allowlisted IP can manage a PS5 — no native client required.
|
|
#
|
|
# Build (from the repo root, NOT engine/):
|
|
# docker build -f engine/Dockerfile.webui -t ps5upload-engine-webui .
|
|
#
|
|
# Run (Linux server; engine/compose.yaml does the same):
|
|
# docker run -d --network host -v ps5upload-data:/data -v /srv/pkgs:/pkgs:ro \
|
|
# -e PS5_ADDR=192.168.1.50 \
|
|
# -e PS5UPLOAD_ALLOW_IP=192.168.1.0/24 \
|
|
# ps5upload-engine-webui
|
|
#
|
|
# Then open http://192.168.1.<host>:19113 in a browser on the machine whose
|
|
# IP you set in PS5UPLOAD_ALLOW_IP.
|
|
#
|
|
# DOCKER DESKTOP (macOS/Windows): the engine's loopback guard rejects
|
|
# connections from Docker's NAT bridge. You MUST set PS5UPLOAD_ALLOW_IP to
|
|
# the bridge gateway (usually 172.17.0.1) for port-forwarded connections to
|
|
# work. On Linux, prefer --network host instead. See engine/Dockerfile for
|
|
# full networking details. Note: on macOS/Windows the Docker VM is NAT'd
|
|
# and may not be able to reach the PS5 on your LAN — this is a Docker
|
|
# Desktop limitation, not an engine bug.
|
|
#
|
|
# The image also carries the two PS5 helper ELFs (ps5upload.elf and the DPI
|
|
# install daemon). The browser cannot open a socket to the console's loader
|
|
# or hold those bytes itself, so without them the web UI can install base
|
|
# games but not updates or DLC — the web UI half of #152. Override with
|
|
# PS5UPLOAD_PAYLOAD_DIR if you need to pin different ones.
|
|
#
|
|
# SECURITY: the web UI is UNAUTHENTICATED. Anyone whose IP is in
|
|
# PS5UPLOAD_ALLOW_IP gets full control over your PS5. Only add IPs from
|
|
# your own trusted LAN. Never expose port 19113 to the internet.
|
|
|
|
# ── Stage 1: build the React frontend ────────────────────────────────────────
|
|
FROM node:26-alpine AS frontend
|
|
|
|
# The client at its repo-relative place: the FAQ and Changelog screens bundle
|
|
# ../FAQ.md and ../CHANGELOG.md from the repo root.
|
|
WORKDIR /repo/client
|
|
# Copy only the client package files first so npm ci is cached
|
|
COPY client/package.json client/package-lock.json ./
|
|
RUN npm ci --silent
|
|
|
|
# Now copy the rest of the client source and build
|
|
COPY client/ .
|
|
COPY FAQ.md CHANGELOG.md ../
|
|
ARG PS5UPLOAD_BASE_URL=/
|
|
ENV VITE_BASE_URL=$PS5UPLOAD_BASE_URL
|
|
RUN npm run build:vite
|
|
|
|
# ── Stage 2: build the Rust engine with embedded web UI ──────────────────────
|
|
FROM rust:alpine AS builder
|
|
|
|
# g++ compiles unrar's bundled C++ against musl; musl target links static.
|
|
RUN apk add --no-cache musl-dev g++ make
|
|
|
|
# Keep engine/ and third_party/ at their real repo-relative positions
|
|
# rather than flattening engine/ into /build: the workspace patches
|
|
# `unrar` to ../third_party/unrar (see third_party/unrar/README.md), and
|
|
# flattening puts that path outside the image entirely.
|
|
WORKDIR /build
|
|
COPY engine/ ./engine/
|
|
COPY third_party/ ./third_party/
|
|
# See engine/Dockerfile: build.rs embeds these, and the web UI's update /
|
|
# DLC install is exactly what breaks without them (the web UI half of #152).
|
|
COPY payload/ ./payload/
|
|
WORKDIR /build/engine
|
|
|
|
# Populate the webui/ embed directory from the frontend build output.
|
|
# rust-embed will bake every file in this directory into the binary.
|
|
COPY --from=frontend /repo/client/dist/ ./crates/ps5upload-engine/webui/
|
|
|
|
RUN cargo build --release -p ps5upload-engine --features webui
|
|
|
|
# The runtime image is `scratch`, which has no /tmp and no home: the engine
|
|
# could not stage an uploaded package ("could not create upload dir:
|
|
# Permission denied"), cache artwork, or remember saved servers and install
|
|
# history. Make both here (scratch has no mkdir) and copy them across below.
|
|
# /data is world-writable too (sticky, like /tmp) so a `user:` override in
|
|
# Compose — common on NAS boxes, e.g. `user: "1000:1000"` (#346) — can still
|
|
# write its state there; its owner is the default runtime user.
|
|
RUN mkdir -p /rootfs/tmp /rootfs-data/data && chmod 1777 /rootfs/tmp /rootfs-data/data
|
|
|
|
# ── Stage 3: minimal scratch image ───────────────────────────────────────────
|
|
FROM scratch
|
|
ARG PS5UPLOAD_BASE_URL=/
|
|
COPY --from=builder /build/engine/target/release/ps5upload-engine /ps5upload-engine
|
|
# /tmp: staging for uploaded packages, archive extraction and the like. It
|
|
# is copied as a child of /rootfs because copying a directory applies only
|
|
# its contents: `COPY /rootfs/tmp /tmp` left a 0755 root-owned /tmp and the
|
|
# upload still failed. /data: the engine's home (HOME=/data puts its state in
|
|
# /data/.ps5upload), owned by the runtime user so it is writable.
|
|
COPY --from=builder /rootfs/ /
|
|
COPY --from=builder --chown=65532:65532 /rootfs-data/ /
|
|
ENV HOME=/data TMPDIR=/tmp PS5UPLOAD_BASE_URL=$PS5UPLOAD_BASE_URL
|
|
# Saved servers (with their encrypted credentials), install history, the
|
|
# artwork cache and the backport library live here. Mount a volume on it so
|
|
# they survive a container upgrade: `-v ps5upload-data:/data`.
|
|
VOLUME ["/data"]
|
|
EXPOSE 19113
|
|
# Run as an unprivileged user (65532 = nobody in distroless convention).
|
|
# scratch has no /etc/passwd, so we use a raw numeric UID — the kernel
|
|
# doesn't need a passwd entry to run a process. Port 19113 > 1024 so
|
|
# no CAP_NET_BIND_SERVICE needed.
|
|
USER 65532:65532
|
|
# scratch has no shell or HTTP client, so the engine probes itself:
|
|
# `--healthcheck` exits 0 when GET /api/jobs answers 200 (no PS5 needed).
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
CMD ["/ps5upload-engine", "--healthcheck"]
|
|
ENTRYPOINT ["/ps5upload-engine"]
|