46 lines
1.9 KiB
Markdown
46 lines
1.9 KiB
Markdown
# examples/starter/Dockerfile.example
|
|
|
|
## Naming
|
|
|
|
EXAMPLE — a component image. Copy, rename, replace. Named like the manifest it feeds and the resource it becomes:
|
|
|
|
```
|
|
Dockerfile.api -> image <cluster>-api -> image: in k8s/base/api.yaml
|
|
```
|
|
|
|
That image string is the ONLY thing connecting the three. Nothing checks it; a typo shows up as a pod stuck in ImagePullBackOff pulling from the public index, which reads like a network problem and is not one.
|
|
|
|
## COPY paths are relative to the build context
|
|
|
|
The overlay's Tiltfile runs from the overlay's own folder (rig's ctrl/Tiltfile includes it), so both paths in `docker_build` are relative to the overlay:
|
|
|
|
```
|
|
context='.' the overlay folder (or a subfolder, e.g. 'repodir/api')
|
|
dockerfile='Dockerfile.api' relative to the overlay's Tiltfile too
|
|
```
|
|
|
|
Every COPY is resolved against the context, NOT against the Dockerfile's directory. With `context='.'` and the Dockerfile in a subfolder, a file sitting right beside it is still reached through that subfolder:
|
|
|
|
```
|
|
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf # correct, Dockerfile in docker/
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf # fails — no such file in the context
|
|
```
|
|
|
|
Nothing warns you. The build just cannot find a file that is visibly there.
|
|
|
|
Before overlays, rig's own ctrl/Tiltfile built with `context='..'` (the repository root) and the Dockerfile in ctrl/, which is the same trap one level up.
|
|
|
|
## Dependency layer
|
|
|
|
Dependencies first, in their own layer: they change far less often than the code, so a source edit does not reinstall them on every rebuild.
|
|
|
|
## live_update
|
|
|
|
The sync in the Tiltfile's `docker_build` must land where this image expects it:
|
|
|
|
```
|
|
live_update=[sync('api', '/app/api')]
|
|
```
|
|
|
|
matches `COPY api/ ./api/` with `WORKDIR /app`. If the two disagree, Tilt syncs into a path nothing reads and the container keeps serving the built copy — edits appear to do nothing, with no error anywhere.
|