Skip to content

Commit

Permalink
feat: multi-platform Docker images
Browse files Browse the repository at this point in the history
# Why

More and more systems are running on the arm64 platform. For example,
AWS EC2 instances with Graviton2 processors or ARM-based MacBooks.
One of our customers is facing issues, because Newman does not run
on ARM-based systems. More specifically, the `postman/newman` Docker
image only supports the `linux/amd64` platform.

# What

This change enables the creation of `linux/amd64` and
`linux/arm64` Docker images.

The change also removes the Docker image definition for Ubuntu 14.04 and
Alpine 3.3. Both of these newman Docker images haven't been published in
two years and can therefore be removed.
  • Loading branch information
Ben Blackmore committed Oct 21, 2022
1 parent 5e0e9b7 commit dd65736
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 209 deletions.
48 changes: 0 additions & 48 deletions docker/images/alpine33/Dockerfile

This file was deleted.

39 changes: 0 additions & 39 deletions docker/images/alpine33/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion docker/images/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:18.04
LABEL maintainer="Postman Labs <help@postman.com>"

ARG NODE_VERSION=10
ARG NODE_VERSION=16
ARG NEWMAN_VERSION

# Bail out early if NODE_VERSION is not provided
Expand Down
40 changes: 0 additions & 40 deletions docker/images/ubuntu1404/Dockerfile

This file was deleted.

39 changes: 0 additions & 39 deletions docker/images/ubuntu1404/README.md

This file was deleted.

89 changes: 47 additions & 42 deletions npm/postpublish.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash

# Bail out on the first error
set -e;
set -eo pipefail;

LATEST="alpine";
BLUE="\033[0;34m";
Expand All @@ -17,62 +17,67 @@ GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD);
MAJOR=$(echo ${VERSION} | grep -oE "^\d+");
MINOR=$(echo ${VERSION} | grep -oE "^\d+\.\d+");

function build_docker_image {
local TAG=$(basename $1);
function validate_docker_image {
local OS="$(basename $1)"
local IMAGE_NAME="newman-test-$OS";

echo "";

echo -e "$BLUE Building $DOCKER_REPO:$VERSION-$TAG $NO_COLOUR";
echo -e "$BLUE Building Docker image (OS: $OS) for local image validation test $NO_COLOUR";

docker build \
--no-cache --force-rm --squash -t ${DOCKER_REPO}:${VERSION}-${TAG} \
--file="docker/images/$TAG/Dockerfile" --build-arg NEWMAN_VERSION=${VERSION} .;
--no-cache \
--force-rm \
-t $IMAGE_NAME \
--file="docker/images/$OS/Dockerfile" \
--build-arg NEWMAN_VERSION=${VERSION} \
.;

echo -e "$BLUE Running docker image test for $DOCKER_REPO:$VERSION-$TAG, latest $NO_COLOUR";
echo -e "$BLUE Running Docker image (OS: $OS) test $NO_COLOUR";

# Test
docker run -v ${PWD}/examples:/etc/newman -t ${DOCKER_REPO}:${VERSION}-${TAG} run "sample-collection.json";
docker run -v ${PWD}/examples:/etc/newman --rm -t $IMAGE_NAME run "sample-collection.json";

echo -e "$BLUE Removing Docker image (OS: $OS) from local Docker $NO_COLOUR";
docker rmi $IMAGE_NAME
}

function build_docker_image {
local OS="$(basename $1)"

echo -e "$BLUE Pushing docker image for $DOCKER_REPO:$VERSION-$TAG $NO_COLOUR";
local TAGS=""

echo "";

# Tag
if [[ ${GIT_BRANCH} == "master" ]]; then
if [[ ${TAG} == "ubuntu1404" || ${TAG} == "alpine33" ]]; then
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}_${TAG}:latest;
docker push ${DOCKER_REPO}_${TAG}:latest;
else
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}:${TAG};
docker push ${DOCKER_REPO}:${TAG};

if [[ ${TAG} == ${LATEST} ]]; then
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}:latest;
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}:${VERSION};
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}:${MINOR};
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}:${MAJOR};

docker push ${DOCKER_REPO}:latest;
docker push ${DOCKER_REPO}:${VERSION};
docker push ${DOCKER_REPO}:${MINOR};
docker push ${DOCKER_REPO}:${MAJOR};
fi
TAGS="$TAGS -t ${DOCKER_REPO}:${OS}"

if [[ ${OS} == ${LATEST} ]]; then
TAGS="$TAGS -t ${DOCKER_REPO}:latest";
TAGS="$TAGS -t ${DOCKER_REPO}:${VERSION}";
TAGS="$TAGS -t ${DOCKER_REPO}:${MINOR}";
TAGS="$TAGS -t ${DOCKER_REPO}:${MAJOR}";
fi
fi

if [[ ${TAG} == "ubuntu1404" || ${TAG} == "alpine33" ]]; then
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}_${TAG}:${VERSION};
docker push ${DOCKER_REPO}_${TAG}:${VERSION};
else
# Push
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}:${VERSION}-${TAG};
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}:${MINOR}-${TAG};
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}:${MAJOR}-${TAG};

docker push ${DOCKER_REPO}:${VERSION}-${TAG};
docker push ${DOCKER_REPO}:${MINOR}-${TAG};
docker push ${DOCKER_REPO}:${MAJOR}-${TAG};
fi
TAGS="$TAGS -t ${DOCKER_REPO}:${VERSION}-${OS}";
TAGS="$TAGS -t ${DOCKER_REPO}:${MINOR}-${OS}";
TAGS="$TAGS -t ${DOCKER_REPO}:${MAJOR}-${OS}";

echo -e "$BLUE Will now build and push multi-platform Docker image with tags $TAGS $NO_COLOUR";

docker buildx build \
--platform linux/amd64,linux/arm64 \
--no-cache \
--force-rm \
${TAGS} \
--file="docker/images/$OS/Dockerfile" \
--build-arg NEWMAN_VERSION=${VERSION} \
--push \
.;
}

for image in ${IMAGES_BASE_PATH}/*; do
validate_docker_image ${image};
build_docker_image ${image};
done

0 comments on commit dd65736

Please sign in to comment.