|
| 1 | + |
| 2 | +FROM mcr.microsoft.com/dotnet/core/sdk:2.2 |
| 3 | + |
| 4 | +# Avoid warnings by switching to noninteractive |
| 5 | +ENV DEBIAN_FRONTEND=noninteractive |
| 6 | + |
| 7 | +# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux, |
| 8 | +# this user's GID/UID must match your local user UID/GID to avoid permission issues |
| 9 | +# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See |
| 10 | +# https://aka.ms/vscode-remote/containers/non-root-user for details. |
| 11 | +ARG USERNAME=vscode |
| 12 | +ARG USER_UID=1000 |
| 13 | +ARG USER_GID=$USER_UID |
| 14 | + |
| 15 | +ARG PS_VERSION=6.2.3 |
| 16 | +ARG PS_PACKAGE=powershell_${PS_VERSION}-1.debian.9_amd64.deb |
| 17 | +ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE} |
| 18 | + |
| 19 | +# Download the Linux package and save it |
| 20 | +ADD ${PS_PACKAGE_URL} /tmp/powershell.deb |
| 21 | + |
| 22 | +# Define ENVs for Localization/Globalization |
| 23 | +ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \ |
| 24 | + LC_ALL=en_US.UTF-8 \ |
| 25 | + LANG=en_US.UTF-8 \ |
| 26 | + # set a fixed location for the Module analysis cache |
| 27 | + PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache |
| 28 | + |
| 29 | +ENV FUNCTIONS_WORKER_RUNTIME=powershell |
| 30 | + |
| 31 | +# Configure apt and install packages |
| 32 | +RUN apt-get update \ |
| 33 | + && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ |
| 34 | + && apt install -y /tmp/powershell.deb \ |
| 35 | + # |
| 36 | + # Verify git and needed tools are installed |
| 37 | + && apt-get -y install \ |
| 38 | + git \ |
| 39 | + iproute2 \ |
| 40 | + procps \ |
| 41 | + curl \ |
| 42 | + apt-transport-https \ |
| 43 | + gnupg2 \ |
| 44 | + lsb-release \ |
| 45 | + # less is required for help in powershell |
| 46 | + less \ |
| 47 | + # requied to setup the locale |
| 48 | + locales \ |
| 49 | + # required for SSL |
| 50 | + ca-certificates \ |
| 51 | + gss-ntlmssp \ |
| 52 | + && apt-get dist-upgrade -y \ |
| 53 | + # enable en_US.UTF-8 locale |
| 54 | + && sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen \ |
| 55 | + # generate locale |
| 56 | + && locale-gen && update-locale \ |
| 57 | + # remove powershell package |
| 58 | + && rm /tmp/powershell.deb \ |
| 59 | + # |
| 60 | + # Install Azure Functions and Azure CLI |
| 61 | + && echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/azure-cli.list \ |
| 62 | + && echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-$(lsb_release -cs)-prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list \ |
| 63 | + && curl -sL https://packages.microsoft.com/keys/microsoft.asc | (OUT=$(apt-key add - 2>&1) || echo $OUT) \ |
| 64 | + && apt-get update \ |
| 65 | + && apt-get install -y azure-cli azure-functions-core-tools \ |
| 66 | + # |
| 67 | + # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. |
| 68 | + && groupadd --gid $USER_GID $USERNAME \ |
| 69 | + && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ |
| 70 | + # [Optional] Add sudo support for the non-root user |
| 71 | + && apt-get install -y sudo \ |
| 72 | + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ |
| 73 | + && chmod 0440 /etc/sudoers.d/$USERNAME \ |
| 74 | + # |
| 75 | + # Clean up |
| 76 | + && apt-get autoremove -y \ |
| 77 | + && apt-get clean -y \ |
| 78 | + && rm -rf /var/lib/apt/lists/* \ |
| 79 | + # intialize powershell module cache |
| 80 | + && pwsh \ |
| 81 | + -NoLogo \ |
| 82 | + -NoProfile \ |
| 83 | + -Command " \ |
| 84 | + \$ErrorActionPreference = 'Stop' ; \ |
| 85 | + \$ProgressPreference = 'SilentlyContinue' ; \ |
| 86 | + while(!(Test-Path -Path \$env:PSModuleAnalysisCachePath)) { \ |
| 87 | + Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; \ |
| 88 | + Start-Sleep -Seconds 6 ; \ |
| 89 | + }" |
| 90 | + |
| 91 | +# Switch back to dialog for any ad-hoc use of apt-get |
| 92 | +ENV DEBIAN_FRONTEND= |
0 commit comments