Give an app hardware access and persistent storage
Declare camera, network, and storage access, then verify what survives a redeploy.
Requirements and learning goals
Before you start
- The hello-wendy Node project from the first deployment lesson
- A camera for the optional hardware exercise
You will be able to
- Explain the difference between installed hardware and app access
- Preserve application data through redeployment
The project brief below assumes the listed prerequisites and gives you a task and checks to perform. Need a guided first project?
An is an app permission: it declares which hardware, network connections, or storage the app can use. Persistent storage keeps files when you replace the application, so calibration and saved settings survive a redeploy.
An installed camera is not automatically available inside every application. Entitlements in wendy.json grant the resources an app needs. A grant does not install drivers or fix incompatible libraries.
Inspect camera inventory before adding camera access. A permission declaration cannot create a missing device or driver.
Continue in hello-wendy, keeping the same app identity and build format. Camera access below is optional; the persistence exercise needs no camera.
Optional: inspect hardware access
wendy device camera list
wendy project entitlements add cameraThe second command edits the current project. Inspect the change and redeploy before checking camera access inside the application.
Keep data across redeploys
Add this object to the existing entitlements array in wendy.json. Keep the network object already there and separate the objects with a comma:
{ "type": "persist", "name": "learn-state", "path": "/data" }In src/index.ts, add this import beside the existing imports:
import { existsSync, readFileSync, writeFileSync } from "node:fs";Add this block before app.listen(...), leaving the existing routes intact:
const counterPath = "/data/starts.txt";
const previous = existsSync(counterPath)
? Number(readFileSync(counterPath, "utf8")) : 0;
writeFileSync(counterPath, String(previous + 1));
console.log("Starts:", previous + 1);Deploy with the build format you used in the previous lesson:
wendy run --build-type docker --dockerfile DockerfileUse wendy run --dockerfile build.stagefile.yaml if you chose the optional . Record Starts: N in the logs, stop with Ctrl+C, and run the same command again. Expect a larger number and the same HTTP response. Restarts also increment the count. Keep the app identity, volume name, and mount path stable. This demonstration counter is not crash-safe; use transactions or atomic writes for important state.
Check the boundary
Device camera presence, app camera access, and persistent data are separate checks. Diagnose each separately. If a server is unreachable, inspect its network mode and bind address rather than adding unrelated hardware grants.
Bridge networking can provide outbound access. Host mode exposes the ports an app binds on the host. service publication follows its own rules. Choose the mode deliberately.
Optional extension: persist calibration parameters and display their version in the UI.
Source: Entitlements and persistence.
Before you move on
Can you do each of these?
- Explain the difference between installed hardware and app access
- Preserve application data through redeployment
0 of 2 checkpoints solved. Try checkpoint 1