Hi team, I am using the `.deploy()` to create a de...
# ask-community
t
Hi team, I am using the
.deploy()
to create a deployment using container image as my source of flow code. Is anyone aware how to pass secrets for the dockerfile context which are required for the docker build? Any examples would be welcome! Thanks
k
You can instantiate a
DeploymentImage
that defines the image
name
,
tag
,
dockerfile
, and any additional kwargs listed here. https://docs.prefect.io/latest/api-ref/prefect/deployments/runner/#prefect.deployments.runner.DeploymentImage Then you can pass that
DeploymentImage
as the
image
to
.deploy()
. One that I've done before for installing private python packages from GCP's artifact registry is like this:
Copy code
FROM python:3.10

ARG AUTHED_ARTIFACT_REG_URL
COPY ./requirements.txt /requirements.txt

RUN pip install --extra-index-url ${AUTHED_ARTIFACT_REG_URL} -r /requirements.txt
Copy code
from prefect import flow
from prefect.deployments.runner import DeploymentImage
from prefect.blocks.system import Secret
from my_private_package import do_something_cool


@flow(log_prints=True)
def my_flow():
    do_something_cool()


if __name__ == "__main__":
    artifact_reg_url: Secret = Secret.load("artifact-reg-url")
    
    my_flow.deploy(
        name="my-deployment",
        work_pool_name="k8s-demo",
        image=DeploymentImage(
            name="my-image",
            tag="test",
            dockerfile="Dockerfile",
            buildargs={"AUTHED_ARTIFACT_REG_URL": artifact_reg_url.get()},
        ),
    )
🙌 1