diff options
author | Samruddhi Khandale <skhandale@microsoft.com> | 2022-05-27 21:27:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-27 21:27:17 +0300 |
commit | cb6a53949966af46935dd17cc43b5ddc0498b354 (patch) | |
tree | db10fd6eda9b931c8f259a1a0b1fcc297cc8b106 | |
parent | e496022c568e9f6f42b41cda37f8d2e929eb3564 (diff) |
Add oryx feature (#27)
* add oryx
* modify oryx sh
* add oryx in matrix
* install dotnet
* fix permission
* test
* test 2
* test 3
* fix dotnet
* fix oryx
* fix
* fix path issues + debugging
* remove debugging
* add oryx test to actions
* fix test
* modify test
* add $
* fix user
* address comments
* add repo
* add wget
* allow apt-update
* add --no-check-certificate
* install ca-certificates
* install with another approach
* fix infinite test runs
* Update src/oryx/install.sh
Co-authored-by: Josh Spicer <joshspicer@github.com>
Co-authored-by: Josh Spicer <joshspicer@github.com>
-rw-r--r-- | .github/workflows/test-all.yaml | 1 | ||||
-rw-r--r-- | .github/workflows/test-pr.yaml | 1 | ||||
-rw-r--r-- | src/oryx/feature.json | 14 | ||||
-rwxr-xr-x | src/oryx/install.sh | 126 | ||||
-rw-r--r-- | test/oryx/test.sh | 14 | ||||
-rw-r--r-- | v1/feature-scripts.env | 1 |
6 files changed, 157 insertions, 0 deletions
diff --git a/.github/workflows/test-all.yaml b/.github/workflows/test-all.yaml index 296ddeb..a434a73 100644 --- a/.github/workflows/test-all.yaml +++ b/.github/workflows/test-all.yaml @@ -29,6 +29,7 @@ jobs: "python jupyterlab", # Install 'python', then 'jupyterlab' "kubectl-helm-minikube", "node", + "oryx", "php", "powershell", "python", diff --git a/.github/workflows/test-pr.yaml b/.github/workflows/test-pr.yaml index 8dc097f..b750bbd 100644 --- a/.github/workflows/test-pr.yaml +++ b/.github/workflows/test-pr.yaml @@ -29,6 +29,7 @@ jobs: 'python jupyterlab': ./**/jupyterlab/** kubectl-helm-minikube: ./**/kubectl-helm-minikube/** node: ./**/node/** + oryx: ./**/oryx/** php: ./**/php/** powershell: ./**/powershell/** python: ./**/python/** diff --git a/src/oryx/feature.json b/src/oryx/feature.json new file mode 100644 index 0000000..10a468b --- /dev/null +++ b/src/oryx/feature.json @@ -0,0 +1,14 @@ +{ + "id": "oryx", + "name": "Oryx", + "containerEnv": { + "PATH":"usr/local/oryx:${PATH}", + "ORYX_SDK_STORAGE_BASE_URL":"https://oryx-cdn.microsoft.io", + "ENABLE_DYNAMIC_INSTALL":"true", + "DYNAMIC_INSTALL_ROOT_DIR":"/usr/local" + }, + "install": { + "app": "", + "file": "install.sh" + } +}
\ No newline at end of file diff --git a/src/oryx/install.sh b/src/oryx/install.sh new file mode 100755 index 0000000..22c12d8 --- /dev/null +++ b/src/oryx/install.sh @@ -0,0 +1,126 @@ +#!/usr/bin/env bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- +# +# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/hugo.md +# Maintainer: The VS Code and Codespaces Teams +# +# Syntax: ./oryx-debian.sh [Non-root user] + +USERNAME=${1:-"automatic"} +UPDATE_RC=${2:-"true"} + +set -eu + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +# Ensure that login shells get the correct path if the user updated the PATH using ENV. +rm -f /etc/profile.d/00-restore-env.sh +echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh +chmod +x /etc/profile.d/00-restore-env.sh + +# Determine the appropriate non-root user +if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then + USERNAME="" + POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") + for CURRENT_USER in ${POSSIBLE_USERS[@]}; do + if id -u ${CURRENT_USER} > /dev/null 2>&1; then + USERNAME=${CURRENT_USER} + break + fi + done + if [ "${USERNAME}" = "" ]; then + USERNAME=root + fi +elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then + USERNAME=root +fi + +function updaterc() { + if [ "${UPDATE_RC}" = "true" ]; then + echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/zsh/zshrc + fi + fi +} + +# Function to run apt-get if needed +apt_get_update_if_needed() +{ + if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update + else + echo "Skipping apt-get update." + fi +} + +# Checks if packages are installed and installs them if not +check_packages() { + if ! dpkg -s "$@" > /dev/null 2>&1; then + apt_get_update_if_needed + DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends "$@" + fi +} + +install_dotnet_using_apt() { + wget --no-check-certificate https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb + sudo dpkg -i packages-microsoft-prod.deb + rm packages-microsoft-prod.deb + + rm -rf /var/lib/apt/lists/* + check_packages apt-transport-https dotnet-sdk-6.0 +} + +# Install dependencies +check_packages git sudo wget ca-certificates + +# If we don't already have Oryx installed, install it now. +if ! oryx --version > /dev/null ; then + echo "Installing Oryx..." + + # Install dotnet unless available + if ! dotnet --version > /dev/null ; then + echo "'dotnet' was not detected. Attempting to install the latest version of the dotnet sdk to build oryx." + install_dotnet_using_apt + + if ! dotnet --version > /dev/null ; then + echo "Please install Dotnet before installing Oryx" + exit 1 + fi + fi + + BUILD_SCRIPT_GENERATOR=/usr/local/buildscriptgen + ORYX=/usr/local/oryx + GIT_ORYX=/tmp/oryx + + mkdir -p ${BUILD_SCRIPT_GENERATOR} + mkdir -p ${ORYX} + + chown -R ${USERNAME} ${BUILD_SCRIPT_GENERATOR} ${ORYX} + git clone --depth=1 https://github.com/microsoft/Oryx $GIT_ORYX + + $GIT_ORYX/build/buildSln.sh + + dotnet publish -property:ValidateExecutableReferencesMatchSelfContained=false -r linux-x64 -o ${BUILD_SCRIPT_GENERATOR} -c Release $GIT_ORYX/src/BuildScriptGeneratorCli/BuildScriptGeneratorCli.csproj + + dotnet publish -r linux-x64 -o ${BUILD_SCRIPT_GENERATOR} -c Release $GIT_ORYX/src/BuildServer/BuildServer.csproj + + chmod a+x ${BUILD_SCRIPT_GENERATOR}/GenerateBuildScript + + ln -s ${BUILD_SCRIPT_GENERATOR}/GenerateBuildScript ${ORYX}/oryx + cp -f $GIT_ORYX/images/build/benv.sh ${ORYX}/benv + + updaterc "export PATH=$PATH:/usr/local/oryx && export ORYX_SDK_STORAGE_BASE_URL=https://oryx-cdn.microsoft.io && export ENABLE_DYNAMIC_INSTALL=true && DYNAMIC_INSTALL_ROOT_DIR=/usr/local" +fi + +echo "Done!" diff --git a/test/oryx/test.sh b/test/oryx/test.sh new file mode 100644 index 0000000..fd3a955 --- /dev/null +++ b/test/oryx/test.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +check "Oryx version" oryx --version +check "Dotnet version" dotnet --version +check "ORYX_SDK_STORAGE_BASE_URL" echo $ORYX_SDK_STORAGE_BASE_URL +check "ENABLE_DYNAMIC_INSTALL" echo $ENABLE_DYNAMIC_INSTALL + +# Report result +reportResults
\ No newline at end of file diff --git a/v1/feature-scripts.env b/v1/feature-scripts.env index 68573da..701c439 100644 --- a/v1/feature-scripts.env +++ b/v1/feature-scripts.env @@ -22,3 +22,4 @@ _BUILD_ARG_DESKTOP_LITE="./desktop-lite/install.sh auto _BUILD_ARG_DOTNET="./dotnet/install.sh ${_BUILD_ARG_DOTNET_VERSION:-latest} ${_BUILD_ARG_DOTNET_RUNTIMEONLY:-false} automatic true /usr/local/dotnet dotnet" _BUILD_ARG_JUPYTERLAB="./jupyterlab/install.sh ${_BUILD_ARG_JUPYTERLAB_VERSION:-latest}" automatic ${_BUILD_ARG_JUPYTERLAB_PYTHONBINARY:-python}" true _BUILD_ARG_PHP="./php/install.sh ${_BUILD_ARG_PHP_VERSION:-latest} /usr/local/php ${_BUILD_ARG_PHP_INSTALLCOMPOSER:-true} true automatic true" +_BUILD_ARG_ORYX="./oryx/install.sh"
\ No newline at end of file |