In this guide you’ll deploy two units in one App: web runs Node.js 26 and serves HTTP at the App’s public URL, and db runs PostgreSQL 19 on the App’s private network. A request to / reads a UUID stored in Postgres. You’ll use that UUID to check that the database survives a redeploy.
Start in a connected project checkout with permission to configure and deploy Apps. Use a fresh demo App and database volume. The commands assume curl and a POSIX shell on macOS or Linux.
Install Flog
Install Flog on your workstation, add its default install directory to the current shell’s path, and verify that it runs:
curl -fsSL https://flog.run/install | sh
export PATH="$HOME/.local/bin:$PATH"
flog --version
Install the web dependencies
From the repository root, create the two build contexts and install the packages used by web/index.js:
mkdir -p db web
(
cd web && flog init &&
flog add --ignore-scripts @rcompat/http @rcompat/env @primate/postgresql pema &&
flog lock --target linux/x64/musl
)
In a fresh web/ directory, flog init creates a package.json with "type": "module". flog add records the dependencies in that manifest, and flog lock --target linux/x64/musl includes the x64 Alpine build target in web/flog.lock. Commit both files; leave node_modules/ out of Git. This server runs directly in Node, so its installs skip dependency scripts: it doesn’t need the bundler’s postinstall step.
Prepare the source
db/Containerfile:
FROM docker.io/library/postgres:19
COPY init.sql /docker-entrypoint-initdb.d/01-demo.sql
db/init.sql runs only when Postgres initializes an empty data directory. Insert one marker and give the web unit a login that can read it:
CREATE TABLE marker (id uuid PRIMARY KEY);
INSERT INTO marker VALUES (gen_random_uuid());
\getenv reader_password READER_PASSWORD
CREATE ROLE appreader LOGIN PASSWORD :'reader_password';
GRANT SELECT ON marker TO appreader;
web/Containerfile:
FROM docker.io/library/node:26-alpine AS deps
RUN apk add --no-cache curl
USER node
ENV PATH="/home/node/.local/bin:${PATH}"
RUN curl -fsSL https://flog.run/install | sh && flog --version
WORKDIR /home/node/web
COPY --chown=node:node package.json flog.lock ./
RUN flog install --prod --ignore-scripts
FROM docker.io/library/node:26-alpine
WORKDIR /app
COPY --from=deps /home/node/web/node_modules ./node_modules
COPY package.json index.js ./
USER node
CMD ["node", "index.js"]
web/index.js:
import env from "@rcompat/env";
import http from "@rcompat/http";
import postgresql from "@primate/postgresql";
import p from "pema";
const db = postgresql({
host: "db", database: "postgres", username: "appreader",
password: env.get("READER_PASSWORD"), pool: { connectTimeout: 3000 },
});
await http.serve(async request => {
const { pathname } = new URL(request.url);
try {
if (pathname === "/check") {
await db.sql("SELECT 1");
return new Response(null, { status: 204 });
}
if (pathname !== "/") return new Response(null, { status: 404 });
const [row] = await db.sql({
query: "SELECT id FROM marker",
output: p.array(p({ id: p.string })),
});
return new Response(`${row.id}\n`, { headers: { "Cache-Control": "no-store" } });
} catch {
return new Response(null, { status: 503 });
}
}, { host: "0.0.0.0", port: Number(env.get("PORT")) });
Commit these files, including web/package.json and web/flog.lock, and push or merge them to the project’s master branch. App creation requires a pushed master; the deployment builds from Git, not your working directory.
Create the App and its units
Replace your-demo-label with an available single DNS label, not a full domain. Confirm the host claim in the browser when prompted.
rp app create myapp --host your-demo-label
rp app unit add myapp db --type runner --context db --containerfile Containerfile --health.tcp 5432
rp app unit volume add myapp db postgres-data /var/lib/postgresql
rp app unit add myapp web --type runner --context web --containerfile Containerfile \
--http 3000 --public --depends db \
--health.http /check
--health.http /check tells Repopack to request /check on the web unit’s HTTP port (3000) inside the App network. The current probe sends GET, so don’t make the route HEAD-only. You choose the path. Here /check runs SELECT 1 and returns an empty response: 204 on success or 503 if the query fails. This checks the database connection without rendering the front page. The separate --health.tcp 5432 check only tests whether the database port accepts a connection.
Each Containerfile and its COPY sources are relative to that unit’s context. --public selects web for routing; there is no separate expose step. --depends db puts the database first in deployment order. From web, connect to db:5432 by unit name, not localhost or the public URL.
Mount the volume at /var/lib/postgresql for the official PostgreSQL 19 image: it stores the cluster in a version-specific directory beneath that mount. If you already have data from an earlier major version, use a PostgreSQL major-version upgrade procedure before switching images; changing the tag or mount path does not migrate the data.
Supply credentials once
Run the following block for the first deployment, with shell tracing off. The database uses READER_PASSWORD to create the read-only login; the web unit uses the same key to connect. Only the database receives the admin password.
(
set -e
set +x
password() { od -An -v -N 32 -t x1 /dev/urandom | tr -d '[:space:]'; }
admin=$(password)
reader=$(password)
test "${#admin}" -eq 64 && test "${#reader}" -eq 64 || exit 1
printf '%s' "$admin" | rp app env set myapp POSTGRES_PASSWORD --value-stdin
printf '%s' "$reader" | rp app env set myapp READER_PASSWORD --value-stdin
rp app unit env add myapp db POSTGRES_PASSWORD
rp app unit env add myapp db READER_PASSWORD
rp app unit env add myapp web READER_PASSWORD
)
The values are write-only. rp app unit env list myapp web should show READER_PASSWORD by name. On an existing volume, setting new env values does not change PostgreSQL role passwords; coordinate any rotation in the database and App configuration.
Verify the first deploy and the redeploy
rp app deploy myapp
rp app info myapp
Wait for the deployment to report running. Copy the public URL from info into url and keep this shell open:
url='https://your-demo-label.repopack.app'
before=$(curl -fsS "$url/") && printf 'Stored UUID: %s\n' "$before"
Expect one UUID. Deploy again without rerunning setup or changing the volume:
rp app deploy myapp
rp app info myapp
Wait for the new deployment to be running before comparing. A full App deploy replaces the database runner as well as web; connections can briefly drop during that handoff.
after=$(curl -fsS "$url/") && test -n "$before" && test "$before" = "$after" && echo 'Same database row after redeploy'
If the request fails, inspect rp app logs myapp --unit db --tail 100 for database startup, then rp app logs myapp --unit web --tail 100 for the Node process. For a build failure, inspect deployment events instead of runtime logs. A matching UUID checks this redeploy; a persistent volume is not a backup. To stop the demo when finished, run rp app stop myapp.