Skip to content
This repository has been archived by the owner on Jun 6, 2018. It is now read-only.

Docker best practice #89

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions images/alpine37/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM alpine:3.7
MAINTAINER Postman Labs <help@getpostman.com>

# Set node version
ENV NODE_VERSION 8.9.3

# Set newman version
ENV NEWMAN_VERSION 3.9.0

# Install node
RUN apk add --no-cache nodejs~=${NODE_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"]
38 changes: 38 additions & 0 deletions images/alpine37/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# newman_alpine37

This image runs newman 3.9.0 on node 8.9.3 on Alpine 3.7

Build the image:

```terminal
docker build -t postman/newman_alpine37 .
```

Or get it from [Docker Hub](https://registry.hub.docker.com/u/postman/newman_alpine37/):

```terminal
docker pull postman/newman_alpine37:3.9.0
```

Then run it:

```terminal
docker --volume="/home/postman/collections:/etc/newman" -t postman/newman_alpine37 --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_alpine37 --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_alpine37 --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_alpine37 --url="https://www.getpostman.com/collections/8a0c9bc08f062d12dcda"
```
30 changes: 12 additions & 18 deletions images/ubuntu1404/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
FROM ubuntu:14.04.2
FROM ubuntu:14.04
MAINTAINER Postman Labs <help@getpostman.com>

# Install curl and npm
RUN apt-get install -y curl;

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

# Set node version
ENV NODE_VERSION 8

# Set locale
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8

# Install node
RUN npm install -g n;
RUN n ${NODE_VERSION};

# Set newman version
ENV NEWMAN_VERSION 3.9.0

ADD https://deb.nodesource.com/setup_8.x /opt/setup_node.sh

# apt-transport-https, curl will be installed by `setup_node.sh`
RUN bash /opt/setup_node.sh \
&& apt-get install -y nodejs

# Install Node version management tool
RUN npm install -g n
RUN n ${NODE_VERSION}

# Install newman
RUN npm install -g newman@${NEWMAN_VERSION};
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
Expand Down
2 changes: 1 addition & 1 deletion images/ubuntu1404/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# newman_ubuntu1404

This image runs newman 3.9.0 on node 4.3.0 on Ubuntu 14.04.2
This image runs newman 3.9.0 on node 8.x on Ubuntu 14.04.x (latest)

Build the image,

Expand Down