Repository navigation
build(repo): package the container, Unraid template and PWA - #20
Conversation
… the password With SELECTS_PASSWORD set, GET /api/health without a session answers only whether the app is up, so a container health check works; the version and schema stay behind the password. The manifest and icons copied from brand/favicon are served without a session, since browsers fetch them without the cookie when installing the app.
The manifest names its id, start_url and scope, and index.html sets the theme color from the background token for light and dark.
The container runs as a non-root user that may not own a mounted folder. Startup now names DATA_DIR and the user and stops, in place of a stack trace.
A multi-stage image on Bun's Debian slim image (glibc, which sharp ships prebuilt binaries for on amd64 and arm64). The UI is built once on the build platform, the server's production dependencies are installed for the target platform with --os and --cpu, and the final stage only copies: the server, its fonts, the login page's tokens and the built UI. It runs as the bun user with /data as its one volume, leaves INSTAGRAM_API unset (fake mode), checks /api/health with Bun and starts Bun as PID 1 so SIGTERM reaches the server. CI builds the image on every pull request and smoke-tests it: health, UI and PWA files, a rendered frame, the password gate, and a clean stop.
A v* tag smoke-tests the image natively on amd64 and arm64 runners, then pushes both platforms to the repository's GitHub Container Registry, tagged with the version and latest, with provenance and an SBOM. Only GITHUB_TOKEN with packages: write is used.
Runs the published image as nobody:users with the data folder on /data, every server variable from .env.example with INSTAGRAM_API defaulting to fake and the secrets masked, and the warnings against exposing the app and against the unverified presigned-link mode.
The README covers the image with docker run and Compose, Unraid, the Meta app, the long-lived token, the bucket with its CORS note, going live with INSTAGRAM_API=live as a deliberate step, and releasing. It warns against exposing the app to the internet and marks private-bucket mode as unverified.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 4 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 837697fe96
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # SELECTS_PASSWORD, INSTAGRAM_API and BUCKET_*; DATA_DIR and PORT are set by the image. | ||
| env_file: selects.env |
There was a problem hiding this comment.
Preserve the container data path in the Compose example
If selects.env is copied from .env.example as instructed above, it contains DATA_DIR=./data. Values from env_file override the image's environment, so the server tries to create /app/data instead of using the mounted /data volume. Since /app is root-owned and the image runs as bun, prepareDataDir rejects this path and the documented Compose setup cannot start. Explicitly set DATA_DIR: /data in the service's environment, or instruct users to remove DATA_DIR from the copied env file.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 6594944: the README says to take only SELECTS_PASSWORD, INSTAGRAM_API and the BUCKET_* lines, and to leave DATA_DIR, PORT and WEB_PORT out.
There was a problem hiding this comment.
4 issues found across 18 files
Confidence score: 3/5
.github/scripts/smoke-test-image.shcan collide with concurrent runs, and its cleanup trap can delete unrelated resources that share the fixed names. Use unique per-run names and limit cleanup to resources created by that run.prepareDataDirinserver/src/data-dir.tscan pass when the directory is writable but an existingselects.dbis not, leaving startup to fail with an uncaughtopenDatabaseerror. Validate the database path or handle that startup error.- The Unraid paths in
README.mdmay direct users with a different share location to prepare the wrong directory. Keep the instructions portable rather than hard-coding host-specific paths. .github/scripts/smoke-test-image.shembeds a reusable container password in a public script. Generate a per-run password instead.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="README.md">
<violation number="1" location="README.md:115">
P3: These Unraid instructions hard-code host-specific `/boot` and `/mnt/user` paths, contrary to the public-repository documentation rule in `AGENTS.md`; users with a different share location can prepare the wrong directory. Refer to the configured template path or Unraid’s template/share UI instead of prescribing absolute host paths.</violation>
</file>
<file name="server/src/data-dir.ts">
<violation number="1" location="server/src/data-dir.ts:11">
P2: `prepareDataDir` checks only the directory, so a writable mount with a non-writable existing `selects.db` still reaches uncaught `openDatabase` failure. Validate the database path or convert that startup error to the same clear DATA_DIR message.</violation>
</file>
<file name=".github/scripts/smoke-test-image.sh">
<violation number="1" location=".github/scripts/smoke-test-image.sh:11">
P2: The smoke test uses fixed Docker names, volumes, and host ports, so concurrent runs can collide; its EXIT trap can also force-delete an unrelated resource with one of those names. Generate unique resource names and dynamically allocate host ports before cleaning them up.</violation>
<violation number="2" location=".github/scripts/smoke-test-image.sh:109">
P3: This public script commits a reusable password for the smoke container. Generate a per-run password instead of embedding `smoke-test-password` in the repository.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| export function prepareDataDir(dataDir: string): string | undefined { | ||
| try { | ||
| mkdirSync(dataDir, { recursive: true }); | ||
| accessSync(dataDir, constants.R_OK | constants.W_OK | constants.X_OK); |
There was a problem hiding this comment.
P2: prepareDataDir checks only the directory, so a writable mount with a non-writable existing selects.db still reaches uncaught openDatabase failure. Validate the database path or convert that startup error to the same clear DATA_DIR message.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At server/src/data-dir.ts, line 11:
<comment>`prepareDataDir` checks only the directory, so a writable mount with a non-writable existing `selects.db` still reaches uncaught `openDatabase` failure. Validate the database path or convert that startup error to the same clear DATA_DIR message.</comment>
<file context>
@@ -0,0 +1,17 @@
+export function prepareDataDir(dataDir: string): string | undefined {
+ try {
+ mkdirSync(dataDir, { recursive: true });
+ accessSync(dataDir, constants.R_OK | constants.W_OK | constants.X_OK);
+ return undefined;
+ } catch {
</file context>
There was a problem hiding this comment.
Left as is. A database file its own user cannot write, inside a folder that user can write, is a broken install the startup error already names by its error.
| set -euo pipefail | ||
|
|
||
| image=${1:?usage: smoke-test-image.sh <image>} | ||
| open=selects-smoke-open |
There was a problem hiding this comment.
P2: The smoke test uses fixed Docker names, volumes, and host ports, so concurrent runs can collide; its EXIT trap can also force-delete an unrelated resource with one of those names. Generate unique resource names and dynamically allocate host ports before cleaning them up.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/scripts/smoke-test-image.sh, line 11:
<comment>The smoke test uses fixed Docker names, volumes, and host ports, so concurrent runs can collide; its EXIT trap can also force-delete an unrelated resource with one of those names. Generate unique resource names and dynamically allocate host ports before cleaning them up.</comment>
<file context>
@@ -0,0 +1,121 @@
+set -euo pipefail
+
+image=${1:?usage: smoke-test-image.sh <image>}
+open=selects-smoke-open
+locked=selects-smoke-locked
+work=$(mktemp -d)
</file context>
There was a problem hiding this comment.
Fixed in 6594944: names are this run's own. The host ports stay fixed: the script runs on a CI runner of its own.
| ### On Unraid | ||
|
|
||
| The template is [unraid/selects.xml](unraid/selects.xml). Save it on the server as | ||
| `/boot/config/plugins/dockerMan/templates-user/my-Selects.xml`, then pick Selects under |
There was a problem hiding this comment.
P3: These Unraid instructions hard-code host-specific /boot and /mnt/user paths, contrary to the public-repository documentation rule in AGENTS.md; users with a different share location can prepare the wrong directory. Refer to the configured template path or Unraid’s template/share UI instead of prescribing absolute host paths.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At README.md, line 115:
<comment>These Unraid instructions hard-code host-specific `/boot` and `/mnt/user` paths, contrary to the public-repository documentation rule in `AGENTS.md`; users with a different share location can prepare the wrong directory. Refer to the configured template path or Unraid’s template/share UI instead of prescribing absolute host paths.</comment>
<file context>
@@ -50,6 +50,170 @@ Six typefaces are bundled, each with its license in `server/fonts`. To use anoth
+### On Unraid
+
+The template is [unraid/selects.xml](unraid/selects.xml). Save it on the server as
+`/boot/config/plugins/dockerMan/templates-user/my-Selects.xml`, then pick Selects under
+**Add Container** in the Docker tab. It runs Selects as `nobody:users` (99:100), the owner Unraid
+gives files in its shares, so photos copied into the inbox over the network can be moved.
</file context>
There was a problem hiding this comment.
Left as is. Those are Unraid's own fixed paths for user templates and the appdata share, which is what an Unraid reader needs; they name no particular machine.
| check "SIGTERM stops the server cleanly" | ||
|
|
||
| # With the password. | ||
| start "$locked" 3001 --env SELECTS_PASSWORD=smoke-test-password |
There was a problem hiding this comment.
P3: This public script commits a reusable password for the smoke container. Generate a per-run password instead of embedding smoke-test-password in the repository.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/scripts/smoke-test-image.sh, line 109:
<comment>This public script commits a reusable password for the smoke container. Generate a per-run password instead of embedding `smoke-test-password` in the repository.</comment>
<file context>
@@ -0,0 +1,121 @@
+check "SIGTERM stops the server cleanly"
+
+# With the password.
+start "$locked" 3001 --env SELECTS_PASSWORD=smoke-test-password
+wait_healthy "$locked"
+base=http://127.0.0.1:3001
</file context>
| start "$locked" 3001 --env SELECTS_PASSWORD=smoke-test-password | |
| start "$locked" 3001 --env "SELECTS_PASSWORD=$(od -An -N16 -tx1 /dev/urandom | tr -d ' \n')" |
There was a problem hiding this comment.
Left as is. It is the password of a container that lives for seconds on a CI runner and holds nothing.
…mage as another user in the smoke test
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6594944cb9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| tags: | | ||
| type=semver,pattern={{version}} |
There was a problem hiding this comment.
Disable automatic latest tagging in the publish job
For a stable version tag, docker/metadata-action automatically includes latest alongside the version: its documentation states that latest is “generated by default (auto mode)” for type=semver. In this workflow, publish passes those tags directly to build-push-action, so latest moves before either platform completes the verify job. If verification fails, users pulling latest still receive the failing image, defeating the explicit promotion gate. Set flavor: latest=false on this metadata step so only the final latest job promotes the verified image.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 646435f: the metadata step sets latest=false, so only the last job moves latest.
There was a problem hiding this comment.
1 issue found across 6 files (changes from recent commits).
Confidence score: 3/5
- In
.github/workflows/release.yml,type=semveralso creates thelatesttag duringpublish, so consumers could pull the image before it passesverify. Setflavor: latest=falseon the metadata step.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".github/workflows/release.yml">
<violation number="1" location=".github/workflows/release.yml:71">
P1: Set `flavor: latest=false` on this metadata step; `type=semver` otherwise adds `latest` during `publish`, before the published image passes `verify`.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 | ||
| with: | ||
| images: ghcr.io/${{ github.repository }} | ||
| # Only the version here: `latest` moves in the last job, once the pushed image is tested. |
There was a problem hiding this comment.
P1: Set flavor: latest=false on this metadata step; type=semver otherwise adds latest during publish, before the published image passes verify.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/workflows/release.yml, line 71:
<comment>Set `flavor: latest=false` on this metadata step; `type=semver` otherwise adds `latest` during `publish`, before the published image passes `verify`.</comment>
<file context>
@@ -67,10 +68,9 @@ jobs:
with:
images: ghcr.io/${{ github.repository }}
- # `latest` only for a release, never for a pre-release such as v1.0.0-rc.1.
+ # Only the version here: `latest` moves in the last job, once the pushed image is tested.
tags: |
type=semver,pattern={{version}}
</file context>
| # Only the version here: `latest` moves in the last job, once the pushed image is tested. | |
| flavor: latest=false | |
| # Only the version here: `latest` moves in the last job, once the pushed image is tested. |
There was a problem hiding this comment.
Fixed in 646435f: the metadata step sets latest=false.
Summary
Closes #11. Part of #1.
/datavolume: a multi-stage build on Bun's Debian slim image, running as a non-root user, with a health check that needs no curl.INSTAGRAM_APIis left unset, so the image starts in fake mode./api/healthand the PWA's manifest and icons answer without the optional password; a read without a session gets only whether the app is up. Everything else stays behind the gate..env.example, fake mode as the default and secrets masked.brand/favicon, themed for light and dark. No service worker: the app is online only.DATA_DIRcannot be written. Decisions are recorded as ADR 0010.Evidence
The image cannot be built where this was written, so this pull request's
imagecheck is its first build and smoke test. The runtime was simulated from exactly the files the final stage copies: it started in fake mode, the health check passed, the UI, manifest and icons were served, a frame rendered with the bundled fonts, and it stopped cleanly on SIGTERM. Typecheck, lint, 548 tests and the build pass locally.Merge Danger
Low for the running app. The release workflow and the arm64 image are proven only by the first version tag, and the Unraid template is untested on Unraid.