Skip to content

Commit 82b9294

Browse files
authored
chore: use feature dependencies (#11)
use the (as of yet) unreleased feature dependency
1 parent 830ba03 commit 82b9294

8 files changed

Lines changed: 86 additions & 262 deletions

File tree

.devcontainer.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
}
1919
},
2020
"features": {
21-
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
22-
"ghcr.io/devcontainers/features/python:1": {
23-
"version": "3.10"
24-
}
21+
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
2522
},
2623
"remoteUser": "node",
2724
"updateContentCommand": "npm install -g @devcontainers/cli"

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
# Renku Dev Container Feature
1+
# Renku project devcontainer features
22

3-
The renku devcontainer feature installs the Renku CLI and supporting packages like git and git-lfs.
3+
A set of devcontainer features for easier runtime configurations.
4+
5+
* [renku](src/renku/) (installs the renku CLI and supporting packages)

src/renku/devcontainer-feature.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,25 @@
1717
"createUser": {
1818
"type": "boolean",
1919
"default": true,
20-
"description": "Whether to create the chosen user if missing."
20+
"description": "Create the chosen user if missing."
2121
},
2222
"installJupyter": {
2323
"type": "boolean",
2424
"default": true,
2525
"description": "Install the Jupyter stack."
2626
}
2727
},
28-
"installsAfter": [
29-
"ghcr.io/devcontainers-contrib/features/pipx-package",
30-
"ghcr.io/devcontainers/features/python",
31-
"ghcr.io/rocker-org/devcontainer-features/miniforge",
32-
"ghcr.io/devcontainers/features/git",
33-
"ghcr.io/devcontainers/features/git-lfs"
34-
],
35-
"containerEnv": {
36-
"CONDA_DIR": "/opt/conda",
37-
"CONDA_SCRIPT": "/opt/conda/etc/profile.d/conda.sh",
38-
"PATH": "/opt/conda/bin:${PATH}"
39-
}
28+
"dependsOn": {
29+
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
30+
"packages": "build-essential,bzip2,ca-certificates,curl,gpg-agent,gnupg,libglib2.0-0,libsm6,libxext6,libxrender1,rclone,tini,wget,vim,jq"
31+
},
32+
"ghcr.io/devcontainers/features/python:1": {
33+
"version": "3.10"
34+
},
35+
"ghcr.io/rocker-org/devcontainer-features/miniforge:1": {},
36+
"ghcr.io/devcontainers/features/git:1": {},
37+
"ghcr.io/devcontainers/features/git-lfs:1": {
38+
"version": "3.3.0"
39+
}
40+
}
4041
}

src/renku/install.sh

Lines changed: 11 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,19 @@
11
#!/bin/bash -i
2-
set -e
2+
set -ex
33

44
USER_ID=1000
5-
USERNAME=${USERNAME:-${_REMOTE_USER:-"automatic"}}
5+
USERNAME=${USERNAME:-${_REMOTE_USER}}
66

77
echo "Activating feature Renku"
88

