|
| 1 | +# Copyright (c) Microsoft Corporation. |
| 2 | +# Licensed under the MIT License. |
| 3 | + |
| 4 | + |
| 5 | +ARG hostRegistry=psdockercache.azurecr.io |
| 6 | +FROM --platform=linux/arm64/v8 ${hostRegistry}/ubuntu:jammy AS installer-env |
| 7 | + |
| 8 | +ARG PS_VERSION=7.3.11 |
| 9 | +ENV PS_PACKAGE=powershell-${PS_VERSION}-linux-arm64.tar.gz |
| 10 | +ENV PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE} |
| 11 | +ARG PS_INSTALL_VERSION=7-preview |
| 12 | + |
| 13 | +# define the folder we will be installing PowerShell to |
| 14 | +ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION |
| 15 | +# Create the install folder |
| 16 | +RUN mkdir -p ${PS_INSTALL_FOLDER} |
| 17 | +ARG PS_PACKAGE_URL_BASE64 |
| 18 | +RUN apt-get update \ |
| 19 | + && apt-get install --no-install-recommends ca-certificates wget --yes |
| 20 | +RUN echo 'in task' \ |
| 21 | + && if [ -n "${PS_PACKAGE_URL_BASE64}" ]; then \ |
| 22 | + echo 'using base64' \ |
| 23 | + && export url=$(echo "${PS_PACKAGE_URL_BASE64}" | base64 --decode -);\ |
| 24 | + else \ |
| 25 | + echo 'using unencoded' \ |
| 26 | + && export url="${PS_PACKAGE_URL}"; \ |
| 27 | + fi \ |
| 28 | + && echo "url: $url" \ |
| 29 | + && wget -O /tmp/powershell.tar.gz "$url" \ |
| 30 | + && echo 'task done' |
| 31 | +RUN ls -l /tmp/powershell.tar.gz |
| 32 | + # Unzip the Linux tar.gz |
| 33 | +RUN tar zxf /tmp/powershell.tar.gz -C ${PS_INSTALL_FOLDER} |
| 34 | + |
| 35 | +ARG hostRegistry=psdockercache.azurecr.io |
| 36 | +FROM --platform=linux/arm64/v8 ${hostRegistry}/ubuntu:jammy AS final-image |
| 37 | + |
| 38 | +# Define Args and Env needed to create links |
| 39 | +ARG PS_INSTALL_VERSION=7-preview |
| 40 | +ARG PS_VERSION=7.3.11 |
| 41 | +ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \ |
| 42 | + \ |
| 43 | + # Define ENVs for Localization/Globalization |
| 44 | + DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \ |
| 45 | + LC_ALL=en_US.UTF-8 \ |
| 46 | + LANG=en_US.UTF-8 \ |
| 47 | + # set a fixed location for the Module analysis cache |
| 48 | + PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \ |
| 49 | + POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-arm64v8-Ubuntu-22.04 |
| 50 | +# Copy only the files we need from the previous stage |
| 51 | +COPY --from=installer-env ["/opt/microsoft/powershell", "/opt/microsoft/powershell"] |
| 52 | +RUN \ |
| 53 | + apt-get update \ |
| 54 | + && apt-get install --no-install-recommends ca-certificates libssl3 libicu70 less --yes |
| 55 | + # Give all user execute permissions and remove write permissions for others |
| 56 | +RUN chmod a+x,o-w ${PS_INSTALL_FOLDER}/pwsh \ |
| 57 | + # Create the pwsh symbolic link that points to powershell |
| 58 | + && ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \ |
| 59 | + # Create the pwsh-preview symbolic link that points to powershell |
| 60 | + && ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh-preview |
| 61 | +# Use PowerShell as the default shell |
| 62 | +# Use array to avoid Docker prepending /bin/sh -c |
| 63 | +CMD [ "pwsh" ] |
0 commit comments