Skip to content

build(repo): package the container, Unraid template and PWA - #20

Merged
brandonnly merged 11 commits into
mainfrom
11-packaging
Nov 13, 2026
Merged

brandonnly merged 11 commits into
mainfrom
11-packaging

Conversation

@brandonnly

@brandonnly brandonnly commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #11. Part of #1.

  • One container image runs the whole app from the /data volume: 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_API is left unset, so the image starts in fake mode.
  • /api/health and 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.
  • CI builds the image on every pull request and smoke-tests it: user, volume, health check, UI, manifest and icons, a rendered frame, the password gate and a clean stop.
  • A version tag publishes the image for amd64 and arm64 to the repository's container registry, after the same smoke test on native runners for both.
  • An Unraid template, with every variable from .env.example, fake mode as the default and secrets masked.
  • The app installs as a PWA from the icons in brand/favicon, themed for light and dark. No service worker: the app is online only.
  • The README walks through running the container, creating the Meta app, generating the token, configuring the bucket and going live, and warns against exposing the app to the internet. Publishing through a presigned link is marked as unverified.
  • Startup says plainly when DATA_DIR cannot be written. Decisions are recorded as ADR 0010.

Evidence

The image cannot be built where this was written, so this pull request's image check 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.

View guided diff Turn on auto-fix

… 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.
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between db94d84 and 646435f.

Files ignored due to path filters: 1

  • brand/favicon/site.webmanifest is excluded by !brand/favicon/**
Files selected for processing: 17

  • .dockerignore
  • .env.example
  • .github/scripts/smoke-test-image.sh
  • .github/workflows/ci.yml
  • .github/workflows/release.yml
  • Dockerfile
  • README.md
  • brand/scripts/build.mjs
  • docs/adr/0010-packaging.md
  • server/src/app.test.ts
  • server/src/app.ts
  • server/src/data-dir.test.ts
  • server/src/data-dir.ts
  • server/src/main.ts
  • unraid/selects.xml
  • web/index.html
  • web/src/pwa.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T12:02:14.970331Z 646435f New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread README.md
Comment on lines +92 to +93
# SELECTS_PASSWORD, INSTAGRAM_API and BUCKET_*; DATA_DIR and PORT are set by the image.
env_file: selects.env

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 18 files

Confidence score: 3/5

  • .github/scripts/smoke-test-image.sh can 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.
  • prepareDataDir in server/src/data-dir.ts can pass when the directory is writable but an existing selects.db is not, leaving startup to fail with an uncaught openDatabase error. Validate the database path or handle that startup error.
  • The Unraid paths in README.md may 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.sh embeds 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

Comment thread README.md Resolved
Comment thread server/src/data-dir.ts
export function prepareDataDir(dataDir: string): string | undefined {
try {
mkdirSync(dataDir, { recursive: true });
accessSync(dataDir, constants.R_OK | constants.W_OK | constants.X_OK);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .github/workflows/release.yml Resolved
Comment thread .github/scripts/smoke-test-image.sh Outdated
set -euo pipefail

image=${1:?usage: smoke-test-image.sh <image>}
open=selects-smoke-open

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6594944: names are this run's own. The host ports stay fixed: the script runs on a CI runner of its own.

Comment thread README.md
### 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread server/src/data-dir.test.ts Resolved
Comment thread server/src/data-dir.ts Resolved
Comment thread .github/scripts/smoke-test-image.sh Resolved
Comment thread .github/scripts/smoke-test-image.sh Resolved
check "SIGTERM stops the server cleanly"

# With the password.
start "$locked" 3001 --env SELECTS_PASSWORD=smoke-test-password

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
start "$locked" 3001 --env SELECTS_PASSWORD=smoke-test-password
start "$locked" 3001 --env "SELECTS_PASSWORD=$(od -An -N16 -tx1 /dev/urandom | tr -d ' \n')"

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left as is. It is the password of a container that lives for seconds on a CI runner and holds nothing.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +72 to +73
tags: |
type=semver,pattern={{version}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 646435f: the metadata step sets latest=false, so only the last job moves latest.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 6 files (changes from recent commits).

Confidence score: 3/5

  • In .github/workflows/release.yml, type=semver also creates the latest tag during publish, so consumers could pull the image before it passes verify. Set flavor: latest=false on 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
# 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.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 646435f: the metadata step sets latest=false.

@brandonnly
brandonnly merged commit 39b7b54 into main Nov 13, 2026
4 checks passed
@brandonnly
brandonnly deleted the 11-packaging branch November 13, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Package the container, Unraid template and PWA

1 participant