From 01f3e26064a6f95e823868180381bfea55a32888 Mon Sep 17 00:00:00 2001 From: Emily Potyraj Date: Thu, 8 Apr 2021 09:36:51 -0500 Subject: [PATCH 01/21] change out .devcontainer content to support current requirements inside Codespaces --- .devcontainer/Dockerfile | 45 ++++++++--------------- .devcontainer/copy-kube-config.sh | 39 -------------------- .devcontainer/devcontainer.json | 60 +++++++++++++------------------ .devcontainer/docker-compose.yaml | 37 ------------------- .devcontainer/init-profile.sh | 34 ------------------ 5 files changed, 38 insertions(+), 177 deletions(-) delete mode 100755 .devcontainer/copy-kube-config.sh delete mode 100644 .devcontainer/docker-compose.yaml delete mode 100755 .devcontainer/init-profile.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index cd89179766..8b8e315b8b 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,38 +1,21 @@ -# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.148.1/containers/go/.devcontainer/base.Dockerfile +FROM mcr.microsoft.com/vscode/devcontainers/universal:1.3.0 -# [Choice] Go version: 1, 1.15, 1.14 -ARG VARIANT="1" -FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT} +WORKDIR /home/ -ARG USERNAME="vscode" +COPY . . -# [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 Azure CLI +USER root +RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash # 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 +RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" +RUN install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl -# Install Helm -RUN curl -s https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash - +# Install rad CLI (Linux) +# TODO: change to make binary directly inside this Dockerfile? +RUN wget -O /usr/local/bin/rad --no-check-certificate https://radiuspublic.blob.core.windows.net/tools/rad/edge/linux-x64/rad +RUN chmod +rx /usr/local/bin/rad -# 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 +# 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 \ 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..372629a31f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,37 +1,25 @@ { - "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" ], - - // 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" - }, - - // 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" - ], - - // 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" -} + "name": "GitHub Codespaces (Default)", + "extensions": [ + "coenraads.bracket-pair-colorizer-2", + "cschleiden.vscode-github-actions", + "eamodio.gitlens", + "github.vscode-pull-request-github", + "ms-azuretools.vscode-docker", + "ms-vscode-remote.remote-container", + "ms-vsliveshare.vsliveshare", + "vscode-icons-team.vscode-icons", + "golang.Go", + "ms-kubernetes-tools.vscode-kubernetes-tools", + "/home/rad-vscode-bicep.vsix", + "visualstudioexptteam.vscodeintellicode" + ], + "dockerFile": "Dockerfile", + "settings": { + "terminal.integrated.shell.linux": "/usr/bin/zsh", + "files.exclude": { + "**/CODE_OF_CONDUCT.md": true, + "**/LICENSE": true + } + } +} \ No newline at end of file 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 From 8895dd7150ec564b5e7f9a46c75479ab7d813d62 Mon Sep 17 00:00:00 2001 From: Emily Potyraj Date: Mon, 12 Apr 2021 11:40:07 -0500 Subject: [PATCH 02/21] add auto-build workflow for base Codespaces image --- .devcontainer/Dockerfile | 22 +--------- .devcontainer/devcontainer.json | 44 +++++++++---------- .devcontainer/tutorials-codespace/Dockerfile | 23 ++++++++++ .../tutorials-codespace/first-run-notice.txt | 0 .../library-scripts/README.md | 0 .../library-scripts/azcli-debian.sh | 0 .../library-scripts/kubectl-helm-debian.sh | 0 .github/workflows/codespaces.yaml | 0 8 files changed, 45 insertions(+), 44 deletions(-) create mode 100644 .devcontainer/tutorials-codespace/Dockerfile create mode 100644 .devcontainer/tutorials-codespace/first-run-notice.txt create mode 100644 .devcontainer/tutorials-codespace/library-scripts/README.md create mode 100644 .devcontainer/tutorials-codespace/library-scripts/azcli-debian.sh create mode 100644 .devcontainer/tutorials-codespace/library-scripts/kubectl-helm-debian.sh create mode 100644 .github/workflows/codespaces.yaml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 8b8e315b8b..5fc29db2c4 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,21 +1 @@ -FROM mcr.microsoft.com/vscode/devcontainers/universal:1.3.0 - -WORKDIR /home/ - -COPY . . - -# Install Azure CLI -USER root -RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash - -# Install kubectl -RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" -RUN install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl - -# Install rad CLI (Linux) -# TODO: change to make binary directly inside this Dockerfile? -RUN wget -O /usr/local/bin/rad --no-check-certificate 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 \ No newline at end of file +FROM emilyregistry2.azurecr.io/radcodespace:latest \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 372629a31f..5c3c10c82a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,25 +1,23 @@ { - "name": "GitHub Codespaces (Default)", - "extensions": [ - "coenraads.bracket-pair-colorizer-2", - "cschleiden.vscode-github-actions", - "eamodio.gitlens", - "github.vscode-pull-request-github", - "ms-azuretools.vscode-docker", - "ms-vscode-remote.remote-container", - "ms-vsliveshare.vsliveshare", - "vscode-icons-team.vscode-icons", - "golang.Go", - "ms-kubernetes-tools.vscode-kubernetes-tools", - "/home/rad-vscode-bicep.vsix", - "visualstudioexptteam.vscodeintellicode" - ], - "dockerFile": "Dockerfile", - "settings": { - "terminal.integrated.shell.linux": "/usr/bin/zsh", - "files.exclude": { - "**/CODE_OF_CONDUCT.md": true, - "**/LICENSE": true - } - } + "name": "Codespaces for Radius tutorials", + + // "dockerFile": "Dockerfile", + "image": "emilyregistry2.azurecr.io/radcodespace:latest", + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-vscode.azurecli", + "ms-dotnettools.vscode-dotnet-runtime", + "/home/rad-vscode-bicep.vsix" + ], + + "forwardPorts": [3000], + + // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" } \ 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..e69de29bb2 diff --git a/.devcontainer/tutorials-codespace/library-scripts/README.md b/.devcontainer/tutorials-codespace/library-scripts/README.md new file mode 100644 index 0000000000..e69de29bb2 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..e69de29bb2 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..e69de29bb2 diff --git a/.github/workflows/codespaces.yaml b/.github/workflows/codespaces.yaml new file mode 100644 index 0000000000..e69de29bb2 From 5542411da36bb83c1baa9625bf1aa249b2fee305 Mon Sep 17 00:00:00 2001 From: "Emily Potyraj (Watkins)" <36576265+emily-potyraj@users.noreply.github.com> Date: Tue, 13 Apr 2021 09:36:17 -0500 Subject: [PATCH 03/21] new codespaces github workflow accidentally came in as empty file previously --- .github/workflows/codespaces.yaml | 65 +++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/.github/workflows/codespaces.yaml b/.github/workflows/codespaces.yaml index e69de29bb2..75d5536dcf 100644 --- a/.github/workflows/codespaces.yaml +++ b/.github/workflows/codespaces.yaml @@ -0,0 +1,65 @@ +# ------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------------------------------ + +name: Codespaces Assets + +on: + push: + branches: + - main + - release/* + paths-ignore: + - 'docs/**' + pull_request: + branches: + - main + - release/* + paths-ignore: + - 'docs/**' + +jobs: + # Logic here: + # - TODO + docker: + name: Build & publish docker image + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + registry: radiusteam.azurecr.io + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: ./.devcontainer/tutorials-codespace/ + #file: ./.devcontainer/tutorials-codespace/Dockerfile ## default is {context}/Dockerfile anyways + builder: ${{ steps.buildx.outputs.name }} + push: true + tags: radiusteam.azurecr.io/radcodespace:latest + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} From 66076ecf72a7655757bc41984c8394079119e0bd Mon Sep 17 00:00:00 2001 From: "Emily Potyraj (Watkins)" <36576265+emily-potyraj@users.noreply.github.com> Date: Tue, 13 Apr 2021 09:41:24 -0500 Subject: [PATCH 04/21] Update devcontainer.json --- .devcontainer/devcontainer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5c3c10c82a..e98b5eb67d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,7 +2,7 @@ "name": "Codespaces for Radius tutorials", // "dockerFile": "Dockerfile", - "image": "emilyregistry2.azurecr.io/radcodespace:latest", + "image": "radius.azurecr.io/radcodespace:latest", // Set *default* container specific settings.json values on container create. "settings": { @@ -20,4 +20,4 @@ // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. "remoteUser": "vscode" -} \ No newline at end of file +} From 306e3268f138d5e67321ec2ce144525f64b9f327 Mon Sep 17 00:00:00 2001 From: "Emily Potyraj (Watkins)" <36576265+emily-potyraj@users.noreply.github.com> Date: Tue, 13 Apr 2021 09:41:39 -0500 Subject: [PATCH 05/21] Delete Dockerfile --- .devcontainer/Dockerfile | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 5fc29db2c4..0000000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -FROM emilyregistry2.azurecr.io/radcodespace:latest \ No newline at end of file From 23de0bf2c100561ad556a6f06990dcbb00616d02 Mon Sep 17 00:00:00 2001 From: "Emily Potyraj (Watkins)" <36576265+emily-potyraj@users.noreply.github.com> Date: Tue, 13 Apr 2021 16:54:57 -0500 Subject: [PATCH 06/21] Update codespaces.yaml --- .github/workflows/codespaces.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codespaces.yaml b/.github/workflows/codespaces.yaml index 75d5536dcf..4b23566596 100644 --- a/.github/workflows/codespaces.yaml +++ b/.github/workflows/codespaces.yaml @@ -57,7 +57,7 @@ jobs: #file: ./.devcontainer/tutorials-codespace/Dockerfile ## default is {context}/Dockerfile anyways builder: ${{ steps.buildx.outputs.name }} push: true - tags: radiusteam.azurecr.io/radcodespace:latest + tags: radius.azurecr.io/radcodespace:latest cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache From cc2b4fa8d6b4d51a0b0a77ab7e9d47400050caa7 Mon Sep 17 00:00:00 2001 From: "Emily Potyraj (Watkins)" <36576265+emily-potyraj@users.noreply.github.com> Date: Tue, 13 Apr 2021 17:13:23 -0500 Subject: [PATCH 07/21] Update codespaces.yaml --- .github/workflows/codespaces.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codespaces.yaml b/.github/workflows/codespaces.yaml index 4b23566596..8dcd6cdc4a 100644 --- a/.github/workflows/codespaces.yaml +++ b/.github/workflows/codespaces.yaml @@ -45,7 +45,7 @@ jobs: - name: Login to Docker Hub uses: docker/login-action@v1 with: - registry: radiusteam.azurecr.io + registry: radius.azurecr.io username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} From faeba3229e19407169c27c2ce1c1a87ba1d41e68 Mon Sep 17 00:00:00 2001 From: "Emily Potyraj (Watkins)" <36576265+emily-potyraj@users.noreply.github.com> Date: Tue, 13 Apr 2021 20:03:27 -0500 Subject: [PATCH 08/21] Update first-run-notice.txt --- .devcontainer/tutorials-codespace/first-run-notice.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.devcontainer/tutorials-codespace/first-run-notice.txt b/.devcontainer/tutorials-codespace/first-run-notice.txt index e69de29bb2..63f8eefa58 100644 --- a/.devcontainer/tutorials-codespace/first-run-notice.txt +++ 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/ + + From c48bc1ad7439bc088a0444b8d38c4c35cb958fb3 Mon Sep 17 00:00:00 2001 From: "Emily Potyraj (Watkins)" <36576265+emily-potyraj@users.noreply.github.com> Date: Tue, 13 Apr 2021 20:05:32 -0500 Subject: [PATCH 09/21] Delete README.md --- .devcontainer/tutorials-codespace/library-scripts/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .devcontainer/tutorials-codespace/library-scripts/README.md diff --git a/.devcontainer/tutorials-codespace/library-scripts/README.md b/.devcontainer/tutorials-codespace/library-scripts/README.md deleted file mode 100644 index e69de29bb2..0000000000 From f460892f0abf3a00ba57286ec6c62340880c85db Mon Sep 17 00:00:00 2001 From: "Emily Potyraj (Watkins)" <36576265+emily-potyraj@users.noreply.github.com> Date: Tue, 13 Apr 2021 20:06:03 -0500 Subject: [PATCH 10/21] Update azcli-debian.sh --- .../library-scripts/azcli-debian.sh | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.devcontainer/tutorials-codespace/library-scripts/azcli-debian.sh b/.devcontainer/tutorials-codespace/library-scripts/azcli-debian.sh index e69de29bb2..760ede936b 100644 --- a/.devcontainer/tutorials-codespace/library-scripts/azcli-debian.sh +++ 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!" From 99caac60d38bb140b622007d0c57a7c53dbc8db2 Mon Sep 17 00:00:00 2001 From: "Emily Potyraj (Watkins)" <36576265+emily-potyraj@users.noreply.github.com> Date: Tue, 13 Apr 2021 20:06:19 -0500 Subject: [PATCH 11/21] Update kubectl-helm-debian.sh --- .../library-scripts/kubectl-helm-debian.sh | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.devcontainer/tutorials-codespace/library-scripts/kubectl-helm-debian.sh b/.devcontainer/tutorials-codespace/library-scripts/kubectl-helm-debian.sh index e69de29bb2..0dad4fdf78 100644 --- a/.devcontainer/tutorials-codespace/library-scripts/kubectl-helm-debian.sh +++ 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!" From b499f6797e9bb2d4a5e1a24f44e7bcf0a045e65c Mon Sep 17 00:00:00 2001 From: "Emily Potyraj (Watkins)" <36576265+emily-potyraj@users.noreply.github.com> Date: Tue, 13 Apr 2021 20:12:53 -0500 Subject: [PATCH 12/21] Update devcontainer.json --- .devcontainer/devcontainer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e98b5eb67d..467451aecf 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,6 @@ { "name": "Codespaces for Radius tutorials", - // "dockerFile": "Dockerfile", "image": "radius.azurecr.io/radcodespace:latest", // Set *default* container specific settings.json values on container create. From e347d8971b232c3f5889fad2068039cc4ed2a65f Mon Sep 17 00:00:00 2001 From: Emily Potyraj Date: Mon, 19 Apr 2021 11:41:04 -0500 Subject: [PATCH 13/21] EOL changes enforced by .gitattributes (no manual changes in this commit) --- .../tutorials-codespace/first-run-notice.txt | 10 +- .../library-scripts/azcli-debian.sh | 68 ++++----- .../library-scripts/kubectl-helm-debian.sh | 72 +++++----- .github/workflows/codespaces.yaml | 130 +++++++++--------- SUPPORT.md | 50 +++---- 5 files changed, 165 insertions(+), 165 deletions(-) diff --git a/.devcontainer/tutorials-codespace/first-run-notice.txt b/.devcontainer/tutorials-codespace/first-run-notice.txt index 63f8eefa58..f1c4806a08 100644 --- a/.devcontainer/tutorials-codespace/first-run-notice.txt +++ b/.devcontainer/tutorials-codespace/first-run-notice.txt @@ -1,5 +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/ - - + +👋 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 index 760ede936b..57c01aa0ca 100644 --- a/.devcontainer/tutorials-codespace/library-scripts/azcli-debian.sh +++ b/.devcontainer/tutorials-codespace/library-scripts/azcli-debian.sh @@ -1,34 +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!" +#!/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 index 0dad4fdf78..25b2129e5a 100644 --- a/.devcontainer/tutorials-codespace/library-scripts/kubectl-helm-debian.sh +++ b/.devcontainer/tutorials-codespace/library-scripts/kubectl-helm-debian.sh @@ -1,36 +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!" +#!/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/codespaces.yaml b/.github/workflows/codespaces.yaml index 8dcd6cdc4a..1ff902bd42 100644 --- a/.github/workflows/codespaces.yaml +++ b/.github/workflows/codespaces.yaml @@ -1,65 +1,65 @@ -# ------------------------------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------------------------------ - -name: Codespaces Assets - -on: - push: - branches: - - main - - release/* - paths-ignore: - - 'docs/**' - pull_request: - branches: - - main - - release/* - paths-ignore: - - 'docs/**' - -jobs: - # Logic here: - # - TODO - docker: - name: Build & publish docker image - runs-on: ubuntu-latest - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - registry: radius.azurecr.io - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - context: ./.devcontainer/tutorials-codespace/ - #file: ./.devcontainer/tutorials-codespace/Dockerfile ## default is {context}/Dockerfile anyways - builder: ${{ steps.buildx.outputs.name }} - push: true - tags: radius.azurecr.io/radcodespace:latest - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} +# ------------------------------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------------------------------ + +name: Codespaces Assets + +on: + push: + branches: + - main + - release/* + paths-ignore: + - 'docs/**' + pull_request: + branches: + - main + - release/* + paths-ignore: + - 'docs/**' + +jobs: + # Logic here: + # - TODO + docker: + name: Build & publish docker image + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + registry: radius.azurecr.io + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: ./.devcontainer/tutorials-codespace/ + #file: ./.devcontainer/tutorials-codespace/Dockerfile ## default is {context}/Dockerfile anyways + builder: ${{ steps.buildx.outputs.name }} + push: true + tags: radius.azurecr.io/radcodespace:latest + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/SUPPORT.md b/SUPPORT.md index dc72f0e5a0..8b05616fc9 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -1,25 +1,25 @@ -# TODO: The maintainer of this repo has not yet edited this file - -**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project? - -- **No CSS support:** Fill out this template with information about how to file issues and get help. -- **Yes CSS support:** Fill out an intake form at [aka.ms/spot](https://aka.ms/spot). CSS will work with/help you to determine next steps. More details also available at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). -- **Not sure?** Fill out a SPOT intake as though the answer were "Yes". CSS will help you decide. - -*Then remove this first heading from this SUPPORT.MD file before publishing your repo.* - -# Support - -## How to file issues and get help - -This project uses GitHub Issues to track bugs and feature requests. Please search the existing -issues before filing new issues to avoid duplicates. For new issues, file your bug or -feature request as a new Issue. - -For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE -FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER -CHANNEL. WHERE WILL YOU HELP PEOPLE?**. - -## Microsoft Support Policy - -Support for this **PROJECT or PRODUCT** is limited to the resources listed above. +# TODO: The maintainer of this repo has not yet edited this file + +**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project? + +- **No CSS support:** Fill out this template with information about how to file issues and get help. +- **Yes CSS support:** Fill out an intake form at [aka.ms/spot](https://aka.ms/spot). CSS will work with/help you to determine next steps. More details also available at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). +- **Not sure?** Fill out a SPOT intake as though the answer were "Yes". CSS will help you decide. + +*Then remove this first heading from this SUPPORT.MD file before publishing your repo.* + +# Support + +## How to file issues and get help + +This project uses GitHub Issues to track bugs and feature requests. Please search the existing +issues before filing new issues to avoid duplicates. For new issues, file your bug or +feature request as a new Issue. + +For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE +FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER +CHANNEL. WHERE WILL YOU HELP PEOPLE?**. + +## Microsoft Support Policy + +Support for this **PROJECT or PRODUCT** is limited to the resources listed above. From 67d02c4e17597b8b3975c85268137e9e3b99ce21 Mon Sep 17 00:00:00 2001 From: Emily Potyraj Date: Tue, 20 Apr 2021 22:01:59 -0500 Subject: [PATCH 14/21] combine codespaces.yaml into build.yaml. use new buildx github actions. --- .github/workflows/build.yaml | 187 +++++++++++++++++++++++++---------- Makefile | 16 --- 2 files changed, 134 insertions(+), 69 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f36e8a4532..747964d546 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -11,15 +11,13 @@ on: - release/* tags: - v* - paths-ignore: - - 'docs/**' pull_request: branches: - main - release/* - paths-ignore: - - 'docs/**' + jobs: + build: name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries runs-on: ${{ matrix.os }} @@ -74,66 +72,107 @@ jobs: images: name: Container image build runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - destination: ['acr', 'dockerhub'] - include: - - destination: acr - registry: radius.azurecr.io - login_server: radius.azurecr.io - username_secret: DOCKER_USERNAME - password_secret: DOCKER_PASSWORD - - destination: dockerhub - registry: radiusteam - login_server: https://index.docker.io/v1/ - username_secret: RADIUSTEAM_DOCKERHUB_USERNAME - password_secret: RADIUSTEAM_DOCKERHUB_PASSWORD + + + # strategy: + # fail-fast: false + # matrix: + # destination: ['acr', 'dockerhub'] + # include: + # - destination: acr + # registry: radius.azurecr.io + # login_server: radius.azurecr.io + # username_secret: DOCKER_USERNAME + # password_secret: DOCKER_PASSWORD + # - destination: dockerhub + # registry: radiusteam + # login_server: https://index.docker.io/v1/ + # username_secret: RADIUSTEAM_DOCKERHUB_USERNAME + # password_secret: RADIUSTEAM_DOCKERHUB_PASSWORD + + steps: - name: Check out code uses: actions/checkout@v2 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to ACR + uses: docker/login-action@v1 + with: + registry: radius.azurecr.io + username: '${{ secrets.DOCKER_USERNAME }}' + password: '${{ secrets.DOCKER_PASSWORD }}' + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + registry: radiusteam #login-server is https://index.docker.io/v1/ by default + username: '${{ secrets.RADIUSTEAM_DOCKERHUB_USERNAME }}' + password: '${{ secrets.RADIUSTEAM_DOCKERHUB_PASSWORD }}' + - name: Parse release version and set REL_VERSION run: python ./.github/scripts/get_release_version.py - - name: make docker - run: make docker - env: - DOCKER_REGISTRY: ${{ matrix.registry }} - DOCKER_TAG_VERSION: latest - - name: make docker (release) - run: make docker - if: startsWith(github.ref, 'refs/pull/') - env: - DOCKER_REGISTRY: ${{ matrix.registry }} - DOCKER_TAG_VERSION: ${{ env.REL_VERSION }} - - name: make docker (release) - run: make docker - if: startsWith(github.ref, 'refs/tags/v') - env: - DOCKER_REGISTRY: ${{ matrix.registry }} - DOCKER_TAG_VERSION: ${{ env.REL_VERSION }} - - uses: azure/docker-login@v1 - with: - login-server: ${{ matrix.login_server }} - username: '${{ secrets[matrix.username_secret] }}' - password: '${{ secrets[matrix.password_secret] }}' - - name: make dockerpush (latest) - run: make dockerpush - if: (github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags/v') # push image on push to main or tag + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 env: - DOCKER_REGISTRY: ${{ matrix.registry }} DOCKER_TAG_VERSION: latest - - name: make dockerpush (PR) - run: make dockerpush - if: startsWith(github.ref, 'refs/pull/') # push image on pr + with: + context: ./deploy/rp/Dockerfile # Location of Dockerfile + builder: ${{ steps.buildx.outputs.name }} + push: true + tags: | # Docker image name in each registry + radius.azurecr.io/radius-rp:${{ env.DOCKER_TAG_VERSION }} + radiusteam/radius-rp:${{ env.DOCKER_TAG_VERSION }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (PR) + id: docker_build_pr + uses: docker/build-push-action@v2 + if: startsWith(github.ref, 'refs/pull/') # build & push image on pr env: - DOCKER_REGISTRY: ${{ matrix.registry }} DOCKER_TAG_VERSION: ${{ env.REL_VERSION }} - - name: make dockerpush (release) - run: make dockerpush - if: startsWith(github.ref, 'refs/tags/v') # push image on tag + with: + context: ./deploy/rp/Dockerfile + builder: ${{ steps.buildx.outputs.name }} + push: true + tags: | + radius.azurecr.io/radius-rp:${{ env.DOCKER_TAG_VERSION }} + radiusteam/radius-rp:${{ env.DOCKER_TAG_VERSION }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (release) + id: docker_build_release + uses: docker/build-push-action@v2 + if: startsWith(github.ref, 'refs/tags/v') # build & push image on tag env: - DOCKER_REGISTRY: ${{ matrix.registry }} DOCKER_TAG_VERSION: ${{ env.REL_VERSION }} + with: + context: ./deploy/rp/Dockerfile + builder: ${{ steps.buildx.outputs.name }} + push: true + tags: | + radius.azurecr.io/radius-rp:${{ env.DOCKER_TAG_VERSION }} + radiusteam/radius-rp:${{ env.DOCKER_TAG_VERSION }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} deploy_tests: name: Run deployment tests @@ -229,3 +268,45 @@ jobs: connection_string: ${{ secrets.ASSETS_STORAGE_CONNECTION_STRING }} sync: true extra_args: '--destination-path rad/${{ env.REL_VERSION }}/windows-x64/ --pattern rad.exe' + + codespacesbuild: + name: Build & publish Codespaces docker image + # needs: [ 'build' ] ### may change to depend on build & deploy tests in the future + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + registry: radiusteam + username: ${{ secrets.RADIUSTEAM_DOCKERHUB_USERNAME }} + password: ${{ secrets.RADIUSTEAM_DOCKERHUB_PASSWORD }} + + - name: Build and push + id: docker_build + if: (github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags/v') # push image on push to main or tag + 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: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} \ No newline at end of file diff --git a/Makefile b/Makefile index e341e10652..48184f4a26 100644 --- a/Makefile +++ b/Makefile @@ -205,22 +205,6 @@ e2e-tests: clean: rm -rf $(OUT_DIR) -################################################################################ -# Target: docker # -################################################################################ -.PHONY: docker -docker: - $(info $(H) Building image as '$(DOCKER_IMAGE)') - docker build . -f ./deploy/rp/Dockerfile -t $(DOCKER_IMAGE) - -################################################################################ -# Target: dockerpush # -################################################################################ -.PHONY: dockerpush -dockerpush: - $(info $(H) Pushing image '$(DOCKER_IMAGE)') - docker push $(DOCKER_IMAGE) - ################################################################################ # Target: runmongo # ################################################################################ From 1388247ca8e4fbf2558ba78a9db79e3a9f758f17 Mon Sep 17 00:00:00 2001 From: Emily Potyraj Date: Tue, 20 Apr 2021 22:05:35 -0500 Subject: [PATCH 15/21] cleanup unused lines --- .github/workflows/build.yaml | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 747964d546..492518bdd2 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -17,7 +17,6 @@ on: - release/* jobs: - build: name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries runs-on: ${{ matrix.os }} @@ -72,33 +71,12 @@ jobs: images: name: Container image build runs-on: ubuntu-latest - - - # strategy: - # fail-fast: false - # matrix: - # destination: ['acr', 'dockerhub'] - # include: - # - destination: acr - # registry: radius.azurecr.io - # login_server: radius.azurecr.io - # username_secret: DOCKER_USERNAME - # password_secret: DOCKER_PASSWORD - # - destination: dockerhub - # registry: radiusteam - # login_server: https://index.docker.io/v1/ - # username_secret: RADIUSTEAM_DOCKERHUB_USERNAME - # password_secret: RADIUSTEAM_DOCKERHUB_PASSWORD - - steps: - name: Check out code uses: actions/checkout@v2 - - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v1 - - name: Cache Docker layers uses: actions/cache@v2 with: @@ -106,24 +84,20 @@ jobs: key: ${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx- - - name: Login to ACR uses: docker/login-action@v1 with: registry: radius.azurecr.io username: '${{ secrets.DOCKER_USERNAME }}' password: '${{ secrets.DOCKER_PASSWORD }}' - - name: Login to DockerHub uses: docker/login-action@v1 with: registry: radiusteam #login-server is https://index.docker.io/v1/ by default username: '${{ secrets.RADIUSTEAM_DOCKERHUB_USERNAME }}' password: '${{ secrets.RADIUSTEAM_DOCKERHUB_PASSWORD }}' - - name: Parse release version and set REL_VERSION run: python ./.github/scripts/get_release_version.py - - name: Build and push id: docker_build uses: docker/build-push-action@v2 @@ -138,7 +112,6 @@ jobs: radiusteam/radius-rp:${{ env.DOCKER_TAG_VERSION }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - - name: Build and push (PR) id: docker_build_pr uses: docker/build-push-action@v2 @@ -154,7 +127,6 @@ jobs: radiusteam/radius-rp:${{ env.DOCKER_TAG_VERSION }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - - name: Build and push (release) id: docker_build_release uses: docker/build-push-action@v2 @@ -170,7 +142,6 @@ jobs: radiusteam/radius-rp:${{ env.DOCKER_TAG_VERSION }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} From ec73d28f0e773dc389c7b2544fe7fd4c8bfd3b4a Mon Sep 17 00:00:00 2001 From: "Emily Potyraj (Watkins)" <36576265+emily-potyraj@users.noreply.github.com> Date: Tue, 20 Apr 2021 22:07:08 -0500 Subject: [PATCH 16/21] Delete codespaces.yaml --- .github/workflows/codespaces.yaml | 65 ------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 .github/workflows/codespaces.yaml diff --git a/.github/workflows/codespaces.yaml b/.github/workflows/codespaces.yaml deleted file mode 100644 index 1ff902bd42..0000000000 --- a/.github/workflows/codespaces.yaml +++ /dev/null @@ -1,65 +0,0 @@ -# ------------------------------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------------------------------ - -name: Codespaces Assets - -on: - push: - branches: - - main - - release/* - paths-ignore: - - 'docs/**' - pull_request: - branches: - - main - - release/* - paths-ignore: - - 'docs/**' - -jobs: - # Logic here: - # - TODO - docker: - name: Build & publish docker image - runs-on: ubuntu-latest - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - registry: radius.azurecr.io - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - context: ./.devcontainer/tutorials-codespace/ - #file: ./.devcontainer/tutorials-codespace/Dockerfile ## default is {context}/Dockerfile anyways - builder: ${{ steps.buildx.outputs.name }} - push: true - tags: radius.azurecr.io/radcodespace:latest - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} From 1f31731341ed43a9ccdbb39ad2a7e6e69991261d Mon Sep 17 00:00:00 2001 From: Emily Potyraj Date: Tue, 20 Apr 2021 22:18:24 -0500 Subject: [PATCH 17/21] make codespaces build depend on publish --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 492518bdd2..5c5fabe2a8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -242,7 +242,7 @@ jobs: codespacesbuild: name: Build & publish Codespaces docker image - # needs: [ 'build' ] ### may change to depend on build & deploy tests in the future + needs: [ 'publish' ] runs-on: ubuntu-latest steps: - name: Check out code From a41b76b9a81530e701ad1b0aa02e6076eae393b8 Mon Sep 17 00:00:00 2001 From: "Emily Potyraj (Watkins)" <36576265+emily-potyraj@users.noreply.github.com> Date: Wed, 21 Apr 2021 10:04:57 -0500 Subject: [PATCH 18/21] don't specify DockerHub registry name explicitly --- .github/workflows/build.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9b4b6b6994..625bf068f7 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -92,7 +92,6 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v1 with: - registry: radiusteam #login-server is https://index.docker.io/v1/ by default username: '${{ secrets.RADIUSTEAM_DOCKERHUB_USERNAME }}' password: '${{ secrets.RADIUSTEAM_DOCKERHUB_PASSWORD }}' - name: Parse release version and set REL_VERSION @@ -298,7 +297,6 @@ jobs: - name: Login to Docker Hub uses: docker/login-action@v1 with: - registry: radiusteam username: ${{ secrets.RADIUSTEAM_DOCKERHUB_USERNAME }} password: ${{ secrets.RADIUSTEAM_DOCKERHUB_PASSWORD }} - name: Build and push From acd7b195db0209d1d31f06d6fcba6a343b4bce20 Mon Sep 17 00:00:00 2001 From: "Emily Potyraj (Watkins)" <36576265+emily-potyraj@users.noreply.github.com> Date: Wed, 21 Apr 2021 10:09:28 -0500 Subject: [PATCH 19/21] Update build.yaml --- .github/workflows/build.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 625bf068f7..35d9cbbf9a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -102,7 +102,8 @@ jobs: env: DOCKER_TAG_VERSION: latest with: - context: ./deploy/rp/Dockerfile # Location of Dockerfile + context: . + file: ./deploy/rp/Dockerfile # Location of Dockerfile builder: ${{ steps.buildx.outputs.name }} push: true tags: | # Docker image name in each registry @@ -117,7 +118,8 @@ jobs: env: DOCKER_TAG_VERSION: ${{ env.REL_VERSION }} with: - context: ./deploy/rp/Dockerfile + context: . + file: ./deploy/rp/Dockerfile builder: ${{ steps.buildx.outputs.name }} push: true tags: | @@ -132,7 +134,8 @@ jobs: env: DOCKER_TAG_VERSION: ${{ env.REL_VERSION }} with: - context: ./deploy/rp/Dockerfile + context: . + file: ./deploy/rp/Dockerfile builder: ${{ steps.buildx.outputs.name }} push: true tags: | From baddbd1d85d0fe28c48e120fc961b18d4f036bcf Mon Sep 17 00:00:00 2001 From: Emily Potyraj Date: Mon, 26 Apr 2021 01:31:43 -0500 Subject: [PATCH 20/21] auto-generate image tags and labels. collapse codespaces image build & main image build into a single job. fix typo in devcontainer.json. --- .devcontainer/devcontainer.json | 2 +- .github/workflows/build.yaml | 106 +++++++++++--------------------- 2 files changed, 38 insertions(+), 70 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 467451aecf..3bc1f51687 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ { "name": "Codespaces for Radius tutorials", - "image": "radius.azurecr.io/radcodespace:latest", + "image": "radiusteam/radcodespace:latest", // Set *default* container specific settings.json values on container create. "settings": { diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 35d9cbbf9a..8f75e99426 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -73,6 +73,35 @@ jobs: steps: - name: Check out code uses: actions/checkout@v2 + - name: Docker meta + id: meta + uses: crazy-max/ghaction-docker-meta@v2 + with: + # list of Docker images to use as base name for tags + images: | + radius.azurecr.io/radius-rp + radiusteam/radius-rp + # generate Docker tags based on the following events/attributes + tags: | + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=edge + - name: Docker meta - Codespaces + if: (github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags/v') # only needed on push to main or tag + id: meta_codespaces + uses: crazy-max/ghaction-docker-meta@v2 + with: + images: | + radiusteam//radius-codespaces + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=edge + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v1 @@ -94,53 +123,27 @@ jobs: with: username: '${{ secrets.RADIUSTEAM_DOCKERHUB_USERNAME }}' password: '${{ secrets.RADIUSTEAM_DOCKERHUB_PASSWORD }}' - - name: Parse release version and set REL_VERSION - run: python ./.github/scripts/get_release_version.py - name: Build and push - id: docker_build uses: docker/build-push-action@v2 - env: - DOCKER_TAG_VERSION: latest with: context: . file: ./deploy/rp/Dockerfile # Location of Dockerfile builder: ${{ steps.buildx.outputs.name }} push: true tags: | # Docker image name in each registry - radius.azurecr.io/radius-rp:${{ env.DOCKER_TAG_VERSION }} - radiusteam/radius-rp:${{ env.DOCKER_TAG_VERSION }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - - name: Build and push (PR) - id: docker_build_pr - uses: docker/build-push-action@v2 - if: startsWith(github.ref, 'refs/pull/') # build & push image on pr - env: - DOCKER_TAG_VERSION: ${{ env.REL_VERSION }} - with: - context: . - file: ./deploy/rp/Dockerfile - builder: ${{ steps.buildx.outputs.name }} - push: true - tags: | - radius.azurecr.io/radius-rp:${{ env.DOCKER_TAG_VERSION }} - radiusteam/radius-rp:${{ env.DOCKER_TAG_VERSION }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - - name: Build and push (release) - id: docker_build_release + - name: Build and push - Codespaces + if: (github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags/v') # push image on push to main or tag uses: docker/build-push-action@v2 - if: startsWith(github.ref, 'refs/tags/v') # build & push image on tag - env: - DOCKER_TAG_VERSION: ${{ env.REL_VERSION }} with: - context: . - file: ./deploy/rp/Dockerfile + context: ./.devcontainer/tutorials-codespace/ builder: ${{ steps.buildx.outputs.name }} push: true - tags: | - radius.azurecr.io/radius-rp:${{ env.DOCKER_TAG_VERSION }} - radiusteam/radius-rp:${{ env.DOCKER_TAG_VERSION }} + tags: ${{ steps.meta_codespaces.outputs.tags }} + labels: ${{ steps.meta_codespaces.outputs.labels }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - name: Image digest @@ -264,7 +267,7 @@ jobs: container_name: 'tools' connection_string: ${{ secrets.ASSETS_STORAGE_CONNECTION_STRING }} sync: true - extra_args: '--destination-path rad/${{ env.REL_CHANNEL }}/macos-x64/ --pattern rad' + extra_args: '--destination-path rad/${{ env.REL_VERSION }}/macos-x64/ --pattern rad' - uses: bacongobbler/azure-blob-storage-upload@v1.1.1 with: source_dir: rad_cli_linux_amd64 @@ -280,38 +283,3 @@ jobs: sync: true extra_args: '--destination-path rad/${{ env.REL_VERSION }}/windows-x64/ --pattern rad.exe' - codespacesbuild: - name: Build & publish Codespaces docker image - needs: [ 'publish' ] - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v2 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.RADIUSTEAM_DOCKERHUB_USERNAME }} - password: ${{ secrets.RADIUSTEAM_DOCKERHUB_PASSWORD }} - - name: Build and push - id: docker_build - if: (github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags/v') # push image on push to main or tag - 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: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} From ecdb117052bc2f19fa4db476b3543c34f00e4c5e Mon Sep 17 00:00:00 2001 From: Emily Potyraj Date: Wed, 28 Apr 2021 22:59:47 -0500 Subject: [PATCH 21/21] revert to previous build method with Makefile for general build. still using build-push-action for Codespaces since I can specify a different Dockerfile. --- .github/workflows/build.yaml | 187 +++++++++++++++++++++-------------- Makefile | 21 ++++ 2 files changed, 132 insertions(+), 76 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8f75e99426..e41b7ac8fb 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -70,84 +70,66 @@ jobs: images: name: Container image build runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + destination: ['acr', 'dockerhub'] + include: + - destination: acr + registry: radius.azurecr.io + login_server: radius.azurecr.io + username_secret: DOCKER_USERNAME + password_secret: DOCKER_PASSWORD + - destination: dockerhub + registry: radiusteam + login_server: https://index.docker.io/v1/ + username_secret: RADIUSTEAM_DOCKERHUB_USERNAME + password_secret: RADIUSTEAM_DOCKERHUB_PASSWORD steps: - name: Check out code uses: actions/checkout@v2 - - name: Docker meta - id: meta - uses: crazy-max/ghaction-docker-meta@v2 - with: - # list of Docker images to use as base name for tags - images: | - radius.azurecr.io/radius-rp - radiusteam/radius-rp - # generate Docker tags based on the following events/attributes - tags: | - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=edge - - name: Docker meta - Codespaces - if: (github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags/v') # only needed on push to main or tag - id: meta_codespaces - uses: crazy-max/ghaction-docker-meta@v2 - with: - images: | - radiusteam//radius-codespaces - tags: | - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=edge - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - name: Login to ACR - uses: docker/login-action@v1 - with: - registry: radius.azurecr.io - username: '${{ secrets.DOCKER_USERNAME }}' - password: '${{ secrets.DOCKER_PASSWORD }}' - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: '${{ secrets.RADIUSTEAM_DOCKERHUB_USERNAME }}' - password: '${{ secrets.RADIUSTEAM_DOCKERHUB_PASSWORD }}' - - name: Build and push - uses: docker/build-push-action@v2 - with: - context: . - file: ./deploy/rp/Dockerfile # Location of Dockerfile - builder: ${{ steps.buildx.outputs.name }} - push: true - tags: | # Docker image name in each registry - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - - name: Build and push - Codespaces - if: (github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags/v') # push image on push to main or tag - uses: docker/build-push-action@v2 + - name: Parse release version and set environment variables + run: python ./.github/scripts/get_release_version.py + - name: make docker + run: make docker + env: + DOCKER_REGISTRY: ${{ matrix.registry }} + DOCKER_TAG_VERSION: latest + - name: make docker (PR) + run: make docker + if: startsWith(github.ref, 'refs/pull/') + env: + DOCKER_REGISTRY: ${{ matrix.registry }} + DOCKER_TAG_VERSION: ${{ env.REL_VERSION }} # includes PR number + - name: make docker (release) + run: make docker + if: startsWith(github.ref, 'refs/tags/v') + env: + DOCKER_REGISTRY: ${{ matrix.registry }} + DOCKER_TAG_VERSION: ${{ env.REL_CHANNEL }} + - uses: azure/docker-login@v1 with: - context: ./.devcontainer/tutorials-codespace/ - builder: ${{ steps.buildx.outputs.name }} - push: true - tags: ${{ steps.meta_codespaces.outputs.tags }} - labels: ${{ steps.meta_codespaces.outputs.labels }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} + login-server: ${{ matrix.login_server }} + username: '${{ secrets[matrix.username_secret] }}' + password: '${{ secrets[matrix.password_secret] }}' + - name: make dockerpush (latest) + run: make dockerpush + if: (github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags/v') # push image on push to main or tag + env: + DOCKER_REGISTRY: ${{ matrix.registry }} + DOCKER_TAG_VERSION: latest + - name: make dockerpush (PR) + run: make dockerpush + if: startsWith(github.ref, 'refs/pull/') # push image on pr + env: + DOCKER_REGISTRY: ${{ matrix.registry }} + DOCKER_TAG_VERSION: ${{ env.REL_VERSION }} # includes PR number + - name: make dockerpush (release) + run: make dockerpush + if: startsWith(github.ref, 'refs/tags/v') # push image on tag + env: + DOCKER_REGISTRY: ${{ matrix.registry }} + DOCKER_TAG_VERSION: ${{ env.REL_CHANNEL }} deploy_tests: name: Run deployment tests @@ -267,7 +249,7 @@ jobs: container_name: 'tools' connection_string: ${{ secrets.ASSETS_STORAGE_CONNECTION_STRING }} sync: true - extra_args: '--destination-path rad/${{ env.REL_VERSION }}/macos-x64/ --pattern rad' + extra_args: '--destination-path rad/${{ env.REL_CHANNEL }}/macos-x64/ --pattern rad' - uses: bacongobbler/azure-blob-storage-upload@v1.1.1 with: source_dir: rad_cli_linux_amd64 @@ -281,5 +263,58 @@ jobs: container_name: 'tools' connection_string: ${{ secrets.ASSETS_STORAGE_CONNECTION_STRING }} sync: true - extra_args: '--destination-path rad/${{ env.REL_VERSION }}/windows-x64/ --pattern rad.exe' + extra_args: '--destination-path rad/${{ env.REL_CHANNEL }}/windows-x64/ --pattern rad.exe' + 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: + 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/Makefile b/Makefile index 1df9e87114..c6a1a20fe5 100644 --- a/Makefile +++ b/Makefile @@ -218,6 +218,27 @@ e2e-tests: clean: rm -rf $(OUT_DIR) +################################################################################ +# Target: docker # +################################################################################ +.PHONY: docker +docker: + $(info $(H) Building image as '$(DOCKER_IMAGE)') + docker build . \ + -f ./deploy/rp/Dockerfile \ + -t $(DOCKER_IMAGE) \ + --build-arg LDFLAGS=$(LDFLAGS) \ + --label org.opencontainers.image.version="$(REL_VERSION)" \ + --label org.opencontainers.image.revision="$(GIT_COMMIT)" + +################################################################################ +# Target: dockerpush # +################################################################################ +.PHONY: dockerpush +dockerpush: + $(info $(H) Pushing image '$(DOCKER_IMAGE)') + docker push $(DOCKER_IMAGE) + ################################################################################ # Target: runmongo # ################################################################################