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
9 changes: 5 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
"version": "latest",
"moby": false // go for the upstream Docker-CE
},
//"ghcr.io/thediveo/devcontainer-features/pull-through-cache-registry:0": {
// "port": "9999"
//}
"ghcr.io/thediveo/devcontainer-features/pull-through-cache-registry:0": {
"port": "9999"
}
},
"customizations": {
"vscode": {
"extensions": [
"mads-hartmann.bash-ide-vscode"
"mads-hartmann.bash-ide-vscode",
"mhutchie.git-graph"
]
}
}
Expand Down
2 changes: 2 additions & 0 deletions .devcontainer/devcontainers-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"name": "@devcontainers/cli",
"id": "devcontainers-cli",
"version": "0.0.1",
"installsAfter": [
"ghcr.io/devcontainers/features/node"
]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
packages: write

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pin@v6

- name: "publish Features"
uses: devcontainers/action@1082abd5d2bf3a11abccba70eef98df068277772 # pin@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
baseImage:
- mcr.microsoft.com/devcontainers/base:ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pin@v6

- name: "install latest devcontainer CLI"
run: npm install -g @devcontainers/cli@0.72.0
run: npm install -g @devcontainers/cli@0.84.1

- name: "generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'"
run: devcontainer features test --skip-duplicated -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .
2 changes: 1 addition & 1 deletion .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pin@v6

- name: "validate devcontainer-feature.json files"
uses: devcontainers/action@1082abd5d2bf3a11abccba70eef98df068277772 # pin@v1
Expand Down
8 changes: 5 additions & 3 deletions src/nerdctl/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# containerd control CLI (nerdctl)
# nerdctl containerd control CLI and CNI plugins (nerdctl)

Installs nerdctl from upstream.
Installs nerdctl and CNI plugins from upstream.

## Example Usage

Expand All @@ -15,7 +15,9 @@ Installs nerdctl from upstream.

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| version | version of cni-plugins to install | string | latest |
| version | version of nerdctl to install | string | latest |
| cni | additionally install CNI plugins from nerdctl-full | boolean | true |
| cni-path | path to install CNI plugin binaries into | string | /usr/libexec/cni |
| containerd-api | path to containerd API endpoint | string | unix:///run/containerd/containerd.sock |

