|
3 | 3 |
|
4 | 4 | FROM mcr.microsoft.com/cbl-mariner/base/core:2.0 AS setup-tdnf-repa |
5 | 5 |
|
6 | | -RUN --mount=type=cache,target=/var/cache/tdnf \ |
7 | | - tdnf install -y mariner-repos-microsoft-preview \ |
8 | | - && tdnf makecache |
| 6 | + # Use the cache mount since this image does go into the final product |
| 7 | + RUN --mount=type=cache,target=/var/cache/tdnf \ |
| 8 | + tdnf install -y mariner-repos-microsoft-preview \ |
| 9 | + && tdnf makecache |
9 | 10 |
|
10 | | -# Move to |
| 11 | +# Download packages into a container so they don't take up space in the final stage |
11 | 12 | FROM setup-tdnf-repa AS installer-env |
12 | 13 |
|
13 | | -# Define Args for the needed to add the package |
14 | | -ARG PS_VERSION=7.3.0-preview.8 |
15 | | -ARG PACKAGE_VERSION=7.3.0_preview.8 |
16 | | -ARG PS_PACKAGE=powershell-preview-${PACKAGE_VERSION}-1.cm.x86_64.rpm |
17 | | -ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE} |
18 | | -ARG PS_INSTALL_VERSION=7-preview |
| 14 | + # Define Args for the needed to add the package |
| 15 | + ARG PS_VERSION=7.3.0-preview.8 |
| 16 | + ARG PACKAGE_VERSION=7.3.0_preview.8 |
| 17 | + ARG PS_PACKAGE=powershell-preview-${PACKAGE_VERSION}-1.cm.x86_64.rpm |
| 18 | + ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE} |
| 19 | + ARG PS_INSTALL_VERSION=7-preview |
19 | 20 |
|
20 | | -# Download the Linux tar.gz and save it |
21 | | -ADD ${PS_PACKAGE_URL} /tmp/powershell.rpm |
| 21 | + # Download the Linux tar.gz and save it |
| 22 | + ADD ${PS_PACKAGE_URL} /tmp/powershell.rpm |
22 | 23 |
|
23 | | -RUN --mount=type=cache,target=/var/cache/tdnf \ |
24 | | - tdnf install -y \ |
| 24 | + # 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 |
| 25 | + RUN tdnf install -y \ |
25 | 26 | wget \ |
26 | 27 | awk \ |
27 | 28 | tar \ |
28 | 29 | ca-certificates |
29 | 30 |
|
30 | | -RUN --mount=type=cache,target=/var/cache/tdnf \ |
31 | | - --mount=type=cache,target=/installTmp \ |
32 | | - cd /installTmp \ |
33 | | - && wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh \ |
34 | | - && chmod +x ./dotnet-install.sh \ |
35 | | - && ./dotnet-install.sh -Channel 8.0 -Quality preview -Runtime dotnet -InstallDir /usr/share/dotnet |
| 31 | + RUN --mount=type=cache,target=/var/cache/tdnf \ |
| 32 | + --mount=type=cache,target=/installTmp \ |
| 33 | + cd /installTmp \ |
| 34 | + && wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh \ |
| 35 | + && chmod +x ./dotnet-install.sh \ |
| 36 | + && ./dotnet-install.sh -Channel 8.0 -Quality preview -Runtime dotnet -InstallDir /usr/share/dotnet |
36 | 37 |
|
37 | | -RUN echo ${PS_PACKAGE_URL} |
| 38 | + RUN echo ${PS_PACKAGE_URL} |
38 | 39 |
|
39 | | -# Start a new stage so we lose all the tar.gz layers from the final image |
| 40 | +# Start a new stage so we lose all the package download layers from the final image |
40 | 41 | FROM setup-tdnf-repa AS powershell |
41 | 42 |
|
42 | | -ARG PS_VERSION=7.3.0-preview.8 |
43 | | -ARG PS_INSTALL_VERSION=7-preview |
44 | | - |
45 | | -# Define Args and Env needed to create links |
46 | | -ARG PS_INSTALL_VERSION=7-preview |
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-Mariner-2.0 |
56 | | - |
57 | | -RUN --mount=type=cache,target=/var/cache/tdnf \ |
58 | | - # install dependencies |
59 | | - tdnf install -y \ |
60 | | - # required for localization |
61 | | - icu \ |
62 | | - # required for help in PowerShell |
63 | | - less \ |
64 | | - # required for SSH |
65 | | - openssh-clients \ |
66 | | - ca-certificates |
67 | | - |
68 | | -# Install dependencies and clean up |
69 | | -RUN --mount=type=cache,target=/var/cache/tdnf \ |
70 | | - tdnf upgrade -y \ |
71 | | - # clean cached data |
72 | | - && tdnf clean all |
73 | | - |
74 | | -COPY --from=installer-env /usr/share/dotnet /usr/share/dotnet |
75 | | - |
76 | | -RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet |
77 | | - |
78 | | -RUN --mount=type=cache,target=/var/cache/tdnf,rw \ |
79 | | - --mount=from=installer-env,target=/mnt/rpm,source=/tmp \ |
80 | | - rpm -i --nodeps /mnt/rpm/powershell.rpm |
81 | | - |
82 | | -# Create the pwsh symbolic link that points to powershell |
83 | | -RUN if [ -f "/opt/microsoft/powershell/7-preview/pwsh" ]; then ln -sf /opt/microsoft/powershell/7-preview/pwsh /usr/bin/pwsh; fi |
84 | | - |
85 | | -# intialize powershell module cache |
86 | | -# and disable telemetry for this ONE session |
87 | | -RUN export POWERSHELL_TELEMETRY_OPTOUT=1 \ |
88 | | - && pwsh \ |
89 | | - -NoLogo \ |
90 | | - -NoProfile \ |
91 | | - -Command " \ |
92 | | - \$ErrorActionPreference = 'Stop' ; \ |
93 | | - \$ProgressPreference = 'SilentlyContinue' ; \ |
94 | | - while(!(Test-Path -Path \$env:PSModuleAnalysisCachePath)) { \ |
95 | | - Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; \ |
96 | | - Start-Sleep -Seconds 6 ; \ |
97 | | - }" |
98 | | - |
99 | | -# Use PowerShell as the default shell |
100 | | -# Use array to avoid Docker prepending /bin/sh -c |
101 | | -CMD [ "pwsh" ] |
| 43 | + ARG PS_VERSION=7.3.0-preview.8 |
| 44 | + ARG PS_INSTALL_VERSION=7-preview |
| 45 | + |
| 46 | + # Define Args and Env needed to create links |
| 47 | + ARG PS_INSTALL_VERSION=7-preview |
| 48 | + ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \ |
| 49 | + \ |
| 50 | + # Define ENVs for Localization/Globalization |
| 51 | + DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \ |
| 52 | + LC_ALL=en_US.UTF-8 \ |
| 53 | + LANG=en_US.UTF-8 \ |
| 54 | + # set a fixed location for the Module analysis cache |
| 55 | + PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \ |
| 56 | + POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-Mariner-2.0 |
| 57 | + |
| 58 | + RUN --mount=type=cache,target=/var/cache/tdnf \ |
| 59 | + # install dependencies |
| 60 | + tdnf install -y \ |
| 61 | + # required for localization |
| 62 | + icu \ |
| 63 | + # required for help in PowerShell |
| 64 | + less \ |
| 65 | + # required for SSH |
| 66 | + openssh-clients \ |
| 67 | + ca-certificates |
| 68 | + |
| 69 | + # Install dependencies and clean up |
| 70 | + RUN --mount=type=cache,target=/var/cache/tdnf \ |
| 71 | + tdnf upgrade -y \ |
| 72 | + # clean cached data |
| 73 | + && tdnf clean all |
| 74 | + |
| 75 | + COPY --from=installer-env /usr/share/dotnet /usr/share/dotnet |
| 76 | + |
| 77 | + RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet |
| 78 | + |
| 79 | + RUN --mount=type=cache,target=/var/cache/tdnf,rw \ |
| 80 | + --mount=from=installer-env,target=/mnt/rpm,source=/tmp \ |
| 81 | + rpm -i --nodeps /mnt/rpm/powershell.rpm |
| 82 | + |
| 83 | + # Create the pwsh symbolic link that points to powershell |
| 84 | + RUN if [ -f "/opt/microsoft/powershell/7-preview/pwsh" ]; then ln -sf /opt/microsoft/powershell/7-preview/pwsh /usr/bin/pwsh; fi |
| 85 | + |
| 86 | + # intialize powershell module cache |
| 87 | + # and disable telemetry for this ONE session |
| 88 | + RUN export POWERSHELL_TELEMETRY_OPTOUT=1 \ |
| 89 | + && pwsh \ |
| 90 | + -NoLogo \ |
| 91 | + -NoProfile \ |
| 92 | + -Command " \ |
| 93 | + \$ErrorActionPreference = 'Stop' ; \ |
| 94 | + \$ProgressPreference = 'SilentlyContinue' ; \ |
| 95 | + while(!(Test-Path -Path \$env:PSModuleAnalysisCachePath)) { \ |
| 96 | + Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; \ |
| 97 | + Start-Sleep -Seconds 6 ; \ |
| 98 | + }" |
| 99 | + |
| 100 | + # Use PowerShell as the default shell |
| 101 | + # Use array to avoid Docker prepending /bin/sh -c |
| 102 | + CMD [ "pwsh" ] |
0 commit comments