# HashiCorp Waypoint Image Tagging

- URL: https://baeke.info/2020/10/19/hashicorp-waypoint-image-tagging/
- Author: Geert Baeke
- Published: October 19, 2020
- Topics: cicd, containers, kubernetes
- Outdated: HashiCorp Waypoint was discontinued.

Recently (October, 2020) I posted an [introduction](https://youtu.be/AtfUmgdj7oE) to HashiCorp Waypoint on my [YouTube channel](https://www.youtube.com/geertbaeke). It shows how to build, push, deploy and release applications to Kubernetes with a single **waypoint up** command. If you want to check out that video first, see below ⬇⬇⬇

<div class="video"><iframe src="https://www.youtube-nocookie.com/embed/AtfUmgdj7oE" title="YouTube video" loading="lazy" allowfullscreen></iframe></div>

After watching that video, it should be clear that you drive the process from a file called waypoint.hcl. The waypoint.hcl to deploy the Azure Function app in the video, is shown below:

```text
project = "wptest-hello"

app "wptest-hello" {
  labels = {
    "service" = "wptest-hello",
    "env" = "dev"
  }

  build {
    use "docker" {}
    registry {
        use "docker" {
          image = "gbaeke/wptest-hello"
          tag = "latest"
          local = false
        }
    }
  }

  deploy {
    use "kubernetes" {
        service_port = 80
        probe_path = "/"
    }
  }

  release {
    use "kubernetes" {
       load_balancer =  true
    }
  }
}
```

In the **build** stanza, **use “docker”** tells Waypoint to build the container image from a local Dockerfile. With **registry**, we push that image to, in this case, Docker Hub. Instead of Docker Hub, other registries can be used as well. Before the image is pushed to the registry, it is first tagged with the tag you specify. Here, that is the **latest** tag. Although that is easy, you should not use that tag in your workflow because you will not get different images per application version. And you certainly want that when you do multiple deploys based on different code.

To make the tag unique, you can replace “latest” with the **gitrefpretty()** function, as shown below:

```text
build {
    use "docker" {}
    registry {
        use "docker" {
          image = "gbaeke/wptest-hello"
          tag = gitrefpretty()
          local = false
        }
    }
  }
```

Assuming you work with git and commit your code changes 😉, gitrefpretty() will return the git commit sha at the time of build.

You can check the commit sha of each commit with **git log**:

![](https://baeke.info/_astro/2020-10-image.Zey4HL3L_1bdmdu.webp)

*git log showing each commit with its sha-1 checksum*

When you use gitrefpretty() and you issue the **waypoint build** command, the images will be tagged with the sha-1 checksum. In Docker Hub, that is clearly shown:

![](https://baeke.info/_astro/2020-10-image-1.DidQMieq_Z1YoLn4.webp)

*Image with commit sha tag pushed to Docker Hub*

That’s it for this quick post. If you have further questions, just hit me up on [Twitter](https://twitter.com/GeertBaeke) or leave a comment!