## Combining with `docker-in-docker` Feature
Expand Down
18 changes: 14 additions & 4 deletions src/nerdctl/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
{
"name": "containerd control CLI",
"name": "nerdctl containerd control CLI and CNI plugins",
"id": "nerdctl",
"version": "0.0.1",
"description": "Installs nerdctl from upstream.",
"version": "0.1.0",
"description": "Installs nerdctl and CNI plugins from upstream.",
"options": {
"version": {
"type": "string",
"default": "latest",
"description": "version of cni-plugins to install"
"description": "version of nerdctl to install"
},
"cni": {
"type": "boolean",
"default": true,
"description": "additionally install CNI plugins from nerdctl-full"
},
"cni-path": {
"type": "string",
"default": "/usr/libexec/cni",
"description": "path to install CNI plugin binaries into"
},
"containerd-api": {
"type": "string",
Expand Down
38 changes: 31 additions & 7 deletions src/nerdctl/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
set -e

NERDCTL_VERSION="${VERSION:-"latest"}"
INSTALL_CNI="${CNI:-true}"
CNI_PATH="${CNI_PATH:-/usr/libexec/cni}"
CONTAINERD_API="${CONTAINERD_API:-"unix:///run/containerd/containerd.sock"}"

REPOSLUG="containerd/nerdctl"
Expand Down Expand Up @@ -142,20 +144,42 @@ fi

if [ "$NERDCTL_VERSION" = "latest" ]; then
# get latest release
NERDCTL_VERSION=$(curl -s ${QUERYLATEST_URL} | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
NERDCTL_VERSION=$(curl -s ${QUERYLATEST_URL} \
| grep '"tag_name":' \
| sed -E 's/.*"([^"]+)".*/\1/')
fi

echo version: $NERDCTL_VERSION
echo for arch: $ARCH
echo "version: ${NERDCTL_VERSION}"
echo "for arch: ${ARCH}"
echo "install CNI plugins: ${INSTALL_CNI}"

URL="${RELEASE_URL}${NERDCTL_VERSION}/nerdctl-${NERDCTL_VERSION#v}-linux-${ARCH}.tar.gz"
VARIANT=""
if [ "${INSTALL_CNI}" = "true" ]; then
VARIANT="-full"
fi
URL="${RELEASE_URL}${NERDCTL_VERSION}/nerdctl${VARIANT}-${NERDCTL_VERSION#v}-linux-${ARCH}.tar.gz"
echo "${URL}"

curl -sSL -o /tmp/nerdctl.tar.gz "${URL}"
trap 'rm -f /tmp/nerdctl.tar.gz' EXIT
curl -SL --progress-bar -o /tmp/nerdctl.tar.gz "${URL}"
ls -lH /tmp/nerdctl.tar.gz
tar xzof /tmp/nerdctl.tar.gz -C /usr/local/bin/ nerdctl

echo "installing nerdctl binary..."
mkdir -p /usr/local/bin
if [ "${INSTALL_CNI}" = "true" ]; then
tar -xzf /tmp/nerdctl.tar.gz --strip-components=1 -C /usr/local/bin bin/nerdctl
else
tar -xzf /tmp/nerdctl.tar.gz -C /usr/local/bin nerdctl
fi
chmod 0755 /usr/local/bin/nerdctl
rm /tmp/nerdctl.tar.gz


if [ "${INSTALL_CNI}" = "true" ]; then
echo "installing CNI binaries..."
mkdir -p "${CNI_PATH}"
tar -xzf /tmp/nerdctl.tar.gz --strip-components=2 -C "${CNI_PATH}" --wildcards 'libexec/cni/*'
find "${CNI_PATH}" -maxdepth 1 -type f -exec chmod 0755 {} \;
fi

mkdir -p /etc/nerdctl
cat <<EOF >"/etc/nerdctl/nerdctl.toml"
Expand Down
4 changes: 4 additions & 0 deletions test/docsify/almalinux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -e

. ./test.sh
4 changes: 4 additions & 0 deletions test/docsify/alpine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -e

. ./test.sh
6 changes: 6 additions & 0 deletions test/docsify/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,11 @@
"docs-path": "foobar"
}
}
},
"almalinux": {
"image": "ghcr.io/almalinux/almalinux:9",
"features":{
"docsify": {}
}
}
}
2 changes: 2 additions & 0 deletions test/nerdctl/almalinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ source dev-container-features-test-lib

check "nerdctl" bash -c "nerdctl --version"

check "no CNI plugins" bash -c "[ ! -x /usr/libexec/cni/firewall ]"

reportResults
2 changes: 2 additions & 0 deletions test/nerdctl/debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ source dev-container-features-test-lib
# (whalewatchers: hold my beer...)
check "nerdctl" bash -c "sudo nerdctl ps"

check "CNI firewall plugin" bash -c "[ -x /usr/local/bin/cni/firewall ]"

reportResults
5 changes: 2 additions & 3 deletions test/nerdctl/fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ set -e

source dev-container-features-test-lib

# as we're combining this test with docker-in-docker, containerd's socket isn't
# in its default location and we explicitly specify it in this feature's options
# (whalewatchers: hold my beer...)
check "nerdctl" bash -c "nerdctl --version"

check "no CNI plugins" bash -c "[ ! -x /usr/libexec/cni/firewall ]"

reportResults
12 changes: 9 additions & 3 deletions test/nerdctl/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,31 @@
"almalinux": {
"image": "ghcr.io/almalinux/almalinux:9",
"features": {
"nerdctl": {}
"nerdctl": {
"cni": false
}
}
},
"debian": {
"image": "mcr.microsoft.com/devcontainers/base:debian-12",
"image": "mcr.microsoft.com/devcontainers/base:debian-13",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"moby": false,
"dockerDashComposeVersion": "none",
"installDockerBuildx": false
},
"nerdctl": {
"cni-path": "/usr/local/bin/cni",
"containerd-api": "unix:///run/docker/containerd/containerd.sock"
}
}
},
"fedora": {
"image": "fedora",
"features": {
"nerdctl": {}
"nerdctl": {
"cni": false
}
}
}
}
1 change: 1 addition & 0 deletions test/nerdctl/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ set -e
source dev-container-features-test-lib

check "nerdctl" bash -c "nerdctl --version"
check "CNI firewall plugin" bash -c "[ -x /usr/libexec/cni/firewall ]"

reportResults
Loading