Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature #1580, Docker Image #1794

Merged
merged 83 commits into from
May 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
ecc8bee
building docker image in workflows
Mar 13, 2022
a55bae3
ls
Mar 13, 2022
0df8067
cd dev
Mar 13, 2022
12d3e6f
checkout
Mar 13, 2022
18f75ca
removing debug output
Mar 13, 2022
ac8acae
nightly version
Mar 14, 2022
99e27dc
docker login
Mar 14, 2022
902f251
docker secret
Mar 14, 2022
7777e91
pushing to docker hub
Mar 14, 2022
d193fa4
Merge branch 'pnp:dev' into dev
shurick81 Mar 14, 2022
96e559c
docker readme
Mar 14, 2022
f32567b
Merge branch 'dev' of https://github.com/alexsapozhkov/powershell int…
Mar 14, 2022
b90c916
Merge branch 'pnp:dev' into dev
shurick81 Mar 14, 2022
dec8521
using DOCKER_USERNAME and DOCKER_PASSWORD
Mar 14, 2022
12980d2
Merge branch 'dev' of https://github.com/alexsapozhkov/powershell int…
Mar 14, 2022
c0122b7
using DOCKER_USERNAME and DOCKER_PASSWORD
Mar 14, 2022
e1859ba
adding nightly tag
Mar 14, 2022
3e896f7
verified adding nightly tag
Mar 14, 2022
9f877c2
corrected user name ref
Mar 14, 2022
433d55a
run via schedule again
Mar 31, 2022
bb6f9f2
more specific job name
Mar 31, 2022
eb6fd6b
divided job into simpler steps
Mar 31, 2022
b8cf75a
Merge branch 'pnp:dev' into dev
shurick81 Mar 31, 2022
dad1ba5
testing pipeline for publishing
Mar 31, 2022
3450cc2
preparing for linux containers
Mar 31, 2022
f5b9651
triggering on yaml change
Mar 31, 2022
46ec4f2
password in quoutes
Mar 31, 2022
19c8a63
testing publishing script with parameters
Mar 31, 2022
e757923
no ` needed for pwsh jobs
Mar 31, 2022
80e54c3
Getting docker tags via Invoke-RestMethod
Mar 31, 2022
6a8e714
show every unpublished image
Mar 31, 2022
1d5ed1e
fixed version comparisons
Mar 31, 2022
f8c886c
publishin all not prereleases
Mar 31, 2022
57fb24e
safer manipulating with :
Mar 31, 2022
e10069a
replacing quotes
Mar 31, 2022
7083145
universal docker file
Mar 31, 2022
5fe379f
using universal dockerfile instead of special
Mar 31, 2022
5023a9b
listing published images with 10k limit
Mar 31, 2022
f3df357
release only running via schedule
Apr 1, 2022
64bdca8
updated base image version
Apr 1, 2022
99aad21
Merge branch 'pnp:dev' into dev
shurick81 Apr 1, 2022
fb57053
cleaning nightly release before merging to origin
Apr 1, 2022
4963cd5
Merge branch 'dev' of https://github.com/alexsapozhkov/powershell int…
Apr 1, 2022
c518b51
typo in yaml cleaning
Apr 1, 2022
5dda025
removing unused file
Apr 1, 2022
53ead61
removing unused file
Apr 1, 2022
10c206e
Merge branch 'pnp:dev' into dev
shurick81 Apr 19, 2022
d701583
Merge branch 'pnp:dev' into dev
shurick81 Apr 22, 2022
1dd7300
removing old files
Apr 22, 2022
0590d48
Merge branch 'dev' of https://github.com/alexsapozhkov/powershell int…
Apr 22, 2022
58f50ba
new line at end of file
Apr 22, 2022
fcae696
more documentation for manual publishing
Apr 22, 2022
2fc111f
removing unneccessary (so far) documentation
Apr 22, 2022
6c31163
Merge branch 'pnp:dev' into dev
shurick81 May 5, 2022
8c785ed
publishing image for 5 platform
May 11, 2022
bb6ba95
Merge branch 'dev' of https://github.com/alexsapozhkov/powershell int…
May 11, 2022
648bef5
fixing parameters in github actions
May 11, 2022
f304291
typo in space
May 11, 2022
22bbf90
sticking to 1 dockerfile
May 11, 2022
b7c01a8
altering installation user
May 11, 2022
20888fd
3 platforms for Windows is default
May 11, 2022
dc1dcfe
fixed string comparison
May 11, 2022
2a3c3e7
removing unnecessary quotes
May 11, 2022
b91081a
fixed logical comparison
May 11, 2022
05b0cfc
specifying platform for building
May 11, 2022
e6bcb17
using buildx for arm32v7-ubuntu-bionic
May 11, 2022
b07ee24
buildx debug output
May 11, 2022
b67fc31
buildx build --load
May 11, 2022
91ccc10
removing arm image
May 12, 2022
f80ce93
keeping 3 platforms
May 12, 2022
cf2abc5
publishing latest for only linux
May 12, 2022
6478344
nightly release for 3 platforms
May 12, 2022
b5f3244
Merge branch 'pnp:dev' into dev
shurick81 May 12, 2022
f531593
replacing with a fake job
May 12, 2022
051a63c
using PS syntax for Windows builder
May 12, 2022
a78076b
fixing more PS syntax in pipeline
May 12, 2022
cb7c5b1
returning back the module publishing steps
May 12, 2022
bd4a0c7
installing module for all the users
shurick81 May 12, 2022
73967df
removing arm image from docu
May 12, 2022
f3aa083
more user documentation
May 12, 2022
a214552
removed unused space in the dockerfile
May 12, 2022
cb4240d
reference to the PS gallery for versions
May 12, 2022
d5e91cd
correcting the pnp organization name in Docker
May 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion .github/workflows/nightlyrelease.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Nightly Release to PowerShell Gallery
name: Nightly Release to PowerShell Gallery and Docker Hub

on:
workflow_dispatch:
Expand Down Expand Up @@ -39,3 +39,50 @@ jobs:
push: true
branch: dev
token: ${{ secrets.PAT }}
publish-docker-windows-2022:
runs-on: windows-2022
needs: [ build ]
steps:
- uses: actions/checkout@v2
- name: Build an image
run: |
$VERSION="$(cat ./version.txt)-nightly"
docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=nanoserver-ltsc2022" --build-arg "INSTALL_USER=ContainerAdministrator" --build-arg "SKIP_PUBLISHER_CHECK=True" ./docker -f ./docker/pnppowershell.dockerFile --tag "${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-ltsc2022";
- name: Push the image
run: |
$VERSION="$(cat ./version.txt)-nightly"
docker login -u ${{ secrets.DOCKER_USERNAME }} -p '${{ secrets.DOCKER_PASSWORD }}'
docker push "${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-ltsc2022"
publish-docker-windows-2019:
runs-on: windows-2019
needs: [ build ]
steps:
- uses: actions/checkout@v2
- name: Build an image
run: |
$VERSION="$(cat ./version.txt)-nightly"
docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=nanoserver-1809" --build-arg "INSTALL_USER=ContainerAdministrator" --build-arg "SKIP_PUBLISHER_CHECK=True" ./docker -f ./docker/pnppowershell.dockerFile --tag "${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-1809";
- name: Push the image
run: |
$VERSION="$(cat ./version.txt)-nightly"
docker login -u ${{ secrets.DOCKER_USERNAME }} -p '${{ secrets.DOCKER_PASSWORD }}'
docker push "${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-1809"
publish-docker-linux:
runs-on: ubuntu-latest
needs: [ build ]
steps:
- uses: actions/checkout@v2
- name: Build an image
run: |
VERSION=$(cat ./version.txt)-nightly
docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=alpine-3.14" --build-arg "INSTALL_USER=root" --build-arg "SKIP_PUBLISHER_CHECK=False" ./docker -f ./docker/pnppowershell.dockerFile --tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-alpine-3.14;
- name: Tag the image
run: |
VERSION=$(cat ./version.txt)-nightly
docker image tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-alpine-3.14 ${{ secrets.DOCKER_USERNAME }}/powershell:nightly
- name: Push the image
run: |
VERSION=$(cat ./version.txt)-nightly
docker login -u ${{ secrets.DOCKER_USERNAME }} -p '${{ secrets.DOCKER_PASSWORD }}'
docker push ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-alpine-3.14
docker push ${{ secrets.DOCKER_USERNAME }}/powershell:nightly
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release to Docker Hub

on:
workflow_dispatch:
schedule:
- cron: '30 3 * * *'
jobs:
publish-docker-windows-2022:
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
- name: Build and Publish All
shell: pwsh
run: |
$securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force
./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "ContainerAdministrator" $true "nanoserver-ltsc2022"
publish-docker-windows-2019:
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- name: Build and Publish All
shell: pwsh
run: |
$securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force
./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "ContainerAdministrator" $true "nanoserver-1809"
publish-docker-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build and Publish All
shell: pwsh
run: |
$securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force
./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "root" $false "alpine-3.14"
60 changes: 60 additions & 0 deletions docker/Publish-UnpublishedImage.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Param(
[Parameter(Position = 0,
Mandatory = $true,
ValueFromPipeline = $false)]
[String]
$PS_MODULE_NAME,
[Parameter(Position = 1,
Mandatory = $true,
ValueFromPipeline = $false)]
[String]
$DOCKER_USERNAME,
[Parameter(Position = 2,
Mandatory = $true,
ValueFromPipeline = $false)]
[String]
$DOCKER_IMAGE_NAME,
[Parameter(Position = 3,
Mandatory = $true,
ValueFromPipeline = $false)]
[Security.SecureString]
$DOCKER_PASSWORD,
[Parameter(Position = 4,
Mandatory = $false,
ValueFromPipeline = $false)]
[String]
$DOCKER_INSTALL_USER = "ContainerAdministrator",
[Parameter(Position = 5,
Mandatory = $false,
ValueFromPipeline = $false)]
[bool]
$SKIP_PUBLISHER_CHECK = $false,
[Parameter(Position = 6,
Mandatory = $false,
ValueFromPipeline = $false)]
[String]
$DOCKER_IMAGE_SUFFIX_ARRAY = "nanoserver-ltsc2022"
)
$publishedImageVersions = (Invoke-RestMethod https://registry.hub.docker.com/v2/repositories/$DOCKER_USERNAME/$DOCKER_IMAGE_NAME/tags?page_size=10240).results | % {
$_.name
}
$moduleVersions = Find-Module $PS_MODULE_NAME -AllVersions;
[array]::Reverse($moduleVersions);
$moduleVersions | % {
$moduleVersion = $_.Version;
$DOCKER_IMAGE_SUFFIX_ARRAY.Split( "," ) | % {
$baseImageSuffix = $_;
$imageVersion = "$moduleVersion-$baseImageSuffix";
Write-Host "Checking $imageVersion"
if ( !( $publishedImageVersions -contains $imageVersion ) ) {
docker build --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion;
$plainStringPassword = [System.Net.NetworkCredential]::new("", $DOCKER_PASSWORD).Password;
docker login -u $DOCKER_USERNAME -p "$plainStringPassword";
docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion;
if ( $baseImageSuffix -eq "alpine-3.14") {
docker image tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest;
docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest;
}
}
}
}
64 changes: 64 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Publish manually in Windows

1. Set "DOCKER_USERNAME" and "DOCKER_PASSWORD" variables

2. Run

```powershell
$securedPassword = ConvertTo-SecureString $DOCKER_PASSWORD -AsPlainText -Force
./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword "ContainerAdministrator" $true "nanoserver-1809"
```

# Publish manually in Linux

1. Set "DOCKER_USERNAME" and "DOCKER_PASSWORD" variables

2. Run

```powershell
$securedPassword = ConvertTo-SecureString $DOCKER_PASSWORD -AsPlainText -Force
./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword $false "root" "alpine-3.14"
```

# Publish with prereleases manually in Windows

1. Set "DOCKER_USERNAME" and "DOCKER_PASSWORD" variables

2. Run

```PowerShell
$VERSION="$(cat ./version.txt)-nightly"
docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=nanoserver-ltsc2022" --build-arg "INSTALL_USER=ContainerAdministrator" --build-arg "SKIP_PUBLISHER_CHECK=True" ./docker -f ./docker/pnppowershell.dockerFile --tag "$DOCKER_USERNAME/powershell:$VERSION-nanoserver-ltsc2022";
$VERSION="$(cat ./version.txt)-nightly"
docker login -u $DOCKER_USERNAME -p "$DOCKER_PASSWORD"
docker push "$DOCKER_USERNAME/powershell:$VERSION-nanoserver-ltsc2022"
```

or

```PowerShell
$VERSION="$(cat ./version.txt)-nightly"
docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=nanoserver-1809" --build-arg "INSTALL_USER=ContainerAdministrator" --build-arg "SKIP_PUBLISHER_CHECK=True" ./docker -f ./docker/pnppowershell.dockerFile --tag "$DOCKER_USERNAME/powershell:$VERSION-nanoserver-1809";
$VERSION="$(cat ./version.txt)-nightly"
docker login -u $DOCKER_USERNAME -p "$DOCKER_PASSWORD"
docker push "$DOCKER_USERNAME/powershell:$VERSION-nanoserver-1809"
```

# Publish with prereleases manually in Linux

1. Set "DOCKER_USERNAME" and "DOCKER_PASSWORD" variables

2. Run

```bash
VERSION=$(cat ./version.txt)-nightly
docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=alpine-3.14" --build-arg "INSTALL_USER=root" --build-arg "SKIP_PUBLISHER_CHECK=False" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/powershell:$VERSION-alpine-3.14;
docker image tag $DOCKER_USERNAME/powershell:$VERSION-alpine-3.14 $DOCKER_USERNAME/powershell:nightly
docker login -u $DOCKER_USERNAME -p "$DOCKER_PASSWORD"
docker push $DOCKER_USERNAME/powershell:$VERSION-alpine-3.14
docker push $DOCKER_USERNAME/powershell:nightly
```

# Publish automatically with Github Actions

Set "DOCKER_USERNAME" and "DOCKER_PASSWORD" variables in Github Actions Secrets
1 change: 0 additions & 1 deletion docker/build.ps1

This file was deleted.

77 changes: 77 additions & 0 deletions docker/hub.docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# PnP.Powershell

## Featured tags

### Latest

* latest: The latest stable image

* alpine-3.14
* `docker pull m365pnp/powershell` or `docker pull m365pnp/powershell:latest`

### Nightly

* nightly: The latest night image

* alpine-3.14
* `docker pull m365pnp/powershell:nightly`

## About this image

**PnP PowerShell** is a .NET Core 3.1 / .NET Framework 4.6.1 based PowerShell Module providing over 600 cmdlets that work with Microsoft 365 environments such as SharePoint Online, Microsoft Teams, Microsoft Project, Security & Compliance, Azure Active Directory, and more.

## Usage examples

### Windows-container

Starting an isolated container with PnP.PowerShell module installed:

```
docker run --rm -it asapozhkov/powershell:1.10.0-nanoserver-1809
```

Starting a PnP.PowerShell container with the current directory mounted:

```PowerShell
docker run --rm -it -v ${PWD}:c:/app -w c:/app asapozhkov/powershell:1.10.0-nanoserver-1809
```

### Linux-container

Starting an isolated container with PnP.PowerShell module installed:

```
docker run --rm -it asapozhkov/powershell
```

Starting a PnP.PowerShell container with the current directory mounted:

```bash
docker run --rm -it -v ${PWD}:/home -w /home asapozhkov/powershell
```

## Tag explanation

Tags names mean the following:

`<version>(-nightly)-<platform>`

Currently supported platforms:

* nanoserver-ltsc2022
* nanoserver-1809
* alpine-3.14

Tag name examples:

* 1.8.0-nanoserver-ltsc2022
* 1.9.0-nanoserver-ltsc2022
* 1.10.0-nanoserver-1809
* 1.10.0-alpine-3.14
* 1.10.26-nightly-nanoserver-ltsc2022

To find the version numbers please visit https://www.powershellgallery.com/packages/PnP.PowerShell

## Feedback

* To give feedback for PnP.PowerShell or for how the images are built, file an issue at [PnP/PowerShell](https://github.com/pnp/powershell/issues/new/choose)
18 changes: 15 additions & 3 deletions docker/pnppowershell.dockerFile
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
FROM mcr.microsoft.com/powershell:lts-debian-10
COPY ./powershell/ powershell
RUN /usr/bin/pwsh -File ./powershell/installModules.ps1 && rm -rf ./powershell
ARG BASE_IMAGE_SUFFIX=alpine-3.14
ARG BASE_IMAGE=mcr.microsoft.com/powershell:lts-7.2-$BASE_IMAGE_SUFFIX
FROM $BASE_IMAGE

SHELL ["pwsh", "-command"]
ARG INSTALL_USER=ContainerAdministrator
USER $INSTALL_USER
ARG PNP_MODULE_VERSION
ARG SKIP_PUBLISHER_CHECK=TRUE
RUN if ( $env:SKIP_PUBLISHER_CHECK -eq $true ) { \
Write-Host "SKIP_PUBLISHER_CHECK"; \
Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease -Scope AllUsers -SkipPublisherCheck; \
} else { \
Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease -Scope AllUsers; \
}
20 changes: 0 additions & 20 deletions docker/powershell/installModules.ps1

This file was deleted.

1 change: 0 additions & 1 deletion docker/runlocal.ps1

This file was deleted.

12 changes: 12 additions & 0 deletions pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ To install a nightly build of PnP PowerShell:
Install-Module -Name PnP.PowerShell -AllowPrerelease -SkipPublisherCheck -AllowClobber
```

To use PnP.PowerShell in a Windows container:

```
docker run -it m365pnp/powershell:1.10.0-nanoserver-1809
```

To use PnP.PowerShell in a Linux container:

```
docker run -it m365pnp/powershell
```

See the [articles](/powershell/articles) section for more information on authentication and configuration. All [cmdlets](/powershell/cmdlets/Add-PnPAlert.html) have been documented too.

# I've found a bug, where do I need to log an issue or create a PR
Expand Down