From 5e8d24394ccabf2caa19b60086161684ffce7b39 Mon Sep 17 00:00:00 2001 From: Abhi Agarwal Date: Thu, 30 Jan 2025 22:39:52 -0500 Subject: [PATCH] vault backup: 2025-01-30 22:39:51 --- content/programming/tools/justfile/tagged-docker-images.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/programming/tools/justfile/tagged-docker-images.md b/content/programming/tools/justfile/tagged-docker-images.md index 3d24433..f9919cd 100644 --- a/content/programming/tools/justfile/tagged-docker-images.md +++ b/content/programming/tools/justfile/tagged-docker-images.md @@ -38,7 +38,7 @@ We can instead do `TAG=my-branch docker compose build` ! Still, not optimal. It Instead, we can use a justfile to calculate the tag dynamically and set the env variable. ```just -export TAG=`(git rev-parse --abbrev-ref HEAD` +export TAG=`(git rev-parse --abbrev-ref HEAD)` just up *FLAGS: docker compose up {{FLAGS}} @@ -47,7 +47,7 @@ just up *FLAGS: Pretty cool! But this could create docker tags that aren't syntactically valid, like if the branch is called `my/FEATURE-branch`. Instead, we can normalize it, following exactly what gitlab does to generate [`CI_COMMIT_REF_SLUG`](https://gitlab.com/gitlab-org/gitlab-runner/-/blame/af6932352f8ed15d1a6d9c786399607bc6be2c2d/Makefile.build.mk?page=1#L25). ```just -export TAG=`(git rev-parse --abbrev-ref HEAD) | tr '[:upper:]' '[:lower:]) | cut -c -63 | sed -E 's/[^a-z0-9-]+/-/g' | sed -E 's/^-*([a-z0-9-]+[a-z0-9])-*$$/\1/g')` +export TAG=`(git rev-parse --abbrev-ref HEAD | tr '[:upper:]' '[:lower:] | cut -c -63 | sed -E 's/[^a-z0-9-]+/-/g' | sed -E 's/^-*([a-z0-9-]+[a-z0-9])-*$$/\1/g')` just up *FLAGS: docker compose up {{FLAGS}}