Use only 1 Dockerfile for Linux

pull/3/head
Stefan Scherer 7 years ago
parent 6e8bb6cb17
commit b0eed25d4a
No known key found for this signature in database
GPG Key ID: 5966AEAC37E957FA

@ -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

@ -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"]

@ -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"]

@ -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" .

@ -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

Loading…
Cancel
Save