diff --git a/release/7-5/mariner2-arm64/docker/Dockerfile b/release/7-5/mariner2-arm64/docker/Dockerfile index 23e28acd1..6f3b3e346 100644 --- a/release/7-5/mariner2-arm64/docker/Dockerfile +++ b/release/7-5/mariner2-arm64/docker/Dockerfile @@ -1,49 +1,48 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -FROM --platform=linux/arm64 mcr.microsoft.com/cbl-mariner/base/core:2.0 AS installer-env +FROM --platform=linux/arm64 mcr.microsoft.com/cbl-mariner/base/core:2.0 AS setup-tdnf-repa + + RUN --mount=type=cache,target=/var/cache/tdnf \ + tdnf install -y mariner-repos-microsoft-preview \ + && tdnf makecache + +# Download packages into a container so they don't take up space in the final stage +FROM setup-tdnf-repa AS installer-env # Define Args for the needed to add the package - ARG PS_VERSION=7.4.0-rc.1 - ARG PS_PACKAGE=powershell-${PS_VERSION}-linux-arm64.tar.gz + ARG PS_VERSION=7.5.0-preview.4 + ARG PACKAGE_VERSION=7.5.0_preview.4 + ARG PS_PACKAGE=powershell-preview-${PACKAGE_VERSION}-1.cm.aarch64.rpm ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE} ARG PS_INSTALL_VERSION=7-preview - # Define the folder we will be installing PowerShell to. - ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/${PS_INSTALL_VERSION} - - # Create the install folder. - RUN mkdir -p ${PS_INSTALL_FOLDER} + # Download the Linux tar.gz and save it + ADD ${PS_PACKAGE_URL} /tmp/powershell.rpm - ARG PS_PACKAGE_URL_BASE64 + # Don't use the cache mount since this image doesn't go into the final product and it causes issues with parralel operations with the next layer + RUN tdnf install -y \ + wget \ + awk \ + tar \ + ca-certificates RUN --mount=type=cache,target=/var/cache/tdnf \ - tdnf update -y \ - && tdnf install -y ca-certificates wget tar + --mount=type=cache,target=/installTmp \ + cd /installTmp \ + && wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh \ + && chmod +x ./dotnet-install.sh \ + && ./dotnet-install.sh -Channel 9.0 -Quality ga -Runtime dotnet -InstallDir /usr/share/dotnet - RUN echo 'in task' \ - && if [ -n "${PS_PACKAGE_URL_BASE64}" ]; then \ - echo 'using base64' \ - && export url=$(echo "${PS_PACKAGE_URL_BASE64}" | base64 --decode -); \ - else \ - echo 'using unencoded' \ - && export url="${PS_PACKAGE_URL}"; \ - fi \ - && echo "url: $url" \ - && wget -O /tmp/powershell.tar.gz "$url" \ - && echo 'task done' + RUN echo ${PS_PACKAGE_URL} - RUN ls -l /tmp/powershell.tar.gz +# Start a new stage so we lose all the package download layers from the final image +FROM setup-tdnf-repa AS powershell - # Unzip the linux powershell.tar.gz - RUN tar zxf /tmp/powershell.tar.gz -C ${PS_INSTALL_FOLDER} - -FROM --platform=linux/arm64 mcr.microsoft.com/cbl-mariner/base/core:2.0 AS final-image - - # Define Args and Env needed to create links + ARG PS_VERSION=7.5.0-preview.4 ARG PS_INSTALL_VERSION=7-preview - ARG PS_VERSION=7.4.0-rc.1 + # Define Args and Env needed to create links ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \ \ # Define ENVs for Localization/Globalization @@ -54,20 +53,47 @@ FROM --platform=linux/arm64 mcr.microsoft.com/cbl-mariner/base/core:2.0 AS final PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \ POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-arm64v7-Mariner-2 - # Copy only the files we need from the previous stage - COPY --from=installer-env ["/opt/microsoft/powershell", "/opt/microsoft/powershell"] - - RUN --mount=type=cache,target=/var/cache/tdnf,rw \ - tdnf update -y \ - && tdnf install -y icu less openssh-clients ca-certificates dotnet-runtime-7.0 \ - && tdnf upgrade -y \ + RUN --mount=type=cache,target=/var/cache/tdnf \ + # install dependencies + tdnf install -y \ + # required for localization + icu \ + # required for help in PowerShell + less \ + # required for SSH + openssh-clients \ + ca-certificates + + # Install dependencies and clean up + RUN --mount=type=cache,target=/var/cache/tdnf \ + tdnf upgrade -y \ + # clean cached data && tdnf clean all - # Give all user execute permissions and remove write permissions for others - RUN chmod a+x,o-w ${PS_INSTALL_FOLDER}/pwsh \ - # Create the pwsh symbolic link that points to powershell - && ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \ - && ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh-preview + COPY --from=installer-env /usr/share/dotnet /usr/share/dotnet + + RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet + + RUN --mount=type=cache,target=/var/cache/tdnf,rw \ + --mount=from=installer-env,target=/mnt/rpm,source=/tmp \ + rpm -i --nodeps /mnt/rpm/powershell.rpm + + # Create the pwsh symbolic link that points to powershell + RUN if [ -f "/opt/microsoft/powershell/7-preview/pwsh" ]; then ln -sf /opt/microsoft/powershell/7-preview/pwsh /usr/bin/pwsh; fi + + # intialize powershell module cache + # and disable telemetry for this ONE session + RUN export POWERSHELL_TELEMETRY_OPTOUT=1 \ + && pwsh \ + -NoLogo \ + -NoProfile \ + -Command " \ + \$ErrorActionPreference = 'Stop' ; \ + \$ProgressPreference = 'SilentlyContinue' ; \ + while(!(Test-Path -Path \$env:PSModuleAnalysisCachePath)) { \ + Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; \ + Start-Sleep -Seconds 6 ; \ + }" # Use PowerShell as the default shell # Use array to avoid Docker prepending /bin/sh -c diff --git a/release/7-5/mariner2-arm64/meta.json b/release/7-5/mariner2-arm64/meta.json index 7c0fd8cfc..973e673ab 100644 --- a/release/7-5/mariner2-arm64/meta.json +++ b/release/7-5/mariner2-arm64/meta.json @@ -1,7 +1,7 @@ { "IsLinux" : true, "UseLinuxVersion": false, - "PackageFormat": "powershell-${PS_VERSION}-linux-arm64.tar.gz", + "PackageFormat": "powershell${channelTag}-${PS_VERSION}-1.cm.aarch64.rpm", "osVersion": "Mariner 2.0 ARM 64v7", "SkipGssNtlmSspTests": true, "ShortDistroName": "mariner",