diff --git a/docker/images/alpine33/Dockerfile b/docker/images/alpine33/Dockerfile deleted file mode 100644 index 328d0a198..000000000 --- a/docker/images/alpine33/Dockerfile +++ /dev/null @@ -1,48 +0,0 @@ -FROM alpine:3.3 -LABEL maintainer="Postman Labs " - -ARG NODE_VERSION=10 -ARG NEWMAN_VERSION - -# Set environment variables -ENV LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8" ALPINE_NODE_REPO="oznu/alpine-node" - -# Bail out early if NODE_VERSION is not provided -RUN if [ ! $(echo $NEWMAN_VERSION | grep -oE "^[0-9]+\.[0-9]+\.[0-9]+$") ]; then \ - echo "\033[0;31mA valid semver Newman version is required in the NEWMAN_VERSION build-arg\033[0m"; \ - exit 1; \ - fi && \ - # Add the latest Alpine Linux package to the repositories list - echo -e "https://nl.alpinelinux.org/alpine/v3.3/main/\nhttps://nl.alpinelinux.org/alpine/v3.3/community/" > /etc/apk/repositories && \ - # Update existing packages and install Node dependencies - apk add --update --no-cache libgcc libstdc++ jq curl && \ - # Determine the complete Semver Node version for the provided Node major version in $NODE_VERSION - FULL_NODE_VERSION=$(curl --silent "https://api.github.com/repos/${ALPINE_NODE_REPO}/releases" | jq -r '.[].tag_name' | grep -oE "^${NODE_VERSION}\.\d+\.\d+$" | sort -r -t. -k 1,1nr -k 2,2nr -k 3,3nr | head -n1) && \ - # Download the appropriate Node binary for Alpine Linux - curl --silent -L "https://github.com/${ALPINE_NODE_REPO}/releases/download/${FULL_NODE_VERSION}/node-v${FULL_NODE_VERSION}-linux-x86_64-alpine.tar.gz" > /etc/alpine-node-${NODE_VERSION}.tar.gz && \ - # Extract and install Node from the binary downloaded in the previous step - tar -xzf /etc/alpine-node-${NODE_VERSION}.tar.gz -C /usr --no-same-owner && \ - # Install Newman globally - npm install --global newman@${NEWMAN_VERSION} && \ - # Prune redundant packages - apk del jq curl && \ - # Clear Alpine Node binary - rm /etc/alpine-node-${NODE_VERSION}.tar.gz; - -# Set workdir to /etc/newman -# When running the image, mount the directory containing your collection to this location -# -# docker run -v :/etc/newman ... -# -# In case you mount your collections directory to a different location, you will need to give absolute paths to any -# collection, environment files you want to pass to newman, and if you want newman reports to be saved to your disk. -# Or you can change the workdir by using the -w or --workdir flag -WORKDIR /etc/newman - -# Set newman as the default container command -# Now you can run the container via -# -# docker run -v /home/collections:/etc/newman -t postman/newman_alpine33 run YourCollection.json.postman_collection \ -# -e YourEnvironment.postman_environment \ -# -H newman_report.html -ENTRYPOINT ["newman"] diff --git a/docker/images/alpine33/README.md b/docker/images/alpine33/README.md deleted file mode 100644 index 49ea4320d..000000000 --- a/docker/images/alpine33/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# newman_alpine33 (deprecated) -## Use postman/newman:alpine instead. See https://hub.docker.com/r/postman/newman/ for more available tags - -This image runs newman on node v8 on Alpine 3.3 - -Build the image: - -```terminal -docker build -t postman/newman_alpine33 --build-arg NEWMAN_VERSION="full semver version" . -``` - -Or get it from [Docker Hub](https://registry.hub.docker.com/u/postman/newman_alpine33/): - -```terminal -docker pull postman/newman_alpine33 -``` - -Then run it: - -```terminal -docker --volume="/home/postman/collections:/etc/newman" -t postman/newman_alpine33 run JSONBlobCoreAPI.json.postman_collection -r json --reporter-json-export newman-report.json -``` -For newman-docker to be able to use collections and environment files saved on the host machine, and to save reports generated by newman, a directory containing the collection and environment needs to be mounted on to the docker instance on run time, preferably at `/etc/newman`, which is the default working directory. If you mount to a different location, then: - - You can pass the full path to your collection and environment files to newman. For instance, if you mount to `/etc/newman`, - -```terminal -docker --volume="/home/postman/collection:/etc/newman" -t postman/newman_alpine33 run JSONBlobCoreAPI.json.postman_collection" -r json --reporter-json-export newman-report.json -``` - - You can change the working directory while running the image to the location you mounted to, using the `-w` or `--workdir` flag. - -```terminal -docker run --volume="/home/postman/collections:/etc/newman" -t postman/newman_alpine33 run JSONBlobCoreAPI.json.postman_collection -r json --reporter-json-export newman-report.json -``` - -In case you don't need to save newman's report to the host, and your collection is available online and does not require any environment, then you can forgo mounting your collections directory and directly pass the collection URL to newman: - -```terminal -docker run -t postman/newman_alpine33 run https://www.getpostman.com/collections/8a0c9bc08f062d12dcda -``` diff --git a/docker/images/ubuntu/Dockerfile b/docker/images/ubuntu/Dockerfile index 2136c44ba..5e1b9af1b 100644 --- a/docker/images/ubuntu/Dockerfile +++ b/docker/images/ubuntu/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:18.04 LABEL maintainer="Postman Labs " -ARG NODE_VERSION=10 +ARG NODE_VERSION=16 ARG NEWMAN_VERSION # Bail out early if NODE_VERSION is not provided diff --git a/docker/images/ubuntu1404/Dockerfile b/docker/images/ubuntu1404/Dockerfile deleted file mode 100644 index 4c6c32903..000000000 --- a/docker/images/ubuntu1404/Dockerfile +++ /dev/null @@ -1,40 +0,0 @@ -FROM ubuntu:14.04.2 -LABEL maintainer="Postman Labs " - -ARG NODE_VERSION=10 -ARG NEWMAN_VERSION - -# Bail out early if NODE_VERSION is not provided -RUN if [ ! $(echo $NEWMAN_VERSION | grep -oE "^[0-9]+\.[0-9]+\.[0-9]+$") ]; then \ - echo "\033[0;31mA valid semver Newman version is required in the NEWMAN_VERSION build-arg\033[0m"; \ - exit 1; \ - fi - -# Install node -ADD https://deb.nodesource.com/setup_$NODE_VERSION.x /opt/install_node.sh - -RUN bash /opt/install_node.sh && \ - apt-get install -y nodejs && \ - npm install -g newman@${NEWMAN_VERSION} && \ - rm /opt/install_node.sh; - -# Set environment variables -ENV LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8" - -# Set workdir to /etc/newman -# When running the image, mount the directory containing your collection to this location -# -# docker run -v :/etc/newman ... -# -# In case you mount your collections directory to a different location, you will need to give absolute paths to any -# collection, environment files you want to pass to newman, and if you want newman reports to be saved to your disk. -# Or you can change the workdir by using the -w or --workdir flag -WORKDIR /etc/newman - -# Set newman as the default container command -# Now you can run the container via -# -# docker run -v /home/collections:/etc/newman -t postman/newman_ubuntu1404 run YourCollection.json.postman_collection \ -# -e YourEnvironment.postman_environment \ -# -H newman_report.html -ENTRYPOINT ["newman"] diff --git a/docker/images/ubuntu1404/README.md b/docker/images/ubuntu1404/README.md deleted file mode 100644 index ac035b602..000000000 --- a/docker/images/ubuntu1404/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# newman_ubuntu1404 (deprecated) -## Use postman/newman:ubuntu instead. See https://hub.docker.com/r/postman/newman/ for more available tags - -This image runs newman on node v10 on Ubuntu 14.04.2 - -Build the image, - -```terminal -docker build -t postman/newman_ubuntu1404 --build-arg NEWMAN_VERSION="full semver version" . -``` - -Or get it from [docker hub](https://registry.hub.docker.com/u/postman/newman_ubuntu1404/) - -```terminal -docker pull postman/newman_ubuntu1404 -``` - -then run it - -```terminal -docker --volume="/home/postman/collections:/etc/newman" -t postman/newman_ubuntu1404 run JSONBlobCoreAPI.json.postman_collection -r json --reporter-json-export newman-report.json -``` -For newman-docker to be able to use collections and environment files saved on the host machine, and to save reports generated by newman, a directory containing the collection and environment needs to be mounted on to the docker instance on run time, preferably at `/etc/newman`, which is the default working directory. If you mount to a different location, then - - You can either pass the full path to your collection and environment files to newman. For instance, if you mount to `/etc/newman`, - -```terminal -docker --volume="/home/postman/collection:/etc/newman" -t postman/newman_ubuntu1404 run JSONBlobCoreAPI.json.postman_collection -r json --reporter-json-export newman-report.json -``` - - You can change the working directory while running the image to the location you mounted to, using the `-w` or `--workdir` flag. - -```terminal -docker run --volume="/home/postman/collections:/etc/newman" -t postman/newman_ubuntu1404 run JSONBlobCoreAPI.json.postman_collection -r json --reporter-json-export newman-report.json -``` - -In case you don't need to save newman's report to the host, and your collection is available online and it does not require any environment, then you can forgo mounting your collections directory, and directly pass the collection url to newman - -```terminal -docker run -t postman/newman_ubuntu1404 run https://www.getpostman.com/collections/8a0c9bc08f062d12dcda -``` diff --git a/npm/postpublish.sh b/npm/postpublish.sh index b01ff8d90..ba7aa853b 100755 --- a/npm/postpublish.sh +++ b/npm/postpublish.sh @@ -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"; @@ -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