Skip to content

Commit 8fa1603

Browse files
CopilotbrianLoomis
andcommitted
Fix Docker container publishing: fix README link, add docs, re-enable Docker Hub channel tagging
- Fix README: wrong Habitat Builder link pointed to 'chef-server' origin instead of the actual 'chef' origin (all plan.sh files use pkg_origin=chef) - Add 'Published Docker Containers' section to README documenting all 6 containers published to Docker Hub (oc_erchef, bookshelf, oc_bifrost, oc_id, chef-server-nginx, chef-server-ctl), how Habitat Builder builds them, and how channel tags are applied - Re-enable Docker Hub container channel tagging in promote_harts_and_containers.sh: the docker pull/tag/push block was entirely commented out, meaning channel-tagged images like chef/oc_erchef:stable were never being published despite the docker-compose.yml relying on them - Add Docker Hub login (via Vault) before docker push commands - Fix openresty-noroot skip logic (it has no export_targets=[docker] in .bldr.toml) - Replace stale TODO/broken-pipeline comments with clear explanatory comments Co-authored-by: brianLoomis <90281862+brianLoomis@users.noreply.github.com> Agent-Logs-Url: https://github.com/chef/chef-server/sessions/484aed12-f0be-4fa2-b8b0-d5c0b1f491e7
1 parent 49ad226 commit 8fa1603

2 files changed

Lines changed: 56 additions & 25 deletions

File tree

.expeditor/promote_harts_and_containers.sh

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ fi
1212
HAB_AUTH_TOKEN=$(vault kv get -field auth_token account/static/habitat/chef-ci)
1313
export HAB_AUTH_TOKEN
1414

15+
# Authenticate with Docker Hub so we can re-tag and push container images
16+
DOCKER_HUB_TOKEN=$(vault kv get -field token account/static/docker-hub/chef-ci)
17+
export DOCKER_HUB_USERNAME
18+
DOCKER_HUB_USERNAME=$(vault kv get -field username account/static/docker-hub/chef-ci)
19+
echo "${DOCKER_HUB_TOKEN}" | docker login -u "${DOCKER_HUB_USERNAME}" --password-stdin
20+
1521
# EXPEDITOR_VERSION and EXPEDITOR_CHANNEL are passed in via Expeditor when an omnibus package of
1622
# version EXPEDITOR_VERSION is promoted to EXPEDITOR_CHANNEL
1723

@@ -21,7 +27,14 @@ aws s3 cp "s3://chef-automate-artifacts/manifests/chef-server/${EXPEDITOR_VERSIO
2127
# Download or create the versions file
2228
aws s3 cp "s3://chef-automate-artifacts/${EXPEDITOR_CHANNEL}/latest/chef-server/versions.json" existing-versions.json --profile chef-cd || echo "[]" > existing-versions.json
2329

