Tomas Moreno
05/28/2024, 5:45 PMprefect deploy --all
from pushing the docker image multiple times? my deploy has been getting
OSError: tag invalid: The image tag '49595c4' already exists in the 'dwh' repository and cannot be overwritten because the repository is immutable.
I'm tagging my docker image using the git commit hashMarvin
05/28/2024, 5:46 PMprefect deploy
, you can customize the build and push process in the prefect.yaml
file. This can help prevent multiple pushes of the same Docker image. Here are some relevant points and examples:
1. Use a Git Commit Hash for Tagging:
You can set your Docker image's tag to a Git commit hash using a script. Here’s an example from the documentation:
yaml
build:
- prefect.deployments.steps.run_shell_script:
id: get-commit-hash
script: git rev-parse --short HEAD
stream_output: false
- prefect_docker.deployments.steps.build_docker_image:
requires: prefect-docker
image_name: my-image
image_tag: "{{ get-commit-hash.stdout }}"
dockerfile: auto
2. Deployment Instruction Overrides:
You can override the build
, push
, and pull
sections in the prefect.yaml
file to cater to specific needs. This customization allows you to implement different behavior for different deployments, such as avoiding repeated Docker pushes:
yaml
build:
image_name: <your_image_name_here>
image_tag: {{ your_commit_hash }}
push: false # or implement conditional logic
3. Customizing Push Logic:
Consider implementing custom logic for pushing to handle immutable repositories correctly. You can add checks and conditions or use different strategies based on your needs:
yaml
push:
- prefect_shell_script:
script: |
if ! docker images -q <your_image_name>:{{ your_commit_hash }}; then
docker push <your_image_name>:{{ your_commit_hash }}
fi
Sources:
- Prefect Deployment Guide
- Prefect Kubernetes Deployment
These references provide more specifics and could be instrumental in avoiding redundant image pushes.Kevin Grismore
05/28/2024, 5:47 PMTomas Moreno
05/28/2024, 5:49 PMTomas Moreno
05/28/2024, 5:50 PMall-deployments: true
in the prefect deploy action https://github.com/PrefectHQ/actions-prefect-deploy/tree/mainNate
05/28/2024, 5:56 PMNate
05/28/2024, 5:56 PMprefect-docker
as soon as possible so this behavior is defaultTomas Moreno
05/28/2024, 6:04 PMTomas Moreno
05/28/2024, 6:04 PMNate
05/28/2024, 6:07 PMprefect_docker.deployments.steps.build_docker_image
and the cached ones i have here that wrap those are just fully qualified names of python functions, so whatever python you have that runs prefect deploy
will need access to those modules, which is why I have the steps defined in a package (but strictly speaking you shouldnt need a package)Tomas Moreno
05/28/2024, 7:38 PMbuildargs
? we use those to pass in github creds to install some private packages but I think it's causing some hangups due to an unhashable type dict.Nate
05/28/2024, 7:50 PMNate
05/28/2024, 7:52 PMBuildKwargs(BaseModel, frozen=True)
in the signature of the step which can scoop a dict
from yaml but also is hashable