Krystal
02/12/2024, 6:57 PMMarvin
02/12/2024, 7:00 PMprefect.yaml
file using deployment steps. This approach allows you to define the image tag during your deployment process, and it assumes you have the image tagging logic integrated into your deployment flow.
Here's a brief step to set up image tagging with Git SHA in your `prefect.yaml`:
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:
id: build-image
requires: prefect-docker>=0.4.0
image_name: "{{ $PREFECT_IMAGE_NAME }}"
tag: "{{ get-commit-hash.stdout }}"
dockerfile: auto
platform: "linux/amd64"
Keep in mind, this will only help to tag the images during the build and deployment process, but does not provide a method to directly retrieve the tag via the API post-deployment.
If you want to retrieve the image tag after deployment, this information might be accessible through querying your container orchestration service (e.g., Kubernetes API if you're using Kubernetes) to get the deployment details, which include the image tag being used.
For further assistance with a specific method to retrieve image tags post-deployment, checking your orchestration service's API or Prefect community resources would be necessary, as this is not detailed in the Prefect documentation excerpts provided.
Keep in mind that I'm operating on the information available up to the moment of my knowledge cutoff in April 2023. If Prefect has introduced new functionality since then, consulting current documentation or community forums might shed light on new developments.