Trying to get off the ground with basic deployment...
# ask-community
l
Trying to get off the ground with basic deployment stuff in Prefect 3.0. I messaged last week about trying to get a flow deployed on ecs. I’ve put that on pause to just try to get the flow running on docker locally first, but I’m confused. I use the deployment script shown below and end up getting the image not found error, shown below the script. From my shell I’m logged into docker and have confirmed the container is built and available after running the script. I have a docker work pool running and try to trigger the flow run from the Prefect Cloud UI, which leads to the shown error. What might I need to do to get this running? I’m also trying to wrap my head around what I need to do to make sure the flow reports to Prefect server/cloud. I’m guessing that running .deploy() locally where I’m logged into prefect from the cli, and building from the prefect managed image will somehow ensure the containerized flow will have enough info to connect to Prefect to report the flow. Is this a correct assumption and, if not, what else would I need to do? And if deploying to ecs, what would I need to do so the flow can report to Prefect cloud when it executes? Would I just need to ensure the container is built with my prefect api token as an environment variable?
Copy code
FROM prefecthq/prefect:3-python3.11

WORKDIR /app

# Install poetry
RUN pip install poetry

# Copy poetry files
COPY pyproject.toml poetry.lock /app/

# Install dependencies
RUN poetry config virtualenvs.create false \
    && poetry install --no-dev --no-root

# Copy the source code
COPY src/ /app

# Run the application
CMD ["sh", "-c", "pwd && ls && python first_example.py"]
Copy code
from prefect.deployments.runner import DockerImage 
from src.first_example import run_first_example


def deploy_local():
    
    run_first_example.deploy(name="example-local-deployment",
                                work_pool_name="local-docker-pool",
                                parameters={"a": 3},
                                image=DockerImage(
                                    name="first-example",
                                    tag="latest",
                                    dockerfile="Dockerfile",
                                    ),
                                push=False
                                )

if __name__ == "__main__":
    deploy_local()
Copy code
docker.errors.ImageNotFound: 404 Client Error for <http+docker://localhost/v1.41/images/create?tag=latest&fromImage=first-example>: Not Found ("pull access denied for first-example, repository does not exist or may require 'docker login': denied: requested access to the resource is denied")
n
hi @luke b there's docs here on • running flows in a static containerrunning flows in ephemeral containers, using a docker worker the latter should be nearly identical to the process you'd follow for ECS, except you'd run an ECS service for your
ecs
type worker, instead of the
docker
worker if you're using cloud and don't need granular control on how your worker runs you can use an ecs push pool so you don't need to run a worker
l
Thanks @Nate I tried to follow the second doc you listed but ran into the error I indicated. Any ideas for what might be causing the issue or how I can address it? The deploy code runs without error, then a docker type work pool is running and receives the run trigger, but then throws that error.
n
there’s a couple issues I notice with your example as shown • you shouldn’t need to overwrite the ENTRYPOINT / CMD if you’re trying to use workers - the command used to start the flow run is determined by the
command
field on your work pool • as for the error, docker can’t find your image. i would use a remote registry for your image, but if you can’t, perhaps you can try an image tag other than latest? e.g “local”