Skip to content

Commit f4ce623

Browse files
committed
feat: add ubuntu version-specific image tags
Add version-specific tags (e.g., ubuntu-noble, ubuntu-24.04) when pushing images to Docker Hub. This allows users to pin to a specific Ubuntu version and avoid unexpected breakage when the base image changes. New tags pushed per image: - ubuntu-{codename} (e.g., ubuntu-noble) - ubuntu-{codename}-{date} (e.g., ubuntu-noble-20250101) - ubuntu-{version} (e.g., ubuntu-24.04) - ubuntu-{version}-{date} (e.g., ubuntu-24.04-20250101) Existing tags (ubuntu, ubuntu-{date}, latest) are unchanged. Closes #282
1 parent 28e8466 commit f4ce623

2 files changed

Lines changed: 50 additions & 2 deletions

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ https://hub.docker.com/r/codercom/example-base. The tag is taken from the
1919
filename of the Dockerfile. For example, `base/ubuntu.Dockerfile` is
2020
under the `ubuntu` tag.
2121

22+
### Available Tags
23+
24+
Each image is published with the following tag variants:
25+
26+
| Tag | Example | Description |
27+
| -------------------------- | --------------------------------------------- | -------------------------------------------------- |
28+
| `ubuntu` | `codercom/example-base:ubuntu` | Latest Ubuntu version (rolling) |
29+
| `ubuntu-{codename}` | `codercom/example-base:ubuntu-noble` | Pinned to a specific Ubuntu release codename |
30+
| `ubuntu-{version}` | `codercom/example-base:ubuntu-24.04` | Pinned to a specific Ubuntu release version |
31+
| `ubuntu-{date}` | `codercom/example-base:ubuntu-20250101` | Snapshot from a specific build date |
32+
| `ubuntu-{codename}-{date}` | `codercom/example-base:ubuntu-noble-20250101` | Version-pinned snapshot from a specific build date |
33+
| `ubuntu-{version}-{date}` | `codercom/example-base:ubuntu-24.04-20250101` | Version-pinned snapshot from a specific build date |
34+
| `latest` | `codercom/example-base:latest` | Alias for the latest build |
35+
2236
> For backward compatibility, these images are also available with the `enterprise-` prefix
2337
> (e.g., `codercom/enterprise-base`), but the `example-` prefix is recommended for new deployments.
2438

scripts/push_images.sh

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,23 @@ if [ $QUIET = true ]; then
8888
)
8989
fi
9090

91+
# Extract Ubuntu version information from a locally loaded Docker image.
92+
# Sets UBUNTU_VERSION_ID (e.g., "24.04") and UBUNTU_VERSION_CODENAME (e.g., "noble").
93+
# Returns 1 if the version information could not be extracted.
94+
function get_ubuntu_version() {
95+
local image_ref="$1"
96+
local os_release
97+
98+
os_release=$(docker run --rm --entrypoint cat "$image_ref" /etc/os-release 2>/dev/null) || return 1
99+
100+
UBUNTU_VERSION_ID=$(echo "$os_release" | grep "^VERSION_ID=" | cut -d'"' -f2)
101+
UBUNTU_VERSION_CODENAME=$(echo "$os_release" | grep "^VERSION_CODENAME=" | cut -d'=' -f2)
102+
103+
if [ -z "${UBUNTU_VERSION_ID:-}" ] || [ -z "${UBUNTU_VERSION_CODENAME:-}" ]; then
104+
return 1
105+
fi
106+
}
107+
91108
date_str=$(date --utc +%Y%m%d)
92109
for image in "${IMAGES[@]}"; do
93110
image_dir="$PROJECT_ROOT/images/$image"
@@ -106,14 +123,31 @@ for image in "${IMAGES[@]}"; do
106123
fi
107124

108125
build_id=$(cat "build_${image}.json" | jq -r .\[\"depot.build\"\].buildID)
109-
126+
110127
# Push example images (primary)
111128
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "$example_image_ref" "$build_id"
112129
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "$example_image_ref_date" "$build_id"
113130
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "codercom/example-${image}:latest" "$build_id"
114-
131+
115132
# Push enterprise images (alias)
116133
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "$enterprise_image_ref" "$build_id"
117134
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "$enterprise_image_ref_date" "$build_id"
118135
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "codercom/enterprise-${image}:latest" "$build_id"
136+
137+
# Push Ubuntu version-specific tags (e.g., ubuntu-noble, ubuntu-24.04)
138+
# These allow users to pin to a specific Ubuntu version and avoid
139+
# unexpected breakage when the base image changes.
140+
if get_ubuntu_version "$enterprise_image_ref"; then
141+
for prefix in "example" "enterprise"; do
142+
# Codename tags (e.g., codercom/example-base:ubuntu-noble)
143+
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "codercom/${prefix}-${image}:${TAG}-${UBUNTU_VERSION_CODENAME}" "$build_id"
144+
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "codercom/${prefix}-${image}:${TAG}-${UBUNTU_VERSION_CODENAME}-${date_str}" "$build_id"
145+
146+
# Version number tags (e.g., codercom/example-base:ubuntu-24.04)
147+
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "codercom/${prefix}-${image}:${TAG}-${UBUNTU_VERSION_ID}" "$build_id"
148+
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "codercom/${prefix}-${image}:${TAG}-${UBUNTU_VERSION_ID}-${date_str}" "$build_id"
149+
done
150+
else
151+
echo "Could not detect Ubuntu version for '$enterprise_image_ref'; skipping version-specific tags" >&2
152+
fi
119153
done

0 commit comments

Comments
 (0)