-
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
Added Docker push postpublish script #1397
Conversation
… alpine33. Also updated the docker files to install the root newman directory as a nodejs module which would be used by the docker image
… is sent to the docker daemon
… and pushes the image on docker hub
…ript once the build is successful
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.
@rishivikram Ensure that all applicable statements are terminated with a semicolon.
docker/images/ubuntu1404/README.md
Outdated
@@ -0,0 +1,38 @@ | |||
# newman_ubuntu1404 | |||
|
|||
This image runs newman 3.9.0 on node 4.3.0 on Ubuntu 14.04.2 |
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.
Remove the Newman version from this statement, mention the Node version as 8.
docker/images/ubuntu1404/README.md
Outdated
Or get it from [docker hub](https://registry.hub.docker.com/u/postman/newman_ubuntu1404/) | ||
|
||
```terminal | ||
docker pull postman/newman_ubuntu1404:3.9.0 |
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.
Same as above.
docker/scripts/run.sh
Outdated
fi | ||
} | ||
|
||
NODE_V=$(node -v | grep -o "v.") |
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.
Travis provides an inbuilt environment variable for this, use that instead.
docker/scripts/run.sh
Outdated
NODE_V=$(node -v | grep -o "v.") | ||
|
||
IMAGES_BASE_PATH="./docker/images" | ||
if [ -n "$TRAVIS_TAG" ] && [ "$NODE_V" = "v8" ]; then |
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.
This will cause unstable tags to be built as well.
docker/scripts/run.sh
Outdated
docker build -t "$DOCKER_ID_USER/$IMAGE_NAME:$TRAVIS_TAG" . | ||
if docker images | grep -q "$DOCKER_ID_USER/$IMAGE_NAME"; then | ||
echo "Image built" | ||
if docker run -t "$DOCKER_ID_USER/$IMAGE_NAME:$TRAVIS_TAG" run "https://www.getpostman.com/collections/8a0c9bc08f062d12dcda"; then |
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.
This will fail if the link ever dies, use a local collection file instead.
docker/scripts/run.sh
Outdated
if docker run -t "$DOCKER_ID_USER/$IMAGE_NAME:$TRAVIS_TAG" run "https://www.getpostman.com/collections/8a0c9bc08f062d12dcda"; then | ||
echo "Collection run successfully" | ||
docker login -u "$DOCKER_ID_USER" -p "$DOCKER_ID_PASSWORD" | ||
docker push "$DOCKER_ID_USER/$IMAGE_NAME:$TRAVIS_TAG" |
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.
This needs the latest
tag as well.
docker/scripts/run.sh
Outdated
function build_docker_image { | ||
BASENAME=$(basename $1) | ||
IMAGE_NAME="newman_$BASENAME" | ||
docker build -t "$DOCKER_ID_USER/$IMAGE_NAME:$TRAVIS_TAG" . |
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.
Indentation is off.
docker/scripts/run.sh
Outdated
echo "Collection not run successfully" | ||
fi | ||
else | ||
echo "Image not built" |
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.
Also include the image basename in the message.
docker/images/alpine33/Dockerfile
Outdated
MAINTAINER Postman Labs <help@getpostman.com> | ||
|
||
# Set node version | ||
# Can't upgrade to nodev8 because it isn't supported in alpine 3.3 |
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.
👍
docker/images/alpine33/README.md
Outdated
@@ -0,0 +1,38 @@ | |||
# newman_alpine33 | |||
|
|||
This image runs newman 3.9.0 on node 4.3.0 on Alpine 3.3 |
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.
Remove the Newman version, update the Node version to v4.3.2
…nly docker images for stable TRAVIS_TAGS will be built
docker/scripts/run.sh
Outdated
BASENAME=$(basename $1); | ||
IMAGE_NAME="newman_$BASENAME"; | ||
TAG="$2"; | ||
docker build -t "$DOCKER_ID_USER/$IMAGE_NAME:$TAG" . |
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.
You'll have to add the latest tag here (-t can accept multiple space separated name:value parameters). See https://github.com/postmanlabs/newman-docker/blob/develop/scripts/docker/docker-build.sh#L13 for a working example.
docker/scripts/run.sh
Outdated
if [ -d "${image}" ] && [ -f "${image}/Dockerfile" ]; then | ||
cp "${image}/Dockerfile" . | ||
build_docker_image ${image} ${TRAVIS_TAG}; | ||
build_docker_image ${image} "latest"; |
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.
You don't have to build two separate images, supply multiple tags as explained above. 😓
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.
Sorry, will correct it right away.
docker/scripts/run.sh
Outdated
docker build -t "$DOCKER_ID_USER/$IMAGE_NAME:$TAG" . | ||
if docker images | grep -q "$DOCKER_ID_USER/$IMAGE_NAME"; then | ||
echo "Image built" | ||
if docker run -t "$DOCKER_ID_USER/$IMAGE_NAME:$TAG" run "sample-collection.json"; then |
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.
Don't you have to specify the complete path, as in examples/sample-collection.json
?
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.
In this case, I already mounted the whole examples
directory in etc/newman
, so no need. The collection runs correctly.
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.
I did the mounting work in the dockerfile.
docker/scripts/run.sh
Outdated
EXTRACTED_TAG=$(echo $TRAVIS_TAG | grep -o "[0-9]\+.[0-9]\+.[0-9]\+") | ||
if [ -n "$TRAVIS_TAG" ] && [ "$TRAVIS_TAG" = "$EXTRACTED_TAG" ] && [ "$TRAVIS_NODE_VERSION" = "8" ]; then | ||
for image in $IMAGES_BASE_PATH/*; do | ||
if [ -d "${image}" ] && [ -f "${image}/Dockerfile" ]; then |
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.
The -d
conditional check is redundant here.
docker/images/alpine33/Dockerfile
Outdated
|
||
ADD . /newman | ||
|
||
RUN ln -s /newman/examples /etc/newman |
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.
Avoid creating symlinks here, use the complete path in collection run tests in the build script.
docker/images/ubuntu1404/Dockerfile
Outdated
|
||
ADD . /newman | ||
|
||
RUN ln -s /newman/examples /etc/newman |
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.
Same as above.
… is taken from package.json after it has been released
…n package.json can recognize it
…ctly now and doesn't throw a GPG public key error
…t in the npm folder
test/system/repository.test.js
Outdated
}); | ||
}); | ||
|
||
it('must have the hashbang defined', function () { | ||
json.scripts && Object.keys(json.scripts).forEach(function (scriptName) { | ||
var fileContent = fs.readFileSync('npm/' + scriptName + '.js').toString(); | ||
expect(/^#!\/(bin\/bash|usr\/bin\/env\snode)[\r\n][\W\w]*$/g.test(fileContent)).to.be.ok(); | ||
fs.readFile('npm/' + scriptName + '.js', function (err, fileContent) { |
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.
No. Check if the file is a shell script or js file using fs.stat first, and then perform extension specific checks.
test/system/repository.test.js
Outdated
var scriptRegex = /^node\snpm\/.+\.js$/; | ||
|
||
var scriptRegexJS = /^node\snpm\/.+\.js$/, | ||
scriptRegexSH = /^\.\/npm\/.+\.sh$/; |
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.
Have one cumulative regex testing both patterns.
docker/images/ubuntu1404/Dockerfile
Outdated
RUN npm install -g n; | ||
RUN n ${NODE_VERSION}; | ||
|
||
ARG newman_version=default_value |
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.
?
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.
It needs a default value which would be used if $newman_version is not sent as a variable in the docker build command.
docker/images/alpine33/Dockerfile
Outdated
# Install node | ||
RUN apk add --update nodejs=${NODE_VERSION}-r1; | ||
|
||
ARG newman_version=default_value |
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.
?
…thub.com:rishivikram/newman into feature/automate-newman-dockerimage-version-bump Pulled latest code from github.
…ted the DOCKER_ID_USER and DOCKER_ID_PASSWORD environment variables to DOCKER_USER and DOCKER_PASSWORD respectively
Looking for updated Docker images and this might be the shortest path there. Is this going to continue through the review process? Perhaps we can get updated images created manually if this isn't going to get merged anytime soon? |
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.
@rishivikram FYI,
maybe you would like to see my PR at another repository:
docker/images/ubuntu1404/Dockerfile
Outdated
|
||
RUN apt-get install -y curl; | ||
|
||
RUN curl -sS https://deb.nodesource.com/setup_8.x | sudo -E bash - |
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.
no need to install curl
, it could be replaced by Docker build-in ADD
feature
FYI, https://github.com/postmanlabs/newman-docker/pull/89/files#diff-df82f574da54a99527d80ff59fdf5388R10
@@ -0,0 +1,49 @@ | |||
FROM ubuntu:14.04.2 |
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
docker/images/ubuntu1404/Dockerfile
Outdated
|
||
RUN curl -sS https://deb.nodesource.com/setup_8.x | sudo -E bash - | ||
|
||
RUN apt-get clean && apt-get upgrade -y && apt-get update -y --fix-missing && apt-get install -y nodejs |
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.
should avoid upgrade
inside docker, use FROM ubuntu:14.04
instead
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 comment
The reason will be displayed to describe this comment to others. Learn more.
please update the path on the Docker Hub
* Added alpine linux repository reference for correct dependency installation * Compacted multiple ENV statements * Added validation for build-args
* Switched to installing Node from the debian nodesource repository * Compacted multiple ENV statements * Added validation for build-args
* Added validation, coloured output * Added steps to autopublish the built images * Updated docker build command to work without caching, remove intermediate image layers
deprecation !why? |
@liyinchigithub This has now been replaced with https://hub.docker.com/r/postman/newman, which has all tags under one unified repository. |
I see, thank you |
No description provided.