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