CI / Start
Run a job in its CI image
A job passes on your machine and fails on the forge, because the tools are different. --docker runs the job in its CI image (node or browser) with Docker, so it gets the tools of the forge.
2 min read
You need:
- Docker.
- A checkout of the TanStack Source repository, to build the images.
- The
srcCLI. Run CI jobs on your machine shows a local run without Docker.
1. Build the two images once
Build them from a checkout of the TanStack Source repository. The images are for linux/amd64.
docker build --platform linux/amd64 -t tanstack-source-ci-node -f apps/web/containers/node/Dockerfile packages/ci
docker build --platform linux/amd64 -t tanstack-source-ci-browser -f apps/web/containers/browser/Dockerfile packages/ci
2. Run the job with --docker
src ci run ci test --docker
- The command mounts your checkout at
/workspace, and runs the job in the container. It usestanstack-source-ci-browserwhen a job to run hasimage: 'browser'. - The images hold only the packages that the runner needs. The command also mounts the folder of the
srccode that you run, read-only, and runs the job with that code. So the runner in the container is the same version as yoursrc. - Secrets and the
--livevariables go into the container by name, so their values never show in the command line.
Note
In Docker, the cache, the artifacts and the fixup patches stay in the container, and Docker deletes the container after the run. Changes to the files of your checkout stay, because the checkout is mounted.
3. Print the docker command (optional)
To see the docker command without running it, add --print:
src ci run ci test --docker --print
docker run --rm --mount 'type=bind,source=/home/you/.source/bin,target=/opt/tanstack-source/ci/bundle,readonly' --mount 'type=bind,source=/home/you/app,target=/workspace' --workdir /workspace tanstack-source-ci-node node /opt/tanstack-source/ci/bundle/src.mjs ci run ci test
Done
The job runs with the tools of the forge, on your machine. When it passes in its CI image, push the fix once.