Skip to content

Commit

Permalink
Add Debian 8, 9 and OpenSuse 42.3 images (#47)
Browse files Browse the repository at this point in the history
- Add test to verify local of images
- fix various typos
  • Loading branch information
TravisEz13 authored Sep 26, 2018
1 parent bd2e0a1 commit 05ad055
Show file tree
Hide file tree
Showing 28 changed files with 348 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ VERBOSE: image name: powershell.local:6.1.0-preview.2-ubuntu-trusty
VERBOSE: image name: powershell.local:6.1.0-preview.2-ubuntu-trusty-20180531
```

### Run the docker image you built
### Run the Docker image you built

```sh
PS /powershell-docker> docker run -it --rm powershell.local:6.1.0-preview.2-ubuntu-14.04 pwsh -c '$psversiontable'
Expand Down
2 changes: 1 addition & 1 deletion createAllManifests.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

# script to create the docker manifest lists
# script to create the Docker manifest lists
param (
[ValidateNotNullOrEmpty()]
[string]
Expand Down
2 changes: 1 addition & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Development

## Adding new docker image
## Adding new Docker image

### Folder structure

Expand Down
2 changes: 1 addition & 1 deletion release/preview/centos7/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Docker image file that describes an Centos7 image with PowerShell installed from Microsoft YUM Repo
# Docker image file that describes an CentOS7 image with PowerShell installed from Microsoft YUM Repo
ARG fromTag=7

FROM centos:${fromTag}
Expand Down
4 changes: 2 additions & 2 deletions release/preview/centos7/getLatestTag.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

# return objects representing the tags we need to base the xenial image on
# return objects representing the tags we need to base the CentOS image on Docker

# The versions of xenial we care about
# The versions of CentOS we care about
$shortTags = @('7')

$parent = Join-Path -Path $PSScriptRoot -ChildPath '..'
Expand Down
2 changes: 1 addition & 1 deletion release/preview/nanoserver/getLatestTag.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if(!$CI.IsPresent)
Get-DockerTags -ShortTags $shortTags -Image "microsoft/nanoserver" -FullTagFilter '\d{4}_KB\d{7}'
}
else {
# This is not supported for nanoserver so don't build in production but try building it as a CI test for the dockerfile
# This is not supported for nanoserver so don't build in production but try building it as a CI test for the Dockerfile
$shortTags = @('latest')

# The \d{4,} part of the regex is because the API is returning tags which are 3 digits and older than the 4 digit tags
Expand Down
2 changes: 1 addition & 1 deletion release/servicing/centos7/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Docker image file that describes an Centos7 image with PowerShell installed from Microsoft YUM Repo
# Docker image file that describes an CentOS7 image with PowerShell installed from Microsoft YUM Repo
ARG fromTag=7

FROM centos:${fromTag}
Expand Down
2 changes: 1 addition & 1 deletion release/servicing/nanoserver/getLatestTag.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if(!$CI.IsPresent)
Get-DockerTags -ShortTags $shortTags -Image "microsoft/nanoserver" -FullTagFilter '\d{4}_KB\d{7}'
}
else {
# This is not supported for nanoserver so don't build in production but try building it as a CI test for the dockerfile
# This is not supported for nanoserver so don't build in production but try building it as a CI test for the Dockerfile
$shortTags = @('latest')

# The \d{4,} part of the regex is because the API is returning tags which are 3 digits and older than the 4 digit tags
Expand Down
7 changes: 4 additions & 3 deletions release/stable/alpine/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ RUN mkdir -p ${PS_INSTALL_FOLDER}
# Unzip the Linux tar.gz
RUN tar zxf /tmp/linux.tar.gz -C ${PS_INSTALL_FOLDER}

# TODO: once the official build produces a full package for Alpine, remove this overlay of the apline files
# Download the apline powershell .tar.gz package
# TODO: once the official build produces a full package for Alpine, remove this overlay of the Alpine files
# Download the Alpine powershell .tar.gz package
ADD ${PS_PACKAGE_MUSL_URL} /tmp/alpine.tar.gz

# Extract the Alpine tar.gz
Expand Down Expand Up @@ -79,7 +79,8 @@ RUN apk add --no-cache \
ARG PS_VERSION=6.1.0
ARG IMAGE_NAME=mcr.microsoft.com/powershell:alpine-3.8
ARG VCS_REF="none"
# Add label last as it's just metadata and usere a lot a parameters

# Add label last as it's just metadata and uses a lot of parameters
LABEL maintainer="PowerShell Team <[email protected]>" \
readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
description="This Dockerfile will install the latest release of PowerShell." \
Expand Down
2 changes: 1 addition & 1 deletion release/stable/centos7/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Docker image file that describes an Centos7 image with PowerShell installed from Microsoft YUM Repo
# Docker image file that describes an CentOS7 image with PowerShell installed from Microsoft YUM Repo
ARG fromTag=7

FROM centos:${fromTag}
Expand Down
4 changes: 2 additions & 2 deletions release/stable/centos7/getLatestTag.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

# return objects representing the tags we need to base the xenial image on
# return objects representing the tags we need to base the CentOS image on Docker

# The versions of xenial we care about
# The versions of CentOS we care about
$shortTags = @('7')

$parent = Join-Path -Path $PSScriptRoot -ChildPath '..'
Expand Down
40 changes: 40 additions & 0 deletions release/stable/debian8/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Docker image file that describes an Debian 8 image with PowerShell installed from Microsoft APT Repo
ARG fromTag=jessie

FROM debian:${fromTag}

ARG PS_VERSION=6.1.0
ARG PS_VERSION_POSTFIX=-1.debian.8
ARG IMAGE_NAME=mcr.microsoft.com/powershell:debian-jessie
ARG VCS_REF="none"

# Install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
ca-certificates \
curl \
apt-transport-https \
locales

# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN locale-gen $LANG && update-locale

# Import the public repository GPG keys
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

# Register the Microsoft Product feed
RUN echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-jessie-prod jessie main" > /etc/apt/sources.list.d/microsoft.list

# Install powershell from Microsoft Repo
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
powershell=${PS_VERSION}${PS_VERSION_POSTFIX} \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Use PowerShell as the default shell
# Use array to avoid Docker prepending /bin/sh -c
CMD [ "pwsh" ]
14 changes: 14 additions & 0 deletions release/stable/debian8/getLatestTag.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

# return objects representing the tags we need to base the debian image on

# The versions of debian we care about
$shortTags = @('jessie')

$parent = Join-Path -Path $PSScriptRoot -ChildPath '..'
$repoRoot = Join-Path -path (Join-Path -Path $parent -ChildPath '..') -ChildPath '..'
$modulePath = Join-Path -Path $repoRoot -ChildPath 'tools\getDockerTags'
Import-Module $modulePath

Get-DockerTags -ShortTags $shortTags -Image "debian" -FullTagFilter 'jessie-\d{8}[\.\d{1}]?' -AlternativeShortTag '8'
3 changes: 3 additions & 0 deletions release/stable/debian8/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"IsLinux" : true
}
4 changes: 4 additions & 0 deletions release/stable/debian8/tags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
"#psversion#-debian-#tag#",
"debian-#shorttag#"
]
41 changes: 41 additions & 0 deletions release/stable/debian9/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Docker image file that describes an Debian 9 image with PowerShell installed from Microsoft APT Repo
ARG fromTag=stretch

