diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index cd89179766..0000000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.148.1/containers/go/.devcontainer/base.Dockerfile - -# [Choice] Go version: 1, 1.15, 1.14 -ARG VARIANT="1" -FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT} - -ARG USERNAME="vscode" - -# [Option] Install Node.js -ARG INSTALL_NODE="false" -ARG NODE_VERSION="lts/*" -RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi - -# Install pip3 and HTTPie -RUN apt-get update \ - && apt-get install -y python3 python3-pip httpie - -# Install Docker CE -RUN apt-get update \ - && apt-get install -y apt-transport-https ca-certificates curl gnupg2 lsb-release \ - && curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | apt-key add - 2>/dev/null \ - && echo "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list \ - && apt-get update \ - && apt-get install -y docker-ce-cli - -# Install kubectl -RUN curl -sSL -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \ - && chmod +x /usr/local/bin/kubectl - -# Install Helm -RUN curl -s https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash - - -# Update credentials for Kubernetes to match container environment -# Script copies localhost's ~/.kube/config file into the container and swaps out -# localhost for host.docker.internal on bash/zsh start to keep them in sync. -COPY init-profile.sh /usr/local/share/ -COPY copy-kube-config.sh /usr/local/share/ -RUN /usr/local/share/init-profile.sh ${USERNAME} \ No newline at end of file diff --git a/.devcontainer/copy-kube-config.sh b/.devcontainer/copy-kube-config.sh deleted file mode 100755 index 9e5f785579..0000000000 --- a/.devcontainer/copy-kube-config.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -i - -echo "running copy-kube-config.sh" -echo "SYNC_LOCALHOST_KUBECONFIG=$SYNC_LOCALHOST_KUBECONFIG" - -if [ "$SYNC_LOCALHOST_KUBECONFIG" = "true" ] && [ ! -d "/usr/local/share/kube-localhost" ]; then - echo "/usr/local/share/kube-localhost does not exist" - exit 1 -fi - -# Copies localhost's ~/.kube/config file into the container and swap out localhost -# for host.docker.internal whenever a new shell starts to keep them in sync. -if [ "$SYNC_LOCALHOST_KUBECONFIG" = "true" ] && [ -d "/usr/local/share/kube-localhost" ]; then - mkdir -p $HOME/.kube - sudo cp -r /usr/local/share/kube-localhost/* $HOME/.kube - sudo chown -R $(id -u) $HOME/.kube - sed -i -e "s/localhost/host.docker.internal/g" $HOME/.kube/config - sed -i -e "s/127.0.0.1/host.docker.internal/g" $HOME/.kube/config - - # If .minikube was mounted, set up client cert/key - if [ -d "/usr/local/share/minikube-localhost" ]; then - mkdir -p $HOME/.minikube - sudo cp -r /usr/local/share/minikube-localhost/ca.crt $HOME/.minikube - # Location varies between versions of minikube - if [ -f "/usr/local/share/minikube-localhost/client.crt" ]; then - sudo cp -r /usr/local/share/minikube-localhost/client.crt $HOME/.minikube - sudo cp -r /usr/local/share/minikube-localhost/client.key $HOME/.minikube - elif [ -f "/usr/local/share/minikube-localhost/profiles/minikube/client.crt" ]; then - sudo cp -r /usr/local/share/minikube-localhost/profiles/minikube/client.crt $HOME/.minikube - sudo cp -r /usr/local/share/minikube-localhost/profiles/minikube/client.key $HOME/.minikube - fi - sudo chown -R $(id -u) $HOME/.minikube - - # Point .kube/config to the correct locaiton of the certs - sed -i -r "s|(\s*certificate-authority:\s).*|\\1$HOME\/.minikube\/ca.crt|g" $HOME/.kube/config - sed -i -r "s|(\s*client-certificate:\s).*|\\1$HOME\/.minikube\/client.crt|g" $HOME/.kube/config - sed -i -r "s|(\s*client-key:\s).*|\\1$HOME\/.minikube\/client.key|g" $HOME/.kube/config - fi -fi \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index abd3824024..3bc1f51687 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,37 +1,22 @@ { - "name": "Radius", - "dockerComposeFile": ["./docker-compose.yaml"], - "service": "rp", - "workspaceFolder": "/workspace/radius", - "remoteEnv": { - "SYNC_LOCALHOST_KUBECONFIG": "true" - }, - "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], - + "name": "Codespaces for Radius tutorials", + + "image": "radiusteam/radcodespace:latest", + // Set *default* container specific settings.json values on container create. - "settings": { - "terminal.integrated.shell.linux": "/bin/bash", - "go.useGoProxyToCheckForToolUpdates": false, - "go.useLanguageServer": true, - "go.gopath": "/go", - "go.goroot": "/usr/local/go", - "go.toolsGopath": "/go/bin" + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" }, - + // Add the IDs of extensions you want installed when the container is created. "extensions": [ - "golang.Go", - "ms-azuretools.vscode-docker", - "ms-kubernetes-tools.vscode-kubernetes-tools" + "ms-vscode.azurecli", + "ms-dotnettools.vscode-dotnet-runtime", + "/home/rad-vscode-bicep.vsix" ], + + "forwardPorts": [3000], - // Use 'forwardPorts' to make a list of ports inside the container available locally. - "forwardPorts": [5000], - - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "&& go mod download", - - // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode", - "shutdownAction": "stopCompose" + // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" } diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml deleted file mode 100644 index 35539d6800..0000000000 --- a/.devcontainer/docker-compose.yaml +++ /dev/null @@ -1,37 +0,0 @@ -version: '3' -services: - rp: - image: rp-devcontainer - build: - context: '.' - args: - VARIANT: '1.15' - INSTALL_NODE: 'false' - command: /bin/bash -c "while sleep 1000; do :; done" - environment: - - 'SKIP_AUTH=true' - - 'PORT=5000' - - 'MONGODB_CONNECTION_STRING=mongodb://mongoadmin:secret@mongo:27017/rpdb?authSource=admin' - - 'MONGODB_DATABASE=rpdb' - - 'K8S_LOCAL=true' - - 'SUBSCRIPTION_ID=test-subscription' - - 'RESOURCE_GROUP=test-resource-group' - - 'RESOURCE_PROVIDER=test-resource-provider' - - 'URL_BASE=http://localhost:5000/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Microsoft.CustomProviders/resourceProviders/test-resource-provider' - volumes: - - '..:/workspace/radius-rp:cached' - - '/var/run/docker.sock:/var/run/docker.sock' - - '${HOME}${USERPROFILE}/.kube:/usr/local/share/kube-localhost' - #- '${HOME}${USERPROFILE}/.minikube:/usr/local/share/minikube-localhost' - depends_on: - - mongo - network_mode: service:mongo - - mongo: - image: mongo - ports: - - '27017' - environment: - - MONGO_INITDB_ROOT_USERNAME=mongoadmin - - MONGO_INITDB_ROOT_PASSWORD=secret - - MONGO_INITDB_DATABASE=rpdb \ No newline at end of file diff --git a/.devcontainer/init-profile.sh b/.devcontainer/init-profile.sh deleted file mode 100755 index b1cc0246b6..0000000000 --- a/.devcontainer/init-profile.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -i -set -eu - -USERNAME=$1 - -echo "running init-profile.sh" -echo "current user is $(whoami)" -echo "target user is $(whoami)" -echo "current user HOME is $HOME" -echo "target user HOME is /home/$USERNAME/" - -if [[ -e "/home/$USERNAME/.profile" ]] -then - echo "/home/$USERNAME/.profile exists" -else - echo "/home/$USERNAME/.profile not found" -fi - -if [[ -e "/home/$USERNAME/.bashrc" ]] -then - echo "/home/$USERNAME/.bashrc exists" -else - echo "/home/$USERNAME/.bashrc not found" -fi - -if [[ -e "/home/$USERNAME/.zshrc" ]] -then - echo "/home/$USERNAME/.zshrc exists" -else - echo "/home/$USERNAME/.zshrc not found" -fi - -chown $USERNAME:root /usr/local/share/copy-kube-config.sh \ - && echo "source /usr/local/share/copy-kube-config.sh" | tee -a /root/.bashrc /root/.zshrc /home/$USERNAME/.bashrc >> /home/$USERNAME/.zshrc \ No newline at end of file diff --git a/.devcontainer/tutorials-codespace/Dockerfile b/.devcontainer/tutorials-codespace/Dockerfile new file mode 100644 index 0000000000..963635171c --- /dev/null +++ b/.devcontainer/tutorials-codespace/Dockerfile @@ -0,0 +1,23 @@ +ARG VARIANT=3.1 +FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT} + +USER root + +# Install library scripts & setup "first notice" +COPY library-scripts/* first-run-notice.txt /tmp/library-scripts/ +RUN bash /tmp/library-scripts/azcli-debian.sh \ + && bash /tmp/library-scripts/kubectl-helm-debian.sh \ + && mv -f /tmp/library-scripts/first-run-notice.txt /usr/local/etc/vscode-dev-containers/ \ + && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts + +# Install rad CLI (Linux) +# TODO: change to make binary directly inside this Dockerfile? +RUN wget -O /usr/local/bin/rad https://radiuspublic.blob.core.windows.net/tools/rad/edge/linux-x64/rad +RUN chmod +rx /usr/local/bin/rad + +# Download Radius VSCode extension +RUN wget -O /home/rad-vscode-bicep.vsix https://radiuspublic.blob.core.windows.net/tools/vscode/edge/rad-vscode-bicep.vsix + +USER vscode + +RUN touch ~/.vimrc \ No newline at end of file diff --git a/.devcontainer/tutorials-codespace/first-run-notice.txt b/.devcontainer/tutorials-codespace/first-run-notice.txt new file mode 100644 index 0000000000..f1c4806a08 --- /dev/null +++ b/.devcontainer/tutorials-codespace/first-run-notice.txt @@ -0,0 +1,5 @@ + +👋 Welcome to the Radius Codespace! You are on our Radius Tutorials image. It includes everything needed to run through our tutorials and example applications. +Radius docs can be found here: https://radapp.dev/ + + diff --git a/.devcontainer/tutorials-codespace/library-scripts/azcli-debian.sh b/.devcontainer/tutorials-codespace/library-scripts/azcli-debian.sh new file mode 100644 index 0000000000..57c01aa0ca --- /dev/null +++ b/.devcontainer/tutorials-codespace/library-scripts/azcli-debian.sh @@ -0,0 +1,34 @@ +#!/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/master/script-library/docs/azcli.md +# Maintainer: The VS Code and Codespaces Teams +# +# Syntax: ./azcli-debian.sh + +set -e + +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 + +export DEBIAN_FRONTEND=noninteractive + +# Install curl, apt-transport-https, lsb-release, or gpg if missing +if ! dpkg -s apt-transport-https curl ca-certificates lsb-release > /dev/null 2>&1 || ! type gpg > /dev/null 2>&1; then + if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then + apt-get update + fi + apt-get -y install --no-install-recommends apt-transport-https curl ca-certificates lsb-release gnupg2 +fi + +# Install the Azure CLI +echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/azure-cli.list +curl -sL https://packages.microsoft.com/keys/microsoft.asc | (OUT=$(apt-key add - 2>&1) || echo $OUT) +apt-get update +apt-get install -y azure-cli +echo "Done!" diff --git a/.devcontainer/tutorials-codespace/library-scripts/kubectl-helm-debian.sh b/.devcontainer/tutorials-codespace/library-scripts/kubectl-helm-debian.sh new file mode 100644 index 0000000000..25b2129e5a --- /dev/null +++ b/.devcontainer/tutorials-codespace/library-scripts/kubectl-helm-debian.sh @@ -0,0 +1,36 @@ +#!/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/master/script-library/docs/kubectl-helm.md +# Maintainer: The VS Code and Codespaces Teams +# +# Syntax: ./kubectl-helm-debian.sh + +set -e + +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 + +export DEBIAN_FRONTEND=noninteractive + +# Install curl if missing +if ! dpkg -s curl ca-certificates > /dev/null 2>&1; then + if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then + apt-get update + fi + apt-get -y install --no-install-recommends curl ca-certificates +fi + +# Install the kubectl +echo "Downloading kubectl..." +curl -sSL -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl +chmod +x /usr/local/bin/kubectl +# Install Helm +echo "Installing Helm..." +curl -s https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash - +echo "Done!" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e1a8da6a0d..7371c9eb9b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -265,10 +265,57 @@ jobs: connection_string: ${{ secrets.ASSETS_STORAGE_CONNECTION_STRING }} sync: true extra_args: '--destination-path rad/${{ env.REL_CHANNEL }}/windows-x64/ --pattern rad.exe' - - uses: bacongobbler/azure-blob-storage-upload@v1.1.1 + + codespaces: + name: Codespaces container image build + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Parse release version and set environment variables + run: python ./.github/scripts/get_release_version.py + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 with: - source_dir: install - container_name: 'tools' - connection_string: ${{ secrets.ASSETS_STORAGE_CONNECTION_STRING }} - sync: true - extra_args: '--destination-path rad/ --pattern install.*' + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: '${{ secrets.RADIUSTEAM_DOCKERHUB_USERNAME }}' + password: '${{ secrets.RADIUSTEAM_DOCKERHUB_PASSWORD }}' + - name: Build and push - Codespaces (latest) + if: (github.ref == 'refs/heads/main') # push image on push to main + uses: docker/build-push-action@v2 + with: + context: ./.devcontainer/tutorials-codespace/ + builder: ${{ steps.buildx.outputs.name }} + push: true + tags: radiusteam/radcodespace:latest + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + - name: Build and push - Codespaces (PR) + if: startsWith(github.ref, 'refs/pull/') # push image on pr + uses: docker/build-push-action@v2 + with: + context: ./.devcontainer/tutorials-codespace/ + builder: ${{ steps.buildx.outputs.name }} + push: false # don't push image on pr + tags: radiusteam/radcodespace:${{ env.REL_VERSION }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + - name: Build and push - Codespaces (release) + if: startsWith(github.ref, 'refs/tags/v') # push image on tag + uses: docker/build-push-action@v2 + with: + context: ./.devcontainer/tutorials-codespace/ + builder: ${{ steps.buildx.outputs.name }} + push: true + tags: radiusteam/radcodespace:${{ env.REL_CHANNEL }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache diff --git a/SUPPORT.md b/SUPPORT.md index aecb2524c5..ed201ba337 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -8,4 +8,4 @@ For help and questions about using this project, please email radiusct@microsoft ## Microsoft Support Policy -Support for this project is limited to the resources listed above. +Support for this project is limited to the resources listed above. \ No newline at end of file