Build with a Dockerfile or an optional Stagefile
Keep your Dockerfile or try an optional build format, then measure the edit-deploy loop.
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 DockerfileExpect the same hello-from-my-device response as before. Stop the attached run with Ctrl+C before the next deployment.
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.yamlExpect 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.
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.
Before you move on
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