Skip to content

Commit 86e98f1

Browse files
authored
Added Step1
1 parent 8c219d9 commit 86e98f1

File tree

6 files changed

+756
-0
lines changed

6 files changed

+756
-0
lines changed

Diff for: .devcontainer/Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# [Choice] .NET Core version: 3.1, 2.1
2+
ARG VARIANT=3.1
3+
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT}
4+
5+
COPY library-scripts/azcli-debian.sh /tmp/library-scripts/
6+
RUN bash /tmp/library-scripts/azcli-debian.sh \
7+
&& curl -Lo /usr/local/bin/bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64 \
8+
&& chmod +x /usr/local/bin/bicep \
9+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
10+
11+
# [Optional] Uncomment this section to install additional OS packages.
12+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
13+
# && apt-get -y install --no-install-recommends <your-package-list-here>

Diff for: .devcontainer/devcontainer.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.192.0/containers/azure-bicep
3+
{
4+
"name": "Azure Bicep (Community)",
5+
"dockerFile": "Dockerfile",
6+
7+
// Set *default* container specific settings.json values on container create.
8+
"settings": {},
9+
10+
// Add the IDs of extensions you want installed when the container is created.
11+
"extensions": [
12+
"ms-vscode.azurecli",
13+
"ms-dotnettools.vscode-dotnet-runtime",
14+
"ms-azuretools.vscode-bicep"
15+
],
16+
17+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
18+
// "forwardPorts": [],
19+
20+
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
21+
"remoteUser": "vscode"
22+
}

Diff for: .devcontainer/library-scripts/azcli-debian.sh

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
#-------------------------------------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
5+
#-------------------------------------------------------------------------------------------------------------
6+
#
7+
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/azcli.md
8+
# Maintainer: The VS Code and Codespaces Teams
9+
#
10+
# Syntax: ./azcli-debian.sh
11+
12+
set -e
13+
14+
MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc"
15+
16+
if [ "$(id -u)" -ne 0 ]; then
17+
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
18+
exit 1
19+
fi
20+
21+
# Get central common setting
22+
get_common_setting() {
23+
if [ "${common_settings_file_loaded}" != "true" ]; then
24+
curl -sfL "https://aka.ms/vscode-dev-containers/script-library/settings.env" 2>/dev/null -o /tmp/vsdc-settings.env || echo "Could not download settings file. Skipping."
25+
common_settings_file_loaded=true
26+
fi
27+
if [ -f "/tmp/vsdc-settings.env" ]; then
28+
local multi_line=""
29+
if [ "$2" = "true" ]; then multi_line="-z"; fi
30+
local result="$(grep ${multi_line} -oP "$1=\"?\K[^\"]+" /tmp/vsdc-settings.env | tr -d '\0')"
31+
if [ ! -z "${result}" ]; then declare -g $1="${result}"; fi
32+
fi
33+
echo "$1=${!1}"
34+
}
35+
36+
# Function to run apt-get if needed
37+
apt_get_update_if_needed()
38+
{
39+
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
40+
echo "Running apt-get update..."
41+
apt-get update
42+
else
43+
echo "Skipping apt-get update."
44+
fi
45+
}
46+
47+
# Checks if packages are installed and installs them if not
48+
check_packages() {
49+
if ! dpkg -s "$@" > /dev/null 2>&1; then
50+
apt_get_update_if_needed
51+
apt-get -y install --no-install-recommends "$@"
52+
fi
53+
}
54+
55+
export DEBIAN_FRONTEND=noninteractive
56+
57+
# Install dependencies
58+
check_packages apt-transport-https curl ca-certificates lsb-release gnupg2
59+
60+
# Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install
61+
. /etc/os-release
62+
get_common_setting MICROSOFT_GPG_KEYS_URI
63+
curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg
64+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/azure-cli/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/azure-cli.list
65+
apt-get update
66+
apt-get install -y azure-cli
67+
echo "Done!"

0 commit comments

Comments
 (0)