Build with a Dockerfile or an optional Stagefile

Keep your Dockerfile or try an optional build format, then measure the edit-deploy loop.

Exercise brief·Intermediate·3 min read
Requirements and learning goals

Before you start

  • The hello-wendy Node project from the first deployment lesson
  • Node.js 22 and npm on your computer for the optional Stagefile comparison

You will be able to

  • Describe a container build with a Stagefile
  • Verify the same TypeScript app with either build format

The project brief below assumes the listed prerequisites and gives you a task and checks to perform. Need a guided first project?

Your existing Dockerfile works here. You do not need to convert it to a . Both produce standard images. A Stagefile is an optional YAML build recipe that generates a Dockerfile and manages dependency layers and lockfiles.

Continue in the same hello-wendy directory from the first deployment lesson. Keep its src/index.ts, package.json, tsconfig.json, and wendy.json. You will change only the build recipe and response text. The app stays in TypeScript and uses the same port and device.

Keep model downloads in persistent storage when appropriate, so an application edit does not require fetching the same weights again.

Keep your Dockerfile

The template already includes a Dockerfile that installs dependencies, compiles TypeScript, and runs dist/index.js. Record build time, then deploy:

wendy build --build-type docker --dockerfile Dockerfile
wendy run --build-type docker --dockerfile Dockerfile

Expect the same hello-from-my-device response as before. Stop the attached run with Ctrl+C before the next deployment.

Checkpoint 1 of 2

The hello-wendy template ships with a Dockerfile. You run wendy run --build-type docker --dockerfile Dockerfile and never write a Stagefile. What should you expect?

Commit to an answer. Every choice explains itself.

Optional: try a Stagefile

If you want to compare formats, generate a dependency lockfile with npm install --package-lock-only in this directory. Save the following as build.stagefile.yaml. Keep the Dockerfile. The commands below select a build file explicitly, so you can compare both in the same project.

version: 1
stages:
  - name: app
    from: node:22-slim
    workdir: /app
    install:
      npm:
        manager: npm
        production: false
    copy:
      - from: local
        paths: [src]
        dest: /app/src
      - from: local
        paths: [tsconfig.json]
        dest: /app/tsconfig.json
    build:
      lang: npm
      script: build
    user: "0"
    cmd: [node, dist/index.js]

Retain wendy.json, including its network and readiness port. Select the Stagefile explicitly while both recipes exist:

wendy build --dockerfile build.stagefile.yaml
wendy run --dockerfile build.stagefile.yaml

Expect the same response again. Change only the message in src/index.ts to hello-build-check, stop the attached run, and repeat your chosen build and run commands. Compare elapsed time with the first build. TypeScript must still compile; do not assume every source edit qualifies for a copy-only update.

Check your result

Refresh the application URL and expect {"message":"hello-build-check"}. Keep the dependency and generated Stagefile lockfiles with the project so teammates resolve the same inputs.

If a source file is missing inside the image, add it to the declared copy inputs. Do not copy your entire laptop environment to fix an undeclared dependency.

Checkpoint 2 of 2

You add labels.json to the project root and read it at startup. Built with the Stagefile above, the app fails because the file is missing inside the image. What is the fix?

Commit to an answer. Every choice explains itself.

Optional extension: try wendy run --watch --dockerfile build.stagefile.yaml, or select Dockerfile instead, and verify a saved edit on the device. Continue using this same project for persistence.

Source: Stagefile format and fast-path conditions.

Can you do each of these?

  • Describe a container build with a Stagefile
  • Verify the same TypeScript app with either build format

0 of 2 checkpoints solved. Try checkpoint 1

Previous: Discover a device and deploy your first app
All lessons in this topic
  1. 1. Discover a device and deploy your first app
  2. 2. Build with a Dockerfile or an optional Stagefile
  3. 3. Give an app hardware access and persistent storage
  4. 4. Split a robot application into services
  5. 5. Find a failure and prove recovery

Ask Wendy

Answers about Wendy and WendyOS

What would you like to know?

Ask about devices, development, and deployment.

Check linked docs for technical details.