24-
# Promote the artifacts in Habitat Depot
30+
# Promote the artifacts in Habitat Depot and re-tag Docker Hub container images
31+
# with the release channel name (e.g. current, stable) and optionally 'latest'.
32+
#
33+
# Each chef/* package with export_targets = ["docker"] in .bldr.toml is automatically
34+
# exported to Docker Hub by Habitat Builder with a versioned tag
35+
# (e.g. chef/oc_erchef:14.0.1-20231015). The block below pulls that image and
36+
# re-tags it with the channel name so consumers can reference
37+
# chef/oc_erchef:stable or chef/oc_erchef:current rather than a specific build id.
2538
jq -r -c ".packages[]" manifest.json | while read service_ident; do
2639
# service_ident will look like: chef/oc_erchef/12.18.2/20180806132701
2740
pkg_origin=$(echo $service_ident | cut -d / -f 1) # chef
@@ -35,29 +48,28 @@ jq -r -c ".packages[]" manifest.json | while read service_ident; do
3548
else
3649
echo "Promoting ${service_ident} hart to the ${EXPEDITOR_CHANNEL} channel"
3750
hab pkg promote "${service_ident}" "${EXPEDITOR_CHANNEL}"
38-
# The pipeline has been improved, breaking this. I'm told to fix
39-
# it requires doing something different.
40-
#
41-
# TODO: remove this if we begin creating a container for `chef/openresty-noroot`
42-
# if [ "$pkg_name" = "openresty-noroot" ];
43-
# then
44-
# echo "Skipping promotion of container for ${service_ident}"
45-
# continue
46-
# fi
47-
#
48-
# echo "Promoting ${pkg_origin}/${pkg_name}:${pkg_version}-${pkg_release} container to ${EXPEDITOR_CHANNEL} tag"
49-
# docker pull "${pkg_origin}/${pkg_name}:${pkg_version}-${pkg_release}"
50-
# docker tag "${pkg_origin}/${pkg_name}:${pkg_version}-${pkg_release}" "${pkg_origin}/${pkg_name}:${EXPEDITOR_CHANNEL}"
51-
# docker push "${pkg_origin}/${pkg_name}:${EXPEDITOR_CHANNEL}"
52-
#
53-
# if [ "${EXPEDITOR_CHANNEL}" = "stable" ];
54-
# then
55-
# docker tag "${pkg_origin}/${pkg_name}:${pkg_version}-${pkg_release}" "${pkg_origin}/${pkg_name}:latest"
56-
# docker push "${pkg_origin}/${pkg_name}:latest"
57-
# docker rmi "${pkg_origin}/${pkg_name}:latest"
58-
# fi
59-
#
60-
# docker rmi "${pkg_origin}/${pkg_name}:${pkg_version}-${pkg_release}" "${pkg_origin}/${pkg_name}:${EXPEDITOR_CHANNEL}"
51+
52+
# openresty-noroot does not have export_targets = ["docker"] in .bldr.toml
53+
# so no Docker image is published for it; skip container promotion.
54+
if [ "$pkg_name" = "openresty-noroot" ];
55+
then
56+
echo "Skipping container promotion for ${service_ident} (no Docker export configured)"
57+
continue
58+
fi
59+
60+
echo "Promoting ${pkg_origin}/${pkg_name}:${pkg_version}-${pkg_release} container to ${EXPEDITOR_CHANNEL} tag"
61+
docker pull "${pkg_origin}/${pkg_name}:${pkg_version}-${pkg_release}"
62+
docker tag "${pkg_origin}/${pkg_name}:${pkg_version}-${pkg_release}" "${pkg_origin}/${pkg_name}:${EXPEDITOR_CHANNEL}"
63+
docker push "${pkg_origin}/${pkg_name}:${EXPEDITOR_CHANNEL}"
64+
65+
if [ "${EXPEDITOR_CHANNEL}" = "stable" ];
66+
then
67+
docker tag "${pkg_origin}/${pkg_name}:${pkg_version}-${pkg_release}" "${pkg_origin}/${pkg_name}:latest"
68+
docker push "${pkg_origin}/${pkg_name}:latest"
69+
docker rmi "${pkg_origin}/${pkg_name}:latest"
70+
fi
71+
72+
docker rmi "${pkg_origin}/${pkg_name}:${pkg_version}-${pkg_release}" "${pkg_origin}/${pkg_name}:${EXPEDITOR_CHANNEL}"
6173
fi
6274
done
6375

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Once the build is complete, the package should be in omnibus/pkg. By default the
6161

6262
## Habitized Chef Infra Server
6363

64-
The following components now exist as Habitat packages and are available [here](https://bldr.habitat.sh/#/origins/chef-server/packages):
64+
The following components now exist as Habitat packages and are available [here](https://bldr.habitat.sh/#/origins/chef/packages):
6565

6666
* nginx
6767
* bookshelf
@@ -76,6 +76,25 @@ To build the packages locally:
7676
./habitat_pkgs_build.sh
7777
```
7878

79+
### Published Docker Containers
80+
81+
The following containers are published to [Docker Hub](https://hub.docker.com/u/chef) under the `chef` organization:
82+
83+
| Container | Docker Hub |
84+
|-----------|-----------|
85+
| `chef-server-nginx` | [hub.docker.com/r/chef/chef-server-nginx](https://hub.docker.com/r/chef/chef-server-nginx) |
86+
| `bookshelf` | [hub.docker.com/r/chef/bookshelf](https://hub.docker.com/r/chef/bookshelf) |
87+
| `oc_id` | [hub.docker.com/r/chef/oc_id](https://hub.docker.com/r/chef/oc_id) |
88+
| `oc_erchef` | [hub.docker.com/r/chef/oc_erchef](https://hub.docker.com/r/chef/oc_erchef) |
89+
| `oc_bifrost` | [hub.docker.com/r/chef/oc_bifrost](https://hub.docker.com/r/chef/oc_bifrost) |
90+
| `chef-server-ctl` | [hub.docker.com/r/chef/chef-server-ctl](https://hub.docker.com/r/chef/chef-server-ctl) |
91+
92+
Container images are built by [Habitat Builder](https://bldr.habitat.sh) using the `export_targets = ["docker"]` configuration in `.bldr.toml`. Each component plan (`src/<component>/habitat/plan.sh`) uses `pkg_origin=chef`, which determines the Docker Hub organization name.
93+
94+
When an omnibus package is promoted to the `current`, `stable`, or `LTS-2024` channel, the Expeditor CI pipeline runs `.expeditor/promote_harts_and_containers.sh`, which promotes the corresponding Habitat packages and re-tags the Docker images with the channel name (e.g., `chef/oc_erchef:stable`, `chef/oc_erchef:current`) and updates `latest` when promoted to `stable`.
95+
96+
### Running Chef Infra Server with Docker Compose
97+
7998
A top-level `docker-compose.yml` file exists for running Chef Infra Server from Habitized Docker images:
8099

81100
```shell

0 commit comments

Comments
 (0)