diff --git a/src/magicmirror/devcontainer-feature.json b/src/magicmirror/devcontainer-feature.json index 00652c6..ac40fc9 100644 --- a/src/magicmirror/devcontainer-feature.json +++ b/src/magicmirror/devcontainer-feature.json @@ -3,6 +3,10 @@ "id": "magicmirror", "version": "1.0.3", "description": "Automatic mirror setup for package managers like apt, pypi, apk etc.", + "entrypoint": "/usr/local/bin/magicmirror.sh", + "installsAfter": [ + "ghcr.io/devcontainers/features/common-utils" + ], "options": { "pypi_mirror": { "type": "string", @@ -36,8 +40,5 @@ "default": "", "description": "Huggingface mirror" } - }, - "installsAfter": [ - "ghcr.io/devcontainers/features/common-utils" - ] + } } diff --git a/src/magicmirror/install.sh b/src/magicmirror/install.sh index 16a745b..dd5f3b0 100644 --- a/src/magicmirror/install.sh +++ b/src/magicmirror/install.sh @@ -47,13 +47,18 @@ if [ "${OS}" = '"Alpine Linux"' ] && [ -n "${APK_MIRROR}" ]; then sed -i "s/dl-cdn.alpinelinux.org/${APK_MIRROR}/g" /etc/apk/repositories fi +# add entrypoint script +cat > /usr/local/bin/magicmirror.sh << EOF +#!/bin/sh +echo "running magicmirror entrypoint" +EOF +chmod +x /usr/local/bin/magicmirror.sh + # Set Huggingface mirror if it's provided HUGGINGFACE_MIRROR=${HUGGINGFACE_MIRROR:-""} echo "HUGGINGFACE_MIRROR: $HUGGINGFACE_MIRROR" if [ -n "${HUGGINGFACE_MIRROR}" ]; then echo "Enabling Huggingface mirror: ${HUGGINGFACE_MIRROR}" - touch /etc/environment && cp /etc/environment /etc/environment.mm.bak - echo "HF_ENDPOINT=${HUGGINGFACE_MIRROR}" >> /etc/environment - # export the new env - set -a; . /etc/environment; set +a; + echo "Injecting HF_ENDPOINT value setting into magicmirror.sh" + echo "export HF_ENDPOINT=${HUGGINGFACE_MIRROR};echo \${HF_ENDPOINT}" >> /usr/local/bin/magicmirror.sh fi diff --git a/test/magicmirror/hf.sh b/test/magicmirror/hf.sh index d007abe..756e472 100644 --- a/test/magicmirror/hf.sh +++ b/test/magicmirror/hf.sh @@ -12,8 +12,8 @@ source dev-container-features-test-lib # The 'check' command comes from the dev-container-features-test-lib. # TODO[sidecus]: Workaround for the test case since /env/environment is not loaded in test case scenarios # Should consider using containerEnv if this is solved: https://github.com/devcontainers/spec/issues/164 -# check "test HF mirror" bash -c "test \"${HF_ENDPOINT}\" = \"https://dummy-hf-mirror.com\"" -check "test HF mirror" bash -c "cat /etc/environment | grep 'https://dummy-hf-mirror.com'" +check "test HF mirror" bash -c "test \"${HF_ENDPOINT}\" = \"https://dummy-hf-mirror.com\"" +# check "test HF mirror" bash -c "cat /etc/environment | grep 'https://dummy-hf-mirror.com'" # Report results # If any of the checks above exited with a non-zero exit code, the test will fail.