Skip to content

Commit

Permalink
Add dockerfile support
Browse files Browse the repository at this point in the history
Add the ability to pass custom dockerfile as a config parameter
  • Loading branch information
grubernaut committed Jan 26, 2015
1 parent 62e68d1 commit f63fb2b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# <a name="title"></a> Kitchen::DockerCli [![Gem Version](https://badge.fury.io/rb/kitchen-docker_cli.svg)](http://badge.fury.io/rb/kitchen-docker_cli) [![Build Status](https://travis-ci.org/marcy-terui/kitchen-docker_cli.svg?branch=master)](https://travis-ci.org/marcy-terui/kitchen-docker_cli) [![Coverage Status](https://coveralls.io/repos/marcy-terui/kitchen-docker_cli/badge.png)](https://coveralls.io/r/marcy-terui/kitchen-docker_cli)
A Test Kitchen Driver for Docker command line interface.

This plugin is created with only Docker CLI functions.
This plugin is created with only Docker CLI functions.
Therefore, we can test with an environment that has no extra software such as ```sshd```.

## <a name="requirements"></a> Requirements

- Test-Kitchen (>= 1.3)

- Docker (>= 1.3)
- Docker (>= 1.3)
This driver uses ```docker exec``` command.

- tar (GNU Tar)
- tar (GNU Tar)

## <a name="installation"></a> Installation and Setup

Expand Down Expand Up @@ -156,7 +156,7 @@ Examples:

### publish_all

Publish all exposed ports to the host interfaces.
Publish all exposed ports to the host interfaces.
This option used to communicate between some containers.

The default value is `false`.
Expand All @@ -183,6 +183,19 @@ Examples:
- <%= Dir::pwd %>:/var:rw
```

### dockerfile

Create test image using a supplied dockerfile, instead of the default dockerfile created.
For best results, please:
- Ensure Package Repositories are updated
- Ensure Dockerfile installs sudo, curl, openssh-server, and tar
- If Ubuntu/Debian, Set DEBIAN_FRONTEND to noninteractive
- If Ubuntu/Debian, install openssh-server

```yml
dockerfile: my/dockerfile
```

## <a name="development"></a> Development

* Source hosted at [GitHub][repo]
Expand Down
26 changes: 15 additions & 11 deletions lib/kitchen/driver/docker_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,23 @@ def parse_container_id(output)
end

def docker_file
file = ["FROM #{config[:image]}"]
case config[:platform]
when 'debian', 'ubuntu'
file << 'RUN apt-get update'
file << 'RUN apt-get -y install sudo curl tar'
when 'rhel', 'centos'
file << 'RUN yum clean all'
file << 'RUN yum -y install sudo curl tar'
if config[:dockerfile]
file = IO.read(File.expand_path(config[:dockerfile]))
else
# TODO: Support other distribution
file = ["FROM #{config[:image]}"]
case config[:platform]
when 'debian', 'ubuntu'
file << 'RUN apt-get update'
file << 'RUN apt-get -y install sudo curl tar'
when 'rhel', 'centos'
file << 'RUN yum clean all'
file << 'RUN yum -y install sudo curl tar'
else
# TODO: Support other distribution
end
Array(config[:run_command]).each { |cmd| file << "RUN #{cmd}" }
file.join("\n")
end
Array(config[:run_command]).each { |cmd| file << "RUN #{cmd}" }
file.join("\n")
end

def execute(cmd, opts = {})
Expand Down

0 comments on commit f63fb2b

Please sign in to comment.