Lucas Silvestre
11/06/2025, 5:36 PMMarvin
11/06/2025, 5:36 PMMarvin
11/06/2025, 5:39 PM/app (because of your set_working_directory pull step), and the deployment’s entrypoint resolves to /app/flows/my_flow_test.py. Since the container can’t find that file, the issue is almost certainly with your Docker build context/COPY.
Why this likely happens
- Your build step uses dockerfile: ../Dockerfile but does not set the Docker build context (path). By default, the context is the directory where you run prefect deploy (typically where prefect.yaml lives).
- Docker COPY paths are relative to the build context, not the Dockerfile location. If your repo looks like this:
- repo_root/
- Dockerfile
- flows/
- some_dir/prefect.yaml
…then using dockerfile: ../Dockerfile with default context of some_dir means COPY flows ... won’t find flows/ (it’s outside the context).
- Older deployments may still work because they use older images that did contain the files; the new images are being built with the wrong context so the new flow files never make it into the image.
Two solid fixes (pick one)
1) Keep the Dockerfile in the parent, set the context to the repo root
build:
- prefect_docker.deployments.steps.build_docker_image:
id: build-image
requires: prefect-docker>=0.6.0
image_name: "{{ prefect.blocks.secret.docker-image }}"
tag: "reports-analytics-{{ $PREFECT_GIT_COMMIT_SHA }}"
dockerfile: ../Dockerfile
path: ".." # set build context to the repo root
platform: "linux/amd64"
- In your Dockerfile, use COPY statements relative to the context (the repo root), e.g.:
WORKDIR /app
COPY flows/ /app/flows/
# or COPY . /app if you want the entire repo
- Make sure .dockerignore does not exclude flows/ or your flow files.
2) Move the Dockerfile next to prefect.yaml and use local context
build:
- prefect_docker.deployments.steps.build_docker_image:
id: build-image
requires: prefect-docker>=0.6.0
image_name: "{{ prefect.blocks.secret.docker-image }}"
tag: "reports-analytics-{{ $PREFECT_GIT_COMMIT_SHA }}"
dockerfile: ./Dockerfile
path: "." # build context = current directory
platform: "linux/amd64"
- Adjust COPYs in the Dockerfile accordingly to match this layout.
Quick verification steps
- Build the image and inspect the contents:
- Locally: docker run --rm -it <your-built-image> ls -R /app/flows
- Or in-cluster: exec into a job/pod and ls -R /app/flows
- Ensure the deployment’s entrypoint matches where the file lands in the image (with /app as the working directory, your file should exist at /app/flows/my_flow_test.py).
If you can, please share:
- Your Dockerfile (especially the COPY lines)
- A small repo tree showing where prefect.yaml, Dockerfile, and flows/ live
- Your .dockerignore
- The failing deployment’s entrypoint (from prefect.yaml or however you define it)
With that, I can suggest exact path/COPY statements to make this robust.