9-
source ./library_scripts.sh
10-
11-
ensure_nanolayer nanolayer_location "v0.4.45"
12-
13-
# install git
14-
$nanolayer_location \
15-
install \
16-
devcontainer-feature \
17-
"ghcr.io/devcontainers/features/git:1"
18-
19-
VERSION=${VERSION:-undefined}
9+
VERSION=${VERSION:-"latest"}
2010
if [ "${VERSION}" = "latest" ]; then
21-
VERSION=$(git ls-remote --tags "https://github.com/swissdatasciencecenter/renku-python" | grep -oP "tags/v\K[0-9]+\.[0-9]+\.[0-9]+$" | sort -rV | head -n 1)
11+
VERSION=$(curl -s https://pypi.org/pypi/renku/json | jq '.releases | keys | sort | .[]' | grep -oP "\"[0-9]+\.[0-9]+\.[0-9]\"" | tr -d '"' | sort -rV | head -n 1)
2212
fi
2313
echo "The requested version is: $VERSION"
2414

25-
# install apt packages
26-
apt-get update --fix-missing && \
27-
apt-get install -yq --no-install-recommends \
28-
build-essential \
29-
bzip2 \
30-
ca-certificates \
31-
curl \
32-
gpg-agent \
33-
gnupg \
34-
libglib2.0-0 \
35-
libsm6 \
36-
libxext6 \
37-
libxrender1 \
38-
rclone \
39-
tini \
40-
wget \
41-
vim && \
42-
apt-get purge && \
43-
apt-get clean && \
44-
apt-get autoremove --yes && \
45-
rm -rf /var/lib/apt/lists/* && \
46-
47-
$nanolayer_location \
48-
install \
49-
devcontainer-feature \
50-
"ghcr.io/rocker-org/devcontainer-features/miniforge:1"
51-
52-
$nanolayer_location \
53-
install \
54-
devcontainer-feature \
55-
"ghcr.io/devcontainers/features/git-lfs:1" \
56-
--option version="3.3.0"
57-
58-
$nanolayer_location \
59-
install \
60-
devcontainer-feature \
61-
"ghcr.io/devcontainers-contrib/features/pipx-package:1" \
62-
--option package="renku" --option version="$VERSION"
63-
64-
# Determine the appropriate user
65-
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
66-
USERNAME=""
67-
POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")
68-
for CURRENT_USER in "${POSSIBLE_USERS[@]}"; do
69-
if id -u "${CURRENT_USER}" >/dev/null 2>&1; then
70-
USERNAME=${CURRENT_USER}
71-
break
72-
fi
73-
done
74-
elif ! id -u "${USERNAME}" >/dev/null 2>&1 && [ "$CREATEUSER" = "true" ]; then
15+
# create the user if missing
16+
if ! id -u "${USERNAME}" >/dev/null 2>&1 && [ "$CREATEUSER" = "true" ]; then
7517
useradd -l -m -s /bin/bash -N -u 1000 "${USERNAME}"
7618
fi
7719

@@ -80,3 +22,8 @@ if [ "${INSTALLJUPYTER}" = "true" ]; then
8022
/opt/conda/bin/mamba install -y jupyterlab
8123
ln -sf /opt/conda/bin/jupyter-server /opt/conda/bin/jupyter-notebook
8224
fi
25+
26+
pip install pipx
27+
pipx install renku==${VERSION}
28+
29+
chown -R ${USERNAME} /usr/local/py-utils

src/renku/library_scripts.sh

Lines changed: 0 additions & 179 deletions
This file was deleted.

test/renku/renku-ubuntu-jovyan.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library bundled with the devcontainer CLI
6+
source dev-container-features-test-lib
7+
8+
# Feature-specific tests
9+
# The 'check' command comes from the dev-container-features-test-lib.
10+
check "renku is available" bash -c "renku --help"
11+
check "git-lfs is available" bash -c "git lfs --help"
12+
check "conda is available" bash -c "conda --version"
13+
check "/opt/conda/bin is on PATH" bash -c "grep -q '/opt/conda/bin' <<< '$PATH'"
14+
check "jupyter notebook works" bash -c "jupyter notebook --help"
15+
16+
# check that the user is indeed jovyan
17+
check "user is jovyan" bash -c "whoami | grep jovyan"
18+
19+
# Report results
20+
# If any of the checks above exited with a non-zero exit code, the test will fail.
21+
reportResults
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library bundled with the devcontainer CLI
6+
source dev-container-features-test-lib
7+
8+
# Feature-specific tests
9+
# The 'check' command comes from the dev-container-features-test-lib.
10+
check "renku is available" bash -c "renku --help"
11+
check "git-lfs is available" bash -c "git lfs --help"
12+
check "conda is available" bash -c "conda --version"
13+
check "/opt/conda/bin is on PATH" bash -c "grep -q '/opt/conda/bin' <<< '$PATH'"
14+
check "jupyter notebook works" bash -c "jupyter notebook --help"
15+
16+
# check that the user is indeed jovyan
17+
check "user is randomUser" bash -c "whoami | grep randomUser"
18+
19+
# Report results
20+
# If any of the checks above exited with a non-zero exit code, the test will fail.
21+
reportResults

test/renku/scenarios.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,19 @@
55
"renku": {}
66
},
77
"remoteUser": "jovyan"
8+
},
9+
"renku-ubuntu-jovyan": {
10+
"image": "ubuntu",
11+
"features": {
12+
"renku": {}
13+
},
14+
"remoteUser": "jovyan"
15+
},
16+
"renku-ubuntu-randomUser": {
17+
"image": "ubuntu",
18+
"features": {
19+
"renku": {}
20+
},
21+
"remoteUser": "randomUser"
822
}
923
}

0 commit comments

Comments
 (0)