Skip to content

Commit dd65736

Browse files
author
Ben Blackmore
committed
feat: multi-platform Docker images
# 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.
1 parent 5e0e9b7 commit dd65736

File tree

6 files changed

+48
-209
lines changed

6 files changed

+48
-209
lines changed

docker/images/alpine33/Dockerfile

Lines changed: 0 additions & 48 deletions
This file was deleted.

docker/images/alpine33/README.md

Lines changed: 0 additions & 39 deletions
This file was deleted.

docker/images/ubuntu/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM ubuntu:18.04
22
LABEL maintainer="Postman Labs <[email protected]>"
33

4-
ARG NODE_VERSION=10
4+
ARG NODE_VERSION=16
55
ARG NEWMAN_VERSION
66

77
# Bail out early if NODE_VERSION is not provided

docker/images/ubuntu1404/Dockerfile

Lines changed: 0 additions & 40 deletions
This file was deleted.

docker/images/ubuntu1404/README.md

Lines changed: 0 additions & 39 deletions
This file was deleted.

npm/postpublish.sh

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
# Bail out on the first error
4-
set -e;
4+
set -eo pipefail;
55

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

20-
function build_docker_image {
21-
local TAG=$(basename $1);
20+
function validate_docker_image {
21+
local OS="$(basename $1)"
22+
local IMAGE_NAME="newman-test-$OS";
2223

2324
echo "";
2425

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

2728
docker build \
28-
--no-cache --force-rm --squash -t ${DOCKER_REPO}:${VERSION}-${TAG} \
29-
--file="docker/images/$TAG/Dockerfile" --build-arg NEWMAN_VERSION=${VERSION} .;
29+
--no-cache \
30+
--force-rm \
31+
-t $IMAGE_NAME \
32+
--file="docker/images/$OS/Dockerfile" \
33+
--build-arg NEWMAN_VERSION=${VERSION} \
34+
.;
3035

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

3338
# Test
34-
docker run -v ${PWD}/examples:/etc/newman -t ${DOCKER_REPO}:${VERSION}-${TAG} run "sample-collection.json";
39+
docker run -v ${PWD}/examples:/etc/newman --rm -t $IMAGE_NAME run "sample-collection.json";
40+
41+
echo -e "$BLUE Removing Docker image (OS: $OS) from local Docker $NO_COLOUR";
42+
docker rmi $IMAGE_NAME
43+
}
44+
45+
function build_docker_image {
46+
local OS="$(basename $1)"
3547

36-
echo -e "$BLUE Pushing docker image for $DOCKER_REPO:$VERSION-$TAG $NO_COLOUR";
48+
local TAGS=""
49+
50+
echo "";
3751

38-
# Tag
3952
if [[ ${GIT_BRANCH} == "master" ]]; then
40-
if [[ ${TAG} == "ubuntu1404" || ${TAG} == "alpine33" ]]; then
41-
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}_${TAG}:latest;
42-
docker push ${DOCKER_REPO}_${TAG}:latest;
43-
else
44-
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}:${TAG};
45-
docker push ${DOCKER_REPO}:${TAG};
46-
47-
if [[ ${TAG} == ${LATEST} ]]; then
48-
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}:latest;
49-
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}:${VERSION};
50-
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}:${MINOR};
51-
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}:${MAJOR};
52-
53-
docker push ${DOCKER_REPO}:latest;
54-
docker push ${DOCKER_REPO}:${VERSION};
55-
docker push ${DOCKER_REPO}:${MINOR};
56-
docker push ${DOCKER_REPO}:${MAJOR};
57-
fi
53+
TAGS="$TAGS -t ${DOCKER_REPO}:${OS}"
54+
55+
if [[ ${OS} == ${LATEST} ]]; then
56+
TAGS="$TAGS -t ${DOCKER_REPO}:latest";
57+
TAGS="$TAGS -t ${DOCKER_REPO}:${VERSION}";
58+
TAGS="$TAGS -t ${DOCKER_REPO}:${MINOR}";
59+
TAGS="$TAGS -t ${DOCKER_REPO}:${MAJOR}";
5860
fi
5961
fi
6062

61-
if [[ ${TAG} == "ubuntu1404" || ${TAG} == "alpine33" ]]; then
62-
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}_${TAG}:${VERSION};
63-
docker push ${DOCKER_REPO}_${TAG}:${VERSION};
64-
else
65-
# Push
66-
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}:${VERSION}-${TAG};
67-
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}:${MINOR}-${TAG};
68-
docker tag ${DOCKER_REPO}:${VERSION}-${TAG} ${DOCKER_REPO}:${MAJOR}-${TAG};
69-
70-
docker push ${DOCKER_REPO}:${VERSION}-${TAG};
71-
docker push ${DOCKER_REPO}:${MINOR}-${TAG};
72-
docker push ${DOCKER_REPO}:${MAJOR}-${TAG};
73-
fi
63+
TAGS="$TAGS -t ${DOCKER_REPO}:${VERSION}-${OS}";
64+
TAGS="$TAGS -t ${DOCKER_REPO}:${MINOR}-${OS}";
65+
TAGS="$TAGS -t ${DOCKER_REPO}:${MAJOR}-${OS}";
66+
67+
echo -e "$BLUE Will now build and push multi-platform Docker image with tags $TAGS $NO_COLOUR";
68+
69+
docker buildx build \
70+
--platform linux/amd64,linux/arm64 \
71+
--no-cache \
72+
--force-rm \
73+
${TAGS} \
74+
--file="docker/images/$OS/Dockerfile" \
75+
--build-arg NEWMAN_VERSION=${VERSION} \
76+
--push \
77+
.;
7478
}
7579

7680
for image in ${IMAGES_BASE_PATH}/*; do
81+
validate_docker_image ${image};
7782
build_docker_image ${image};
7883
done

0 commit comments

Comments
 (0)