-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Docker push postpublish script #1397
Merged
kunagpal
merged 23 commits into
postmanlabs:develop
from
rishivikram:feature/automate-newman-dockerimage-version-bump
May 8, 2018
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
9617f0c
Added docker folder that contains the docker files for ubuntu1404 and…
rishivikram 1c4f156
Added .dockerignore file so that not everything (like nodejs modules)…
rishivikram e6d1d1f
Added the main script that runs after successful tag build on newman,…
rishivikram 6965ca9
Added after_success routine to trigger the ./docker/scripts/run.sh sc…
rishivikram 7556c24
Removed unnecessary echo statements
rishivikram 6de27b5
Updated Dockerfile so that local collections can run now
rishivikram 316a4b3
Used travis environment variables to determine the node version and o…
rishivikram 28b3a39
Updated docker build command to include the latest tag
rishivikram fadfdb8
Removed after success routine from .travis.yml and added postpublish …
rishivikram d714412
Updated dockerfiles and script so that newman version to be installed…
rishivikram 7378d20
Renamed the run.sh script and moved it to npm folder so that script i…
rishivikram 46b9c79
Added options to apt-get update so that the docker image builds corre…
rishivikram ffb0902
Updated repository.test.js to account for .sh files also being presen…
rishivikram 74f29bf
Merge branch 'develop' into feature/automate-newman-dockerimage-versi…
kunagpal 74a7862
Made the code in system tests a little cleaner
rishivikram 213a7c6
Merge branch 'feature/automate-newman-dockerimage-version-bump' of gi…
rishivikram c7747b6
Updated the dockerfile to not use a fallback default value. Also upda…
rishivikram 806474d
Merge branch 'develop' into feature/automate-newman-dockerimage-versi…
shamasis 099b659
Updated Newman alpine 3.3 Dockerfile for automated postpublish
kunagpal 10b4b15
Updated Newman alpine 3.3 Dockerfile for automated postpublish
kunagpal da2e1ec
Cleaned up postpublish script :art:
kunagpal 9a45abe
Merge branch 'develop' into feature/automate-newman-dockerimage-versi…
kunagpal fd73890
Fixed broken system tests :white_check_mark:
kunagpal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# PLATFORM | ||
# ======== | ||
# All exclusions that are specific to the NPM, GIT, IDE and Operating Systems. | ||
|
||
# - Do not allow installed node modules to be committed. Doing `npm install -d` will bring them in root or other places. | ||
node_modules | ||
|
||
# - Do not commit any log file from anywhere | ||
*.log | ||
*.log.* | ||
|
||
# - Prevent addition of OS specific file explorer files | ||
Thumbs.db | ||
.DS_Store | ||
|
||
# Prevent IDE stuff | ||
.idea | ||
.vscode | ||
|
||
# PROJECT | ||
# ======= | ||
# Configuration pertaining to project specific repository structure. | ||
|
||
# - Prevent Sublime text IDE files from being commited to repository | ||
*.sublime-* | ||
|
||
# - Allow sublime text project file to be commited in the development directory. | ||
!/develop/*.sublime-project | ||
|
||
# - Prevent CI output files from being Added | ||
/out/ | ||
/newman/ | ||
|
||
# - Prevent diff backups from SourceTree from showing as commit. | ||
*.BACKUP.* | ||
*.BASE.* | ||
*.LOCAL.* | ||
*.REMOTE.* | ||
*.orig | ||
|
||
# Prevent unit test coverage reports from being added | ||
.coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
FROM alpine:3.3 | ||
MAINTAINER Postman Labs <help@getpostman.com> | ||
|
||
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 | ||
|
||
# Can't upgrade to node v8 because it isn't supported in alpine 3.3 | ||
ENV NODE_VERSION 4.3.2 | ||
|
||
# Install node | ||
RUN echo -e "http://nl.alpinelinux.org/alpine/v3.3/main\nhttp://nl.alpinelinux.org/alpine/v3.3/community" > /etc/apk/repositories && \ | ||
apk add --update nodejs=${NODE_VERSION}-r1; | ||
|
||
# Set environment variables | ||
ENV LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8" NEWMAN_VERSION=$newman_version | ||
|
||
# Install newman | ||
RUN npm install -g newman@${NEWMAN_VERSION}; | ||
|
||
# Set workdir to /etc/newman | ||
# When running the image, mount the directory containing your collection to this location | ||
# | ||
# docker run -v <path to collections directory>:/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 -c YourCollection.json.postman_collection \ | ||
# -e YourEnvironment.postman_environment \ | ||
# -H newman_report.html | ||
ENTRYPOINT ["newman"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# newman_alpine33 | ||
|
||
This image runs newman on node 4.3.2 on Alpine 3.3 | ||
|
||
Build the image: | ||
|
||
```terminal | ||
docker build -t postman/newman_alpine33 . | ||
``` | ||
|
||
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 --collection="JSONBlobCoreAPI.json.postman_collection" --html="newman-report.html" | ||
``` | ||
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 `/var/newman`, | ||
|
||
```terminal | ||
docker --volume="/home/postman/collection:/var/newman" -t postman/newman_alpine33 --collection="/var/newman/JSONBlobCoreAPI.json.postman_collection" --html="/var/newman/newman-report.html" | ||
``` | ||
- 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:/var/newman" --workdir="/var/newman" -t postman/newman_alpine33 --collection="JSONBlobCoreAPI.json.postman_collection" --html="newman-report.html" | ||
``` | ||
|
||
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 --url="https://www.getpostman.com/collections/8a0c9bc08f062d12dcda" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
FROM ubuntu:14.04.2 | ||
MAINTAINER Postman Labs <help@getpostman.com> | ||
|
||
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 | ||
|
||
# Set node version | ||
ENV NODE_VERSION 8 | ||
|
||
# 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 | ||
|
||
# Set environment variables | ||
ENV LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8" NEWMAN_VERSION=$newman_version | ||
|
||
# Install newman | ||
RUN npm install -g newman@${NEWMAN_VERSION}; | ||
|
||
# Set workdir to /etc/newman | ||
# When running the image, mount the directory containing your collection to this location | ||
# | ||
# docker run -v <path to collections directory>:/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 -c YourCollection.json.postman_collection \ | ||
# -e YourEnvironment.postman_environment \ | ||
# -H newman_report.html | ||
ENTRYPOINT ["newman"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# newman_ubuntu1404 | ||
|
||
This image runs newman on node v8 on Ubuntu 14.04.2 | ||
|
||
Build the image, | ||
|
||
```terminal | ||
docker build -t postman/newman_ubuntu1404 . | ||
``` | ||
|
||
Or get it from [docker hub](https://registry.hub.docker.com/u/postman/newman_ubuntu1404/) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please update the path on the Docker Hub |
||
|
||
```terminal | ||
docker pull postman/newman_ubuntu1404 | ||
``` | ||
|
||
then run it | ||
|
||
```terminal | ||
docker --volume="/home/postman/collections:/etc/newman" -t postman/newman_ubuntu1404 --collection="JSONBlobCoreAPI.json.postman_collection" --html="newman-report.html" | ||
``` | ||
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 `/var/newman`, | ||
|
||
```terminal | ||
docker --volume="/home/postman/collection:/var/newman" -t postman/newman_ubuntu1404 --collection="/var/newman/JSONBlobCoreAPI.json.postman_collection" --html="/var/newman/newman-report.html" | ||
``` | ||
- 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:/var/newman" --workdir="/var/newman" -t postman/newman_ubuntu1404 --collection="JSONBlobCoreAPI.json.postman_collection" --html="newman-report.html" | ||
``` | ||
|
||
In case you don't need to save newmans 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 --url="https://www.getpostman.com/collections/8a0c9bc08f062d12dcda" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# Bail out on the first error | ||
set -e; | ||
|
||
BLUE='\033[0;34m'; | ||
NO_COLOUR='\033[0m'; | ||
DOCKER_USER="postman"; | ||
TAG=$npm_package_version; | ||
IMAGES_BASE_PATH="./docker/images"; | ||
|
||
# It's good to be paranoid | ||
[[ -z "$TAG" ]] && TAG=$(jq -r ".version" < package.json); | ||
|
||
function build_docker_image { | ||
local TAG="$2"; | ||
local BASENAME=$(basename $1); | ||
local IMAGE_NAME="newman_$BASENAME"; | ||
|
||
echo ""; | ||
echo -e "$BLUE Building docker image for $DOCKER_USER/$IMAGE_NAME:$TAG, latest $NO_COLOUR"; | ||
docker build \ | ||
-t "$DOCKER_USER/$IMAGE_NAME:$TAG" -t "$DOCKER_USER/$IMAGE_NAME:latest" \ | ||
--no-cache --force-rm --file="docker/images/$BASENAME/Dockerfile" --build-arg newman_version="$TAG" .; | ||
|
||
echo -e "$BLUE Running docker image test for $DOCKER_USER/$IMAGE_NAME:$TAG, latest $NO_COLOUR"; | ||
docker run -v "$PWD/examples:/etc/newman" -t "$DOCKER_USER/$IMAGE_NAME:$TAG" run "sample-collection.json"; | ||
|
||
# prepare current images for pushing | ||
docker tag $DOCKER_USER/$IMAGE_NAME:$TAG $DOCKER_USER/$IMAGE_NAME:$TAG; | ||
docker tag $DOCKER_USER/$IMAGE_NAME:latest $DOCKER_USER/$IMAGE_NAME:latest; | ||
|
||
echo -e "$BLUE Pushing docker image for $DOCKER_USER/$IMAGE_NAME:$TAG, latest $NO_COLOUR"; | ||
docker push $DOCKER_USER/$IMAGE_NAME:$TAG; | ||
docker push $DOCKER_USER/$IMAGE_NAME:latest; | ||
} | ||
|
||
for image in $IMAGES_BASE_PATH/*; do | ||
build_docker_image ${image} ${TAG}; | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to use
ubuntu:14.04
to keep track on upstream changes