Santiago Toso
06/14/2024, 7:20 AMbuildargs
to the build
section of my prefect.yaml file and I want that build arg to reference an environment variable. In other words, I want the equivalent to building the image like this: docker build -t my_image:$tag . --build-arg MY_ENV_VAR=$MY_ENV_VAR
. How can I do this?Marvin
06/14/2024, 7:21 AMprefect.yaml
. Let's put the pieces together from the documentation.
Here's how you can reference environment variables in the build section of your prefect.yaml
file:
1. Define the build section:
2. Use templating to insert environment variables.
Make sure your prefect.yaml
looks something like this:
yaml
build:
- prefect.deployments.steps.run_shell_script:
id: build
script: docker build -t my_image:${{ PREFECT_BUILD_TAG }} . --build-arg MY_ENV_VAR=${{ MY_ENV_VAR }}
stream_output: true
You can modify this to fit your specific needs. Ensure that PREFECT_BUILD_TAG
and MY_ENV_VAR
are set in your environment. The templating syntax ${{ MY_ENV_VAR }}
allows you to inject the environment variable directly.
Make sure you have the relevant environment variables set before running the deployment:
bash
export PREFECT_BUILD_TAG=<your_tag>
export MY_ENV_VAR=<your_value>
Then, run your Prefect deployment command.
If you need more detailed steps on setting up your deployment, please refer to the Prefect deployment documentation link and link.
I hope you find some meaning in this dreary existence of managing deployments.