Skip to content
Merged
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
24 changes: 16 additions & 8 deletions 14/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
FROM buildpack-deps:buster
FROM debian:trixie-slim

ENV NPM_CONFIG_LOGLEVEL=info
ENV NODE_VERSION=14.17.1

# gpg keys listed at https://github.com/nodejs/node
RUN set -ex \
&& apt-get update \
&& apt-get install -y ca-certificates curl gnupg dirmngr xz-utils --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
# use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150
&& export GNUPGHOME="$(mktemp -d)" \
&& for key in \
4ED778F539E3634C779C87C6D7062848A1AB005C \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
Expand All @@ -17,16 +25,16 @@ RUN set -ex \
; do \
{ gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" && gpg --batch --fingerprint "$key"; } || \
{ gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" && gpg --batch --fingerprint "$key"; } ; \
done

ENV NPM_CONFIG_LOGLEVEL=info
ENV NODE_VERSION=14.17.1

RUN curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \
done \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
&& gpgconf --kill all \
&& rm -rf "$GNUPGHOME" \
&& grep " node-v$NODE_VERSION-linux-x64.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 \
&& rm "node-v$NODE_VERSION-linux-x64.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt
&& rm "node-v$NODE_VERSION-linux-x64.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
&& node --version \
&& npm --version

CMD [ "node" ]
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# docker-image-testing-example

This is an exmaple of using Serverspec to test Dockerfiles
This is an example of using Serverspec to test Dockerfiles

## Setup

Expand All @@ -10,7 +10,7 @@ Install Serverspec and the require gems with bundler:
bundle install
```

This exmaple assumes you have Docker installed, running and configured.
This example assumes you have Docker installed, running and configured.

## Usage (running the tests)

Expand All @@ -20,22 +20,22 @@ bundle exec rake

The above will run Serverspec and using the docker-api gem it will

- Build a Docker image from the Docker file found in the top level dictrories (4.4 and 6.3)
- Build a Docker image from the Docker file found in the top level directories (4.4 and 6.3)
- Create a container of that image,
- Run the tests found in `spec/` on the container
- Delete the images and containers if the test was successful

The Dockerfiles are based on the offiial [docker-node](https://github.com/nodejs/docker-node) image.
The Dockerfiles are based on the official [docker-node](https://github.com/nodejs/docker-node) image.

You could also use the docker-api gem to pull exisiting images from the Docker hub and run tests against that image.
You could also use the docker-api gem to pull existing images from the Docker hub and run tests against that image.

So for instance, a pull_image helper could look something like this:

```ruby
def pull_image(image)

puts "Pulling image #{image}..."
@image = Docker::Image.create('fromImage' => imge)
@image = Docker::Image.create('fromImage' => image)

set :os, :family => 'debian'
set :backend, :docker
Expand Down