<@ULVA73B9P> how to deploy flow without pushing to...
# ask-marvin
f
@Marvin how to deploy flow without pushing to remote repo # Welcome to your prefect.yaml file! You can use this file for storing and managing # configuration for deploying your flows. We recommend committing this file to source # control along with your flow code. # Generic metadata about this project name: prefect prefect-version: 3.4.7 # build section allows you to manage and build docker images build: ... # - prefect_docker.deployments.steps.build_docker_image: # id: build_image # requires: prefect-docker>=0.3.1 # image_name: fugotakefusaptml/prefect-docker-repo # tag: 2 # dockerfile: auto # push section allows you to manage if and how this project is uploaded to remote locations push: ... # - prefect_docker.deployments.steps.push_docker_image: # requires: prefect-docker>=0.3.1 # image_name: '{{ build_image.image_name }}' # tag: '{{ build_image.tag }}' # pull section allows you to provide instructions for cloning this project in remote locations pull: ... # - prefect.deployments.steps.set_working_directory: # directory: /opt/prefect/prefect definitions: work_pools: docker_worker_pool: &docker_worker_pool name: docker-worker-pool work_queue_name: null job_variables: image: '{{ build_image.image }}' actions: docker_build: &docker_build - prefect_docker.deployments.steps.build_docker_image: &docker_build_config id: build-image requires: prefect-docker>=0.3.0 image_name: fugotakefusaptml/prefect-docker-repo tag: dev dockerfile: auto docker_push: &docker_push - prefect_docker.deployments.steps.push_docker_image: &docker_push_config requires: prefect-docker>=0.3.1 image_name: fugotakefusaptml/prefect-docker-repo tag: dev # the deployments section allows you to provide configuration for deploying flows deployments: - name: deploy_buy1 flow_name: deploybuy entrypoint: data_flows/deploy_buy.py:buy work_pool: *docker_worker_pool build: *docker_build push: *docker_push
m
thought for 247.5 seconds
Great question. In Prefect 3.x you can deploy without pushing to a remote Git repo in a few ways. The right choice depends on your worker setup and whether you’re using Docker. Here are the common patterns: Option A: Local code with a Process work pool (no Docker, no Git) - Create a process pool and start a worker on the same machine where your code lives:
Copy code
prefect work-pool create my-process-pool --type process
prefect worker start --pool my-process-pool
- Deploy from local files (programmatically) using `Flow.from_source`:
Copy code
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:
Copy code
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:
Copy code
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):
Copy code
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?