Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ permissions:
jobs:
publish:
runs-on: ubuntu-latest
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
jobs:
test-global:
runs-on: ubuntu-latest
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
jobs:
validate:
runs-on: ubuntu-latest
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- uses: actions/checkout@v4

Expand Down
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This repository contains the following DevContainer Features:

- **[apptainer](#apptainer)** - Install Apptainer for HPC containerization
- **[cmdstan](#cmdstan)** - Install CmdStan (Stan probabilistic programming system)
- **[build-info](#build-info)** - Bakes build-time release version and date metadata directly into a system-wide command
- **[renv-cache](#renv-cache)** - Configure R with renv cache
- **[fit-sne](#fit-sne)** - Install FIt-SNE for dimensionality reduction
- **[mermaid](#mermaid)** - Install Mermaid CLI for diagram generation
Expand Down Expand Up @@ -85,6 +86,40 @@ The feature downloads the official CmdStan release tarball, pre-compiles the Sta

---

## build-info

Bakes build-time release version and date metadata directly into a system-wide command `container-info`.

### Example

To pass host environment variables (like `IMAGE_VERSION` and `IMAGE_BUILD_DATE` exported in a GitHub Action step) to the container at build time, you can map them in your project's `devcontainer.json` using the `${localEnv:VAR_NAME}` syntax:

```json
{
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/MiguelRodo/DevContainerFeatures/build-info:1": {
"version": "${localEnv:IMAGE_VERSION}",
"buildDate": "${localEnv:IMAGE_BUILD_DATE}"
}
}
}
```

### Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `version` | string | `"development"` | The automated version number injected from the runner host environment. |
| `buildDate` | string | `"unknown"` | The build timestamp injected from the runner host environment. |

### Notes

- Creates a secure static metadata file at `/usr/local/etc/container_metadata/build_info.txt`.
- Generates a globally executable command `/usr/local/bin/container-info`.

---

## renv-cache

Configures R for development in VS Code, including library paths, GitHub tokens, and package restoration with renv cache.
Expand Down
21 changes: 21 additions & 0 deletions src/build-info/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "Container Metadata Injector",
"id": "build-info",
"version": "1.0.0",
"description": "Bakes build-time release version and date metadata from GHA directly into a system-wide command.",
"options": {
"version": {
"type": "string",
"default": "development",
"description": "The automated version number injected from the runner host environment."
},
"buildDate": {
"type": "string",
"default": "unknown",
"description": "The build timestamp injected from the runner host environment."
}
},
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils"
]
}
34 changes: 34 additions & 0 deletions src/build-info/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -e

VERSION="${VERSION:-"development"}"
BUILD_DATE="${BUILDDATE:-"unknown"}"

DATA_DIR="/usr/local/etc/container_metadata"
mkdir -p "$DATA_DIR"

cat << EOF > "${DATA_DIR}/build_info.txt"
CONTAINER_VERSION="${VERSION}"
BUILD_DATE="${BUILD_DATE}"
EOF

COMMAND_PATH="/usr/local/bin/container-info"
cat << 'EOF' > "$COMMAND_PATH"
#!/usr/bin/env bash
DATA_FILE="/usr/local/etc/container_metadata/build_info.txt"
if [ ! -f "$DATA_FILE" ]; then
echo "[ERROR] Container release metadata log file is missing." >&2
exit 1
fi

echo "--------------------------------------------------"
echo "🚀 DevContainer Release Information"
echo "--------------------------------------------------"
cat "$DATA_FILE" | grep "^CONTAINER_VERSION=" | sed 's/^CONTAINER_VERSION="/ Version : /' | sed 's/"$//'
cat "$DATA_FILE" | grep "^BUILD_DATE=" | sed 's/^BUILD_DATE="/ Built On: /' | sed 's/"$//'
echo "--------------------------------------------------"
EOF

chmod +x "$COMMAND_PATH"
echo "Metadata injection and system command generation complete!"
15 changes: 15 additions & 0 deletions test/_global/build_info_default.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

source dev-container-features-test-lib

check "container-info script exists and is executable" test -x /usr/local/bin/container-info
check "build_info.txt exists" test -f /usr/local/etc/container_metadata/build_info.txt

# Run the command and check output
check "container-info outputs correct version" bash -c "container-info | grep 'Version : 1.2.3'"
check "container-info outputs correct date" bash -c "container-info | grep 'Built On: 2023-10-27T10:00:00Z'"

# Report result
reportResults
9 changes: 9 additions & 0 deletions test/_global/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,14 @@
"features": {
"cmdstan": {}
}
},
"build_info_default": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"build-info": {
"version": "1.2.3",
"buildDate": "2023-10-27T10:00:00Z"
}
}
}
}
Loading