/
Dockerfile
71 lines (66 loc) · 2.42 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# Docker image file that describes an Amazon Linux image with PowerShell
# installed from RHEL7 PowerShell package
# Define arg(s) needed for the From statement
FROM amazonlinux:latest AS installer-env
# Define Args for the needed to add the package
ARG PS_VERSION=7.0.1
ARG PS_PACKAGE=powershell-${PS_VERSION}-1.rh.x86_64.rpm
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE}
ARG PS_INSTALL_VERSION=7
# Define Args and Env needed to create links
ENV \
PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
# Define ENVs for Localization/Globalization
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
# Set up PowerShell module analysis cache path
PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \
POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-AmazonLinux-latest
# Installation
RUN \
# update package list
yum update -y \
# install dependencies
&& yum install -y \
# required for help in PowerShell
less \
# required for SSH
openssh-clients \
# install EPEL repository
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
# update package list from EPEL repository
&& yum update -y \
# install dependencies from EPEL repository
&& yum install -y \
# install gssntlmssp package
gssntlmssp \
# download the powershell package
&& curl -sSL ${PS_PACKAGE_URL} -o /tmp/powershell-linux.rpm \
# install powershell package
&& yum install -y /tmp/powershell-linux.rpm \
# remove powershell package
&& rm -f /tmp/powershell-linux.rpm \
# intialize powershell module cache
# and disable telemetry
&& 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 ; \
}" \
# upgrade packages
&& yum upgrade -y \
# clean cached data
&& yum clean all \
# remove cache folders and files
&& rm -rf /var/cache/yum
CMD [ "pwsh" ]