FROM debian:${fromTag}

ARG PS_VERSION=6.1.0
ARG PS_VERSION_POSTFIX=-1.debian.9
ARG IMAGE_NAME=mcr.microsoft.com/powershell:debian-jessie
ARG VCS_REF="none"

# Install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
ca-certificates \
curl \
apt-transport-https \
locales \
gnupg

# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN locale-gen $LANG && update-locale

# Import the public repository GPG keys
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

# Register the Microsoft Product feed
RUN echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main" > /etc/apt/sources.list.d/microsoft.list

# Install powershell from Microsoft Repo
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
powershell=${PS_VERSION}${PS_VERSION_POSTFIX} \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Use PowerShell as the default shell
# Use array to avoid Docker prepending /bin/sh -c
CMD [ "pwsh" ]
14 changes: 14 additions & 0 deletions release/stable/debian9/getLatestTag.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

# return objects representing the tags we need to base the debian image on Docker

# The versions of debian we care about
$shortTags = @('stretch')

$parent = Join-Path -Path $PSScriptRoot -ChildPath '..'
$repoRoot = Join-Path -path (Join-Path -Path $parent -ChildPath '..') -ChildPath '..'
$modulePath = Join-Path -Path $repoRoot -ChildPath 'tools\getDockerTags'
Import-Module $modulePath

