Skip to content
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

Add dockerfile support #2

Merged
merged 1 commit into from
Jan 27, 2015
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
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