Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/build-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,12 @@ jobs:
size_mb="$(yq '.rootfs_size_mb // 512' "$svc_file")"
output="${tenant_id}-${base_name}-rootfs.ext4"

# Config overlay: tenant-specific overlay takes precedence.
# Config overlays: shared baseline applied first, tenant-specific on top.
# Pass as a colon-separated list so docker-to-rootfs.sh applies them in order.
overlay_arg=""
if [ -d "configs/${tenant_id}-${base_name}" ]; then
if [ -d "configs/${base_name}" ] && [ -d "configs/${tenant_id}-${base_name}" ]; then
overlay_arg="configs/${base_name}:configs/${tenant_id}-${base_name}"
elif [ -d "configs/${tenant_id}-${base_name}" ]; then
overlay_arg="configs/${tenant_id}-${base_name}"
elif [ -d "configs/${base_name}" ]; then
overlay_arg="configs/${base_name}"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The `build-images` workflow does the following on relevant pushes:
2. Iterates over `tenants/*/*.yaml`.
3. Reads `source_image` and optional `rootfs_size_mb` from each tenant file.
4. Builds `<tenant>-<service>-rootfs.ext4` via `scripts/docker-to-rootfs.sh`.
5. Applies config overlays with precedence:
- `configs/<tenant>-<service>/` (tenant-specific)
- then `configs/<service>/` (shared)
5. Applies config overlays in order (shared baseline first, tenant-specific on top):
- `configs/<service>/` (shared baseline, applied first if present)
- `configs/<tenant>-<service>/` (tenant-specific, applied on top if present, overrides shared)
6. Uploads resulting `*-rootfs.ext4` artifacts to S3.
23 changes: 15 additions & 8 deletions scripts/docker-to-rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
#
# Usage: ./scripts/docker-to-rootfs.sh <docker-image> <output.ext4> [size_mb] [overlay_dir] [fc_init_bin]
#
# overlay_dir Optional directory whose contents are copied into the rootfs,
# mirroring the guest filesystem layout. For example, placing a
# file at overlay_dir/usr/share/elasticsearch/config/elasticsearch.yml
# overwrites that path in the rootfs.
# overlay_dir Optional colon-separated list of directories whose contents are
# copied into the rootfs in order, mirroring the guest filesystem
# layout. Later directories override earlier ones, so pass the shared
# baseline first and tenant-specific overlay second. For example:
# configs/elasticsearch:configs/tenant-1-elasticsearch
# fc_init_bin Optional path to a prebuilt linux/arm64 fc-init binary.
# If omitted, the script tries:
# 1) FC_INIT_BIN env var
Expand Down Expand Up @@ -164,10 +165,16 @@ RUNTIME_WRITABLE_PATHS_JSON="$(jq -cn \
| unique
')"

# Apply config overlay if provided.
if [ -n "$OVERLAY_DIR" ] && [ -d "$OVERLAY_DIR" ]; then
echo "==> Applying config overlay from $OVERLAY_DIR"
cp -r "$OVERLAY_DIR/." "$ROOTFS/"
# Apply config overlays in order. OVERLAY_DIR may be a colon-separated list;
# later entries override earlier ones (shared baseline first, tenant-specific second).
if [ -n "$OVERLAY_DIR" ]; then
IFS=: read -ra overlay_dirs <<< "$OVERLAY_DIR"
for dir in "${overlay_dirs[@]}"; do
[ -n "$dir" ] || continue
[ -d "$dir" ] || continue
echo "==> Applying config overlay from $dir"
cp -r "$dir/." "$ROOTFS/"
done
fi

# Some upstream images carry runtime-generated files that should not be baked
Expand Down