Skip to content

Commit 9216fbf

Browse files
authored
feat: add ubuntu version-specific image tags (#330)
Define UBUNTU_VERSION in scripts/images.sh as a single source of truth. Dockerfiles consume it via a build arg, and the push script reads the same variable to generate version-specific tags. No runtime detection or sidecar files needed. Updated Dockerfiles to use ARG UBUNTU_VERSION: - base, minimal: FROM ubuntu:${UBUNTU_VERSION} - universal: FROM mcr.microsoft.com/devcontainers/universal:${UBUNTU_VERSION} - Derivative images (golang, java, node, desktop) are unchanged since they inherit from locally-built base/minimal images. New tags pushed per image: - ubuntu-{version} (e.g., ubuntu-noble) - ubuntu-{version}-{date} (e.g., ubuntu-noble-20250101) Existing tags (ubuntu, ubuntu-{date}, latest) are unchanged. Closes #282
1 parent 2ab49fd commit 9216fbf

8 files changed

Lines changed: 36 additions & 5 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
*.sarif
33
tmp.*
4+
build_*.json

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ 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-{version}` | `codercom/example-base:ubuntu-noble` | Pinned to a specific Ubuntu release |
30+
| `ubuntu-{date}` | `codercom/example-base:ubuntu-20250101` | Snapshot from a specific build date |
31+
| `ubuntu-{version}-{date}` | `codercom/example-base:ubuntu-noble-20250101` | Version-pinned snapshot from a specific build date |
32+
| `latest` | `codercom/example-base:latest` | Alias for the latest build |
33+
2234
> For backward compatibility, these images are also available with the `enterprise-` prefix
2335
> (e.g., `codercom/enterprise-base`), but the `example-` prefix is recommended for new deployments.
2436

images/base/ubuntu.Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM ubuntu:noble
1+
ARG UBUNTU_VERSION=noble
2+
FROM ubuntu:${UBUNTU_VERSION}
23

34
SHELL ["/bin/bash", "-c"]
45
ENV DEBIAN_FRONTEND=noninteractive

images/minimal/ubuntu.Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM ubuntu:noble
1+
ARG UBUNTU_VERSION=noble
2+
FROM ubuntu:${UBUNTU_VERSION}
23

34
USER root
45
ENV DEBIAN_FRONTEND=noninteractive

images/universal/ubuntu.Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM mcr.microsoft.com/devcontainers/universal:linux
1+
ARG UBUNTU_VERSION=noble
2+
FROM mcr.microsoft.com/devcontainers/universal:${UBUNTU_VERSION}
23

34
USER root
45

scripts/build_images.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ for image in "${IMAGES[@]}"; do
111111
fi
112112

113113
run_trace $DRY_RUN depot build --project "gb3p8xrshk" --load --platform "$platform" --save --metadata-file="build_${image}.json" \
114+
--build-arg "UBUNTU_VERSION=$UBUNTU_VERSION" \
114115
"${docker_flags[@]}" \
115116
"$image_dir" \
116117
--file="$image_path" \

scripts/images.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
set -euo pipefail
44

5+
# UBUNTU_VERSION defines the Ubuntu release used as the base for all
6+
# images. Changing this value and rebuilding will produce images on
7+
# a different Ubuntu release. All Dockerfiles and the push script
8+
# read this variable so it acts as a single source of truth.
9+
UBUNTU_VERSION="noble"
10+
511
# IMAGES defines the list of images to build/push IN ORDER.
612
IMAGES=(
713
"base"

scripts/push_images.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,22 @@ for image in "${IMAGES[@]}"; do
106106
fi
107107

108108
build_id=$(cat "build_${image}.json" | jq -r .\[\"depot.build\"\].buildID)
109-
109+
110110
# Push example images (primary)
111111
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "$example_image_ref" "$build_id"
112112
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "$example_image_ref_date" "$build_id"
113113
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "codercom/example-${image}:latest" "$build_id"
114-
114+
115115
# Push enterprise images (alias)
116116
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "$enterprise_image_ref" "$build_id"
117117
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "$enterprise_image_ref_date" "$build_id"
118118
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "codercom/enterprise-${image}:latest" "$build_id"
119+
120+
# Push version-specific tags so users can pin to a specific Ubuntu
121+
# release. UBUNTU_VERSION is defined in images.sh and is the single
122+
# source of truth used by both the Dockerfiles and this script.
123+
for prefix in "example" "enterprise"; do
124+
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "codercom/${prefix}-${image}:${TAG}-${UBUNTU_VERSION}" "$build_id"
125+
run_trace $DRY_RUN depot push --project "gb3p8xrshk" --tag "codercom/${prefix}-${image}:${TAG}-${UBUNTU_VERSION}-${date_str}" "$build_id"
126+
done
119127
done

0 commit comments

Comments
 (0)