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