Get-DockerTags -ShortTags $shortTags -Image "debian" -FullTagFilter 'stretch-\d{8}[\.\d{1}]?' -AlternativeShortTag '8'
3 changes: 3 additions & 0 deletions release/stable/debian9/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"IsLinux" : true
}
4 changes: 4 additions & 0 deletions release/stable/debian9/tags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
"#psversion#-debian-#tag#",
"debian-#shorttag#"
]
2 changes: 1 addition & 1 deletion release/stable/nanoserver/getLatestTag.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if(!$CI.IsPresent)
Get-DockerTags -ShortTags $shortTags -Image "microsoft/nanoserver" -FullTagFilter '\d{4}_KB\d{7}'
}
else {
# This is not supported for nanoserver so don't build in production but try building it as a CI test for the dockerfile
# This is not supported for nanoserver so don't build in production but try building it as a CI test for the Dockerfile
$shortTags = @('latest')

# The \d{4,} part of the regex is because the API is returning tags which are 3 digits and older than the 4 digit tags
Expand Down
88 changes: 88 additions & 0 deletions release/stable/opensuse423/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Docker image file that describes an OpenSuse 42.3 image with PowerShell installed from tar.gz
# Implemented in two stages, one that downloads and uncompresses the tar.gz
# The next stage simply copies the files from the first stage,
# effectively removing the tar.gz and packages that are not needed from the final image.

# Define arg(s) needed for the From statement
ARG fromTag=42.3

FROM opensuse:${fromTag} AS installer-env


# Define Args for the needed to add the package
ARG PS_VERSION=6.1.0
ARG PS_PACKAGE=powershell-${PS_VERSION}-linux-x64.tar.gz
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE}
ARG PS_INSTALL_VERSION=6

# 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}

# Install dependencies
RUN zypper --non-interactive update --skip-interactive

RUN zypper --non-interactive install \
tar

# downoad the Linux tar.gz and save it
ADD ${PS_PACKAGE_URL} /tmp/linux.tar.gz

# Unzip the Linux tar.gz
RUN tar zxf /tmp/linux.tar.gz -C ${PS_INSTALL_FOLDER}

# ------ Second stage ------
# Start a new stage so we loose all the tar.gz layers from the final image
FROM opensuse:${fromTag}

# Install dependencies
RUN zypper --non-interactive update --skip-interactive \
&& zypper --non-interactive install \
glibc-locale \
glibc-i18ndata \
libunwind \
libicu \
openssl

# Copy only the files we need from the previous stag
COPY --from=installer-env ["/opt/microsoft/powershell", "/opt/microsoft/powershell"]

# Define Args and Env needed to create links
ARG PS_INSTALL_VERSION=6
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

RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG \
\
# Create the pwsh symbolic link that points to powershell
&& ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh

# Define args needed only for the labels
ARG PS_VERSION=6.1.0
ARG IMAGE_NAME=mcr.microsoft.com/powershell:opensuse-42.3
ARG VCS_REF="none"

# Add label last as it's just metadata and uses a lot of parameters
LABEL maintainer="PowerShell Team <[email protected]>" \
readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
description="This Dockerfile will install the latest release of PowerShell." \
org.label-schema.usage="https://github.com/PowerShell/PowerShell/tree/master/docker#run-the-docker-image-you-built" \
org.label-schema.url="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
org.label-schema.vcs-url="https://github.com/PowerShell/PowerShell-Docker" \
org.label-schema.name="powershell" \
org.label-schema.vendor="PowerShell" \
org.label-schema.vcs-ref=${VCS_REF} \
org.label-schema.version=${PS_VERSION} \
org.label-schema.schema-version="1.0" \
org.label-schema.docker.cmd="docker run ${IMAGE_NAME} pwsh -c '$psversiontable'" \
org.label-schema.docker.cmd.devel="docker run ${IMAGE_NAME}" \
org.label-schema.docker.cmd.test="docker run ${IMAGE_NAME} pwsh -c Invoke-Pester" \
org.label-schema.docker.cmd.help="docker run ${IMAGE_NAME} pwsh -c Get-Help"

CMD [ "pwsh" ]
14 changes: 14 additions & 0 deletions release/stable/opensuse423/getLatestTag.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

# return objects representing the tags we need to base the opensuse image on Docker

# The versions of opensuse we care about
$shortTags = @('42.3')

$parent = Join-Path -Path $PSScriptRoot -ChildPath '..'
$repoRoot = Join-Path -path (Join-Path -Path $parent -ChildPath '..') -ChildPath '..'
$modulePath = Join-Path -Path $repoRoot -ChildPath 'tools\getDockerTags'
Import-Module $modulePath

Get-DockerTags -ShortTags $shortTags -Image "opensuse" -FullTagFilter '^42.3$' -OnlyShortTags
3 changes: 3 additions & 0 deletions release/stable/opensuse423/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"IsLinux" : true
}
4 changes: 4 additions & 0 deletions release/stable/opensuse423/tags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
"#psversion#-opensuse-#tag#",
"opensuse-#shorttag#"
]
2 changes: 1 addition & 1 deletion republish.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

# Republishes images between mcr.microsoft.com and docker hub until mcr.microsoft.com automatically republishes to docker hub
# Republishes images between mcr.microsoft.com and Docker hub until mcr.microsoft.com automatically republishes to Docker hub
# This should be enabled now, but we will keep the script around until it proves reliable
param(
$stableVersion = '6.0.4',
Expand Down
Loading

0 comments on commit 05ad055

Please sign in to comment.