Fugo Takefusa
09/18/2025, 1:30 AMMarvin
09/18/2025, 1:30 AMMarvin
09/18/2025, 1:35 AMprefect work-pool create my-process-pool --type process
prefect worker start --pool my-process-pool
- Deploy from local files (programmatically) using `Flow.from_source`:
from prefect import Flow
Flow.from_source(".", "data_flows/deploy_buy.py:buy").deploy(
name="deploy_buy",
work_pool_name="my-process-pool",
)
This stores the deployment as “local” storage and expects the worker to read your code from the same path.
Option B: Docker work pool with code baked into the image (no Git)
- Keep your Docker build step, remove the push step. Your worker must run on the same Docker host so it can see the locally built image.
- Edit your prefect.yaml:
- Keep build:
step
- Remove push:
step (or set it to []
)
- Ensure your work pool job_variables.image
points at the built image tag
- Create/start a Docker worker:
uv run --with 'prefect[docker]' prefect work-pool create docker-worker-pool --type docker
uv run --with 'prefect[docker]' prefect worker start --pool docker-worker-pool
- Deploy with prefect deploy
from your project root, or programmatically. No remote repo is required because the code is inside the image.
Notes for your YAML
- To skip pushing the image, remove the deployment’s push: *docker_push
or set push: []
.
- Make sure your Jinja placeholders line up with the step id you set. If your build step id is build-image
, reference it as {{ build-image.image }}
in job_variables.image
.
Option C: Docker work pool with host code mounted into the container (no Git, no image push)
- Don’t bake the code into the image; mount it at runtime.
- In your Docker work pool job variables, add something like:
job_variables:
image: "python:3.11-slim"
volumes:
- "/path/on/host/your-project:/opt/prefect/project"
working_dir: "/opt/prefect/project"
- In prefect.yaml
, you can add a pull step to set the working dir (optional if working_dir
above is set):
pull:
- prefect.deployments.steps.set_working_directory:
directory: /opt/prefect/project
- Deploy with prefect deploy
or programmatically. Your worker must be on the same machine (or have the path available) to mount the volume.
Quick CLI checks (verified)
- prefect deploy --help
exists and supports entrypoint pointing at ./path/to/file.py:flow_func_name
.
- prefect worker start --pool <name>
and prefect work-pool create --type <type>
are valid.
Docs
- Store flow code (Prefect 3.x)
Questions to clarify
- Are your workers running on the same machine as where you’re deploying?
- Do you also want to avoid pushing Docker images to a registry, or just avoid pushing code to a Git repo?
- Do you prefer Process workers (no Docker) or Docker workers?