From 5a84e60c13109b01af1b44a5fa19333590c747b6 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 20 Jun 2017 10:42:26 -0700 Subject: [PATCH] Remove nightly docker images (#4052) --- .spelling | 2 + docker/README.md | 160 ++++++++++-------------- docker/launch.sh | 88 ------------- docker/nightly/centos7/Dockerfile | 18 --- docker/nightly/fedora24/Dockerfile | 17 --- docker/nightly/ubuntu14.04/Dockerfile | 17 --- docker/nightly/ubuntu16.04/Dockerfile | 18 --- test/common/markdown/markdown.tests.ps1 | 1 + 8 files changed, 68 insertions(+), 253 deletions(-) delete mode 100755 docker/launch.sh delete mode 100644 docker/nightly/centos7/Dockerfile delete mode 100644 docker/nightly/fedora24/Dockerfile delete mode 100644 docker/nightly/ubuntu14.04/Dockerfile delete mode 100644 docker/nightly/ubuntu16.04/Dockerfile diff --git a/.spelling b/.spelling index 7e6b3aa1ea..a99f7ec1d8 100644 --- a/.spelling +++ b/.spelling @@ -165,6 +165,8 @@ journalctl SystemD - docker/README.md andschwa's +hub.docker.com +microsoft - docs/building/internals.md Catalog src diff --git a/docker/README.md b/docker/README.md index e7486f01f6..7618931b80 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,8 +1,6 @@ -Docker -====== +# Docker -These DockerFiles enable building and running PowerShell in a container for each Linux distribution we support. -There are two sets: release and nightly. +These DockerFiles enable running PowerShell in a container for each Linux distribution we support. This requires an up-to-date version of Docker, such as 1.12. It also expects you to be able to run Docker without `sudo`. @@ -10,8 +8,7 @@ Please follow [Docker's official instructions][install] to install `docker` corr [install]: https://docs.docker.com/engine/installation/ -Release -------- +## Release The release containers derive from the official distribution image, such as `centos:7`, then install dependencies, @@ -26,65 +23,7 @@ and about 120 megabytes of .NET Core and bootstrapping dependencies. [docker-release]: https://hub.docker.com/r/microsoft/powershell/ -Nightly -------- - -The nightly containers derive from their respective release images, -such as `microsoft/powershell:centos7`, -then run the `bootstrap.ps1` script which clones the repository, -runs `Start-PSBootstrap -Package` to install building and packaging tools, -runs `Start-PSBuild -Crossgen -PSModuleRestore` to build PowerShell with native-image DLLs, -runs `Start-PSPackage` to generate the platform's package, -and finally installs the generated package. - -These containers live at [hub.docker.com/r/microsoft/powershell-nightly][docker-nightly]. - -At about 4 gigabytes, -these images are *much* larger due to having all the tools installed. -This is intended so that the containers are useful for reproducing packages. - -[docker-nightly]: https://hub.docker.com/r/microsoft/powershell-nightly/ - -Automation -========== - -A script, `launch.sh`, exists to automatically build all the respective images. -It has a few configuration options, -passed in as environment variables: - -* `FORK`: the fork to clone in nightly builds (default: `PowerShell`) - * Set `FORK=andschwa` to clone https://github.com/andschwa/PowerShell - -* `BRANCH`: the branch to checkout in nightly builds (default: `master`) - * Set `BRANCH=feature-A` to checkout the `feature-A` branch - -* `BUILDS`: the type of builds to run (default: `release nightly`) - * This is order dependent! Release images must exist for nightly images to be built - * Set `BUILDS=release` to run the script for just the release images - -* `DISTROS`: the distributions of Linux to run (default: `ubuntu14.04 ubuntu16.04 centos7`) - * Set `DISTROS=centos7` to build just CentOS 7 images - * Combine with `BUILDS` to filter - -* `TEST`: set to 1 to `docker run Start-PSPester` inside the containers - * The containers *must* first exist; this skips the build step - -* `BUILDARGS`: additional arguments to be passed to `docker build` during building - * Set `BUILDARGS="--no-cache"` to rebuild and ignore cached layers - -* `RUNARGS`: additional arguments to be passed to `docker run` during testing - * Set `RUNARGS="--rm"` to automatically delete the test container when finished - -For each build type (release and nightly), -the selected distributions will run in parallel. -The output is sent to log files in `docker/logs`. -For nightly builds, the generated packages are copied to `docker/packages`. - -This script is very new, and there may be bugs. -Use `set -x` to see exactly what commands it is running. - -Examples --------- +## Examples To run PowerShell from using a container: @@ -103,46 +42,77 @@ adf6ad28fa0e: Pull complete Digest: sha256:92c79c5fcdaf3027626643aef556344b8b4cbdaccf8443f543303319949c7f3a Status: Downloaded newer image for microsoft/powershell:latest PowerShell -Copyright (C) 2016 Microsoft Corporation. All rights reserved. +Copyright © 2016 Microsoft Corporation. All rights reserved. PS /> Write-Host "Hello, World!" Hello, World! ``` -To build a CentOS container with the latest released package: +## Building the images + +The images are built with the [`docker image build`](https://docs.docker.com/engine/reference/commandline/image_build/) command. + +### Example ```sh -$ BUILDS=release DISTROS=centos7 ./launch.sh -Logging to docker/logs/release/centos7.log -Waiting for release containers to finish; tail the logs for more information. - -$ docker images -REPOSITORY TAG IMAGE ID CREATED SIZE -microsoft/powershell centos7 f0a11a8009b7 20 minutes ago 438.3 MB -... +PS /powershell/docker> cd ./release/ubuntu16.04/ +PS /powershell/docker/release/ubuntu16.04> docker image build -t ps-ubuntu.16.04 . +Sending build context to Docker daemon 3.072 kB +Step 1/12 : FROM ubuntu:xenial + ---> 7b9b13f7b9c0 +Step 2/12 : LABEL maintainer "PowerShell Team " + ---> Using cache + ---> c6515b7d596f +Step 3/12 : LABEL readme.md "https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" + ---> Using cache + ---> 721306ae4490 +Step 4/12 : LABEL description "This Dockerfile will install the latest release of PS." + ---> Using cache + ---> 80c06f5481d2 +Step 5/12 : RUN apt-get update && apt-get install -y --no-install-recommends apt-utils ca-certificates curl apt-transport-https locales && rm -rf /var/lib/apt/lists/* + ---> Using cache + ---> 2d08e2300fc9 +Step 6/12 : ENV LANG en_US.UTF-8 + ---> Using cache + ---> 6dfc363111c0 +Step 7/12 : ENV LC_ALL $LANG + ---> Using cache + ---> b7ef2cd3a7ed +Step 8/12 : RUN locale-gen $LANG && update-locale + ---> Using cache + ---> e75306ddf3e0 +Step 9/12 : RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - + ---> Using cache + ---> f476b7be22a2 +Step 10/12 : RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | tee /etc/apt/sources.list.d/microsoft.list + ---> Using cache + ---> 909ca8e33a3b +Step 11/12 : RUN apt-get update && apt-get install -y --no-install-recommends powershell + ---> Using cache + ---> f32b54204619 +Step 12/12 : ENTRYPOINT powershell + ---> Using cache + ---> ee667ad86a7b +Successfully built ee667ad86a7b ``` -To generate an Ubuntu 16.04 package from andschwa's `docker` branch: +### Run the docker image you built ```sh -$ DISTROS=ubuntu16.04 FORK=andschwa BRANCH=docker ./launch.sh -Logging to docker/logs/release/ubuntu16.04.log -Waiting for release containers to finish; tail the logs for more information. -Logging to docker/logs/nightly/ubuntu16.04.log -Waiting for nightly containers to finish; tail the logs for more information. +PS /powershell/docker/release/ubuntu16.04> docker run -it ps-ubuntu.16.04 '$psversiontable' -$ ls packages -powershell_6.0.0-alpha.10-310-g5ded651-1ubuntu1.16.04.1_amd64.deb +Name Value +---- ----- +PSVersion 6.0.0-beta +PSEdition Core +BuildVersion 3.0.0.0 +CLRVersion +GitCommitId v6.0.0-beta.2 +OS Linux 4.9.27-moby #1 SMP Thu May 11 04:01:18 ... +Platform Unix +PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} +PSRemotingProtocolVersion 2.3 +SerializationVersion 1.1.0.1 +WSManStackVersion 3.0 -$ tail logs/nightly/ubuntu16.04.log -Step 5 : COPY bootstrap.ps1 / - ---> Using cache - ---> d18a28ff1e3d -Step 6 : RUN powershell -f bootstrap.ps1 && dpkg -i PowerShell/powershell*.deb - ---> Using cache - ---> 9cd8b1ef79b3 -Successfully built 9cd8b1ef79b3 -LOG: Saving package to docker/packages -~/src/PowerShell/docker ~/src/PowerShell/docker -'/PowerShell/powershell_6.0.0-alpha.10-310-g5ded651-1ubuntu1.16.04.1_amd64.deb' -> '/mnt/powershell_6.0.0-alpha.10-310-g5ded651-1ubuntu1.16.04.1_amd64.deb' -``` +``` \ No newline at end of file diff --git a/docker/launch.sh b/docker/launch.sh deleted file mode 100755 index 942ca5edf9..0000000000 --- a/docker/launch.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# This is borrowed from https://github.com/dotnet/cli/blob/18456af5caeae44defc23ad5579c838c1fda3c3d/run.sh -SOURCE="${BASH_SOURCE[0]}" -while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink - DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - SOURCE="$(readlink "$SOURCE")" - [[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located -done -DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - -# run from directory of launch.sh so artifacts are placed appropriately -pushd "$DIR" - -if [[ -z "$FORK" ]]; then - FORK=PowerShell -fi - -if [[ -z "$BRANCH" ]]; then - BRANCH=master -fi - -# Build both sets by default -if [[ -z "$BUILDS" ]]; then - BUILDS="release nightly" -fi - -# Build specified distributions -if [[ -z $DISTROS ]]; then - DISTROS="ubuntu14.04 ubuntu16.04 centos7" -fi - -for build in $BUILDS; do - # each distro can be done in parallel; but release must be done before nightly - for distro in $DISTROS; do - logfile="$distro.log" - if [[ "$TEST" -eq 1 ]]; then logfile="test-$logfile"; fi - mkdir -p "logs/$build" - logfile="logs/$build/$logfile" - echo "Logging to docker/$logfile" - - if [[ "$build" = release ]]; then - repo="microsoft/powershell" - else - repo="microsoft/powershell-nightly" - fi - - ( - image="$repo:$distro" - pushd "$build" - if [[ "$TEST" -eq 1 ]]; then - echo "LOG: testing $image" - command="cd PowerShell; Import-Module ./build.psm1; Install-Dotnet -NoSudo; Start-PSPester -powershell powershell -Pester ./src/Modules/Shared/Pester" - # clone repo for release images because it's not already done - if [[ "$build" = release ]]; then - command="git clone --recursive https://github.com/$FORK/PowerShell -b $BRANCH; $command" - fi - # run Pester tests inside container - # RUNARGS can be set in the environment - docker run $RUNARGS "$image" -c "$command" - else - echo "LOG: building $image" - # copy the common script because it lives outside the docker build context - if [[ "$build" = nightly ]]; then - cp bootstrap.ps1 "$distro" - buildargs="--build-arg fork=$FORK --build-arg branch=$BRANCH" - fi - # build and tag the image so they can be derived from - # BUILDARGS can be set in the environment - docker build $buildargs $BUILDARGS -t "$image" "$distro" - if [[ "$build" = nightly ]]; then - echo "LOG: Saving package to docker/packages" - popd - mkdir -p packages - command='cp -vf /PowerShell/powershell*{deb,rpm} /mnt 2> /dev/null' - # override entrypoint to be bash so we can use globbing - docker run --rm --volume "$(pwd)/packages:/mnt" --entrypoint bash "$image" -c "$command" - fi - fi - ) &>> "$logfile" & - done - echo "Waiting for $build containers to finish; tail the logs for more information." - wait -done - -popd diff --git a/docker/nightly/centos7/Dockerfile b/docker/nightly/centos7/Dockerfile deleted file mode 100644 index 99dda80682..0000000000 --- a/docker/nightly/centos7/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM microsoft/powershell:centos7 - -LABEL maintainer="PowerShell Team " -LABEL readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" -LABEL description="This Dockerfile will install the latest release of PS." - -ARG fork=PowerShell -ARG branch=master -SHELL ["powershell", "-command"] -RUN git clone --recursive https://github.com/$env:fork/PowerShell.git -b $env:branch; \ - Set-Location PowerShell; \ - Import-Module ./build.psm1; \ - Start-PSBootstrap -Package -NoSudo; \ - Start-PSBuild -Crossgen -PSModuleRestore; \ - Start-PSPackage; - -SHELL ["/bin/sh", "-c"] -RUN yum install -y PowerShell/powershell*.rpm \ No newline at end of file diff --git a/docker/nightly/fedora24/Dockerfile b/docker/nightly/fedora24/Dockerfile deleted file mode 100644 index d2b79f3bd7..0000000000 --- a/docker/nightly/fedora24/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM microsoft/powershell:fedora24 -LABEL maintainer="PowerShell Team " -LABEL readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" -LABEL description="This Dockerfile will install the latest release of PS." - -ARG fork=PowerShell -ARG branch=master -SHELL ["powershell", "-command"] -RUN git clone --recursive https://github.com/$env:fork/PowerShell.git -b $env:branch; \ - Set-Location PowerShell; \ - Import-Module ./build.psm1; \ - Start-PSBootstrap -Package -NoSudo; \ - Start-PSBuild -Crossgen -PSModuleRestore; \ - Start-PSPackage; - -SHELL ["/bin/sh", "-c"] -RUN dnf install -y PowerShell/powershell*.rpm diff --git a/docker/nightly/ubuntu14.04/Dockerfile b/docker/nightly/ubuntu14.04/Dockerfile deleted file mode 100644 index 4051a89e05..0000000000 --- a/docker/nightly/ubuntu14.04/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM microsoft/powershell:ubuntu14.04 -LABEL maintainer="PowerShell Team " -LABEL readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" -LABEL description="This Dockerfile will install the latest release of PS." - -ARG fork=PowerShell -ARG branch=master -SHELL ["powershell", "-command"] -RUN git clone --recursive https://github.com/$env:fork/PowerShell.git -b $env:branch; \ - Set-Location PowerShell; \ - Import-Module ./build.psm1; \ - Start-PSBootstrap -Package -NoSudo; \ - Start-PSBuild -Crossgen -PSModuleRestore; \ - Start-PSPackage; - -SHELL ["/bin/sh", "-c"] -RUN dpkg -i PowerShell/powershell*.deb diff --git a/docker/nightly/ubuntu16.04/Dockerfile b/docker/nightly/ubuntu16.04/Dockerfile deleted file mode 100644 index 4a4121c24a..0000000000 --- a/docker/nightly/ubuntu16.04/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM microsoft/powershell:ubuntu16.04 - -LABEL maintainer="PowerShell Team " -LABEL readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" -LABEL description="This Dockerfile will install the latest release of PS." - -ARG fork=PowerShell -ARG branch=master -SHELL ["powershell", "-command"] -RUN git clone --recursive https://github.com/$env:fork/PowerShell.git -b $env:branch; \ - Set-Location PowerShell; \ - Import-Module ./build.psm1; \ - Start-PSBootstrap -Package -NoSudo; \ - Start-PSBuild -Crossgen -PSModuleRestore; \ - Start-PSPackage; - -SHELL ["/bin/sh", "-c"] -RUN dpkg -i PowerShell/powershell*.deb diff --git a/test/common/markdown/markdown.tests.ps1 b/test/common/markdown/markdown.tests.ps1 index 7f221ff7e8..91f8181fc3 100644 --- a/test/common/markdown/markdown.tests.ps1 +++ b/test/common/markdown/markdown.tests.ps1 @@ -76,6 +76,7 @@ Describe 'Common Tests - Validate Markdown Files' -Tag 'CI' { './docs/*.md' './docs/installation/*.md' './demos/SSHRemoting/*.md' + './docker/*.md' ) $filter = ($docsToTest -join ',') &"gulp" test-mdsyntax --silent `