From b0eed25d4ac7ab967e3eb4977c648b7682d654f8 Mon Sep 17 00:00:00 2001 From: Stefan Scherer Date: Wed, 1 Nov 2017 20:39:42 +0100 Subject: [PATCH 1/4] Use only 1 Dockerfile for Linux --- Dockerfile.arm64 => Dockerfile | 4 +++- Dockerfile.amd64 | 14 -------------- Dockerfile.arm | 14 -------------- travis-build.sh | 15 ++------------- travis-deploy.sh | 35 ++++++++++++---------------------- 5 files changed, 17 insertions(+), 65 deletions(-) rename Dockerfile.arm64 => Dockerfile (64%) delete mode 100644 Dockerfile.amd64 delete mode 100644 Dockerfile.arm diff --git a/Dockerfile.arm64 b/Dockerfile similarity index 64% rename from Dockerfile.arm64 rename to Dockerfile index ec981b5..e90e083 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile @@ -1,9 +1,11 @@ FROM golang AS build +ARG arch=amd64 + COPY . /code WORKDIR /code -RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -installsuffix cgo http.go +RUN CGO_ENABLED=0 GOOS=linux GOARCH=$arch go build -a -installsuffix cgo http.go FROM scratch diff --git a/Dockerfile.amd64 b/Dockerfile.amd64 deleted file mode 100644 index 086ac9e..0000000 --- a/Dockerfile.amd64 +++ /dev/null @@ -1,14 +0,0 @@ -FROM golang AS build - -COPY . /code -WORKDIR /code - -RUN CGO_ENABLED=0 go build -a -installsuffix cgo http.go - -FROM scratch - -COPY --from=build /code/http /http - -EXPOSE 8080 - -CMD ["/http"] diff --git a/Dockerfile.arm b/Dockerfile.arm deleted file mode 100644 index 87d76e0..0000000 --- a/Dockerfile.arm +++ /dev/null @@ -1,14 +0,0 @@ -FROM golang AS build - -COPY . /code -WORKDIR /code - -RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -a -installsuffix cgo http.go - -FROM scratch - -COPY --from=build /code/http /http - -EXPOSE 8080 - -CMD ["/http"] diff --git a/travis-build.sh b/travis-build.sh index 178164f..75a03c2 100755 --- a/travis-build.sh +++ b/travis-build.sh @@ -3,25 +3,14 @@ set -e docker version uname -a -echo "Updating Docker engine to 17.05.0" +echo "Updating Docker engine to have multi-stage builds" sudo service docker stop curl -fsSL https://get.docker.com/ | sudo sh docker version -if [ "$ARCH" != "amd64" ]; then - # prepare qemu - docker run --rm --privileged multiarch/qemu-user-static:register --reset - - if [ "$ARCH" == "arm64" ]; then - # prepare qemu binary - docker create --name register hypriot/qemu-register - docker cp register:qemu-aarch64 qemu-aarch64-static - fi -fi - if [ -d tmp ]; then docker rm build rm -rf tmp fi -docker build -t whoami -f "Dockerfile.$ARCH" . +docker build -t whoami --build-arg "arch=$ARCH" . diff --git a/travis-deploy.sh b/travis-deploy.sh index 712c143..b460581 100755 --- a/travis-deploy.sh +++ b/travis-deploy.sh @@ -23,22 +23,28 @@ if [ "$ARCH" == "amd64" ]; then sleep 15 echo "Try again" done + until docker run --rm stefanscherer/winspector "$image:windows-amd64-$TRAVIS_TAG-1709" + do + sleep 15 + echo "Try again" + done set -e echo "Downloading docker client with manifest command" - wget https://5028-88013053-gh.circle-artifacts.com/1/work/build/docker-linux-amd64 + wget https://6582-88013053-gh.circle-artifacts.com/1/work/build/docker-linux-amd64 mv docker-linux-amd64 docker chmod +x docker ./docker version - + set -x - + echo "Pushing manifest $image:$TRAVIS_TAG" ./docker -D manifest create "$image:$TRAVIS_TAG" \ "$image:linux-amd64-$TRAVIS_TAG" \ "$image:linux-arm-$TRAVIS_TAG" \ "$image:linux-arm64-$TRAVIS_TAG" \ - "$image:windows-amd64-$TRAVIS_TAG" + "$image:windows-amd64-$TRAVIS_TAG" \ + "$image:windows-amd64-$TRAVIS_TAG-1709" ./docker manifest annotate "$image:$TRAVIS_TAG" "$image:linux-arm-$TRAVIS_TAG" --os linux --arch arm ./docker manifest annotate "$image:$TRAVIS_TAG" "$image:linux-arm64-$TRAVIS_TAG" --os linux --arch arm64 ./docker manifest push "$image:$TRAVIS_TAG" @@ -48,26 +54,9 @@ if [ "$ARCH" == "amd64" ]; then "$image:linux-amd64-$TRAVIS_TAG" \ "$image:linux-arm-$TRAVIS_TAG" \ "$image:linux-arm64-$TRAVIS_TAG" \ - "$image:windows-amd64-$TRAVIS_TAG" + "$image:windows-amd64-$TRAVIS_TAG" \ + "$image:windows-amd64-$TRAVIS_TAG-1709" ./docker manifest annotate "$image:latest" "$image:linux-arm-$TRAVIS_TAG" --os linux --arch arm ./docker manifest annotate "$image:latest" "$image:linux-arm64-$TRAVIS_TAG" --os linux --arch arm64 ./docker manifest push "$image:latest" - - echo "Downloading manifest-tool" - wget https://github.com/estesp/manifest-tool/releases/download/v0.6.0/manifest-tool-linux-amd64 - mv manifest-tool-linux-amd64 manifest-tool - chmod +x manifest-tool - ./manifest-tool - - echo "Pushing manifest $image:$TRAVIS_TAG" - ./manifest-tool push from-args \ - --platforms linux/amd64,linux/arm,linux/arm64,windows/amd64 \ - --template "$image:OS-ARCH-$TRAVIS_TAG" \ - --target "$image:$TRAVIS_TAG-manifest-tool" - - echo "Pushing manifest $image:latest" - ./manifest-tool push from-args \ - --platforms linux/amd64,linux/arm,linux/arm64,windows/amd64 \ - --template "$image:OS-ARCH-$TRAVIS_TAG" \ - --target "$image:latest-manifest-tool" fi From c8f46f90d6d9d1f2d0075db67b19f7810dce1136 Mon Sep 17 00:00:00 2001 From: Stefan Scherer Date: Wed, 1 Nov 2017 20:40:03 +0100 Subject: [PATCH 2/4] Use only 1 Dockerfile for Windows --- Dockerfile.windows | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile.windows b/Dockerfile.windows index 3c99f53..cf1e7fe 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -1,11 +1,14 @@ -FROM golang:nanoserver AS build +ARG golang=golang:nanoserver +ARG target=microsoft/nanoserver + +FROM $golang AS build COPY . /code WORKDIR /code RUN go build http.go -FROM microsoft/nanoserver +FROM $target COPY --from=build /code/http.exe /http.exe From 61246a50f702743ad2d259c2e83c88e91b8e20de Mon Sep 17 00:00:00 2001 From: Stefan Scherer Date: Wed, 1 Nov 2017 20:40:14 +0100 Subject: [PATCH 3/4] Rebase image to 1709 --- appveyor-build.ps1 | 5 +---- appveyor-deploy.ps1 | 7 +++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/appveyor-build.ps1 b/appveyor-build.ps1 index 0f15874..f0e6143 100644 --- a/appveyor-build.ps1 +++ b/appveyor-build.ps1 @@ -2,9 +2,6 @@ $ErrorActionPreference = 'Stop'; $files = "" Write-Host Starting build -Write-Host Updating base images -docker pull microsoft/nanoserver - -docker build -t whoami -f Dockerfile.windows . +docker build --pull -t whoami -f Dockerfile.windows . docker images diff --git a/appveyor-deploy.ps1 b/appveyor-deploy.ps1 index 0bead66..9a99c70 100644 --- a/appveyor-deploy.ps1 +++ b/appveyor-deploy.ps1 @@ -11,3 +11,10 @@ docker login -u="$env:DOCKER_USER" -p="$env:DOCKER_PASS" docker tag whoami stefanscherer/whoami:windows-amd64-$env:APPVEYOR_REPO_TAG_NAME docker push stefanscherer/whoami:windows-amd64-$env:APPVEYOR_REPO_TAG_NAME + +Write-Host Rebasing image to produce 1709 variant +npm install -g rebase-docker-image +rebase-docker-image ` + stefanscherer/whoami:windows-amd64-$env:APPVEYOR_REPO_TAG_NAME ` + -t stefanscherer/whoami:windows-amd64-$env:APPVEYOR_REPO_TAG_NAME-1709 ` + -b microsoft/nanoserver:1709 From a8373b57b133cacb311e225da1e18e3eb2403f60 Mon Sep 17 00:00:00 2001 From: Stefan Scherer Date: Wed, 1 Nov 2017 20:40:30 +0100 Subject: [PATCH 4/4] Use only 1 Dockerfile for Windows --- Dockerfile.1709 | 14 -------------- Dockerfile.insider | 14 -------------- 2 files changed, 28 deletions(-) delete mode 100644 Dockerfile.1709 delete mode 100644 Dockerfile.insider diff --git a/Dockerfile.1709 b/Dockerfile.1709 deleted file mode 100644 index 91e1c85..0000000 --- a/Dockerfile.1709 +++ /dev/null @@ -1,14 +0,0 @@ -FROM stefanscherer/golang-windows:1709 AS build - -COPY . /code -WORKDIR /code - -RUN go build http.go - -FROM microsoft/nanoserver:1709 - -COPY --from=build /code/http.exe /http.exe - -EXPOSE 8080 - -CMD ["\\http.exe"] diff --git a/Dockerfile.insider b/Dockerfile.insider deleted file mode 100644 index 275a250..0000000 --- a/Dockerfile.insider +++ /dev/null @@ -1,14 +0,0 @@ -FROM stefanscherer/golang-windows:1.9-insider AS build - -COPY . /code -WORKDIR /code - -RUN go build http.go - -FROM microsoft/nanoserver-insider - -COPY --from=build /code/http.exe /http.exe - -EXPOSE 8080 - -CMD ["\\http.exe"]