Skip to content

Commit 73905dc

Browse files
committed
prepare README to 0.9.0 release
1 parent 8d6830e commit 73905dc

File tree

1 file changed

+41
-64
lines changed

1 file changed

+41
-64
lines changed

README.md

Lines changed: 41 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -10,97 +10,69 @@ You can read about reasoning behind it at [Finely Distributed](https://finelydis
1010

1111
## Setup
1212

13-
docker-it-scala utilises [docker-java](https://github.com/docker-java/docker-java)'s way of configuration in performing
14-
initialisation with default settings.
13+
docker-it-scala can work with two underlying libraries to communicate to docker engine through *REST API* or *unix socket*.
14+
- [Spotify's docker-client](https://github.com/spotify/docker-client) (used in Whisk)
15+
- [docker-java](https://github.com/docker-java/docker-java)
1516

16-
```scala
17-
import com.github.dockerjava.core.DockerClientConfig
18-
19-
trait DockerKit {
20-
implicit val docker: Docker =
21-
new Docker(DockerClientConfig.createDefaultConfigBuilder().build())
22-
23-
...
24-
}
25-
```
17+
*Note: there is no specific recommendation to use one of them, over the other, but we hear people using Spotify's one more often, so you might get better support for it*.
2618

27-
That makes it possible to configure it through enviroment variables
19+
There are separate artifacts available for these libraries:
2820

29-
### docker-machine setup
21+
**Spotify's docker-client**
3022

31-
Docker Toolbox 1.9 (maybe also before, came some time in 2015) contains the [`docker-machine`](https://docs.docker.com/machine/) command. With it, you get going simply by:
32-
33-
```
34-
docker-machine start default
35-
eval $(docker-machine env default)
23+
```scala
24+
libraryDependencies ++= Seq(
25+
"com.whisk" %% "docker-testkit-scalatest" % "0.9.0" % "test",
26+
"com.whisk" %% "docker-testkit-impl-spotify" % "0.9.0" % "test")
3627
```
3728

38-
<!-- I like having '$' in shell commands shown in documentation. However, left them out here for consistency with the rest of the README. AKa010216 -->
39-
40-
### Boot2docker setup
29+
**docker-java**
4130

42-
```
43-
export DOCKER_HOST=tcp://192.168.59.103:2376
44-
export DOCKER_CERT_PATH=/Users/<username>/.boot2docker/certs/boot2docker-vm
45-
export DOCKER_TLS_VERIFY=1
31+
```scala
32+
libraryDependencies ++= Seq(
33+
"com.whisk" %% "docker-testkit-scalatest" % "0.9.0" % "test",
34+
"com.whisk" %% "docker-testkit-impl-docker-java" % "0.9.0" % "test")
4635
```
4736

48-
### Setup without SSL
37+
You don't necessarily have to use `scalatest` dependency as demonstrated above.
38+
You can create your custom bindings into your test environment, whether you use different initialisation technique or different framework.
39+
Have a look at [this specific trait](https://github.com/whisklabs/docker-it-scala/blob/master/scalatest/src/main/scala/com/whisk/docker/scalatest/DockerTestKit.scala)
4940

50-
```
51-
export DOCKER_HOST=tcp://127.0.0.1:2375
52-
```
5341

54-
### Docker for Mac setup
42+
### Overriding execution environment
43+
44+
If you need to have custom setup for you environment, you need to override `dockerFactory` field, providing `DockerClient` instance
5545

56-
Since version `0.9.0-M2` you can use implementation with Spotify's [docker-client](https://github.com/spotify/docker-client) in Docker for Mac setup as it works better with unix socket
57-
5846
```scala
59-
import com.spotify.docker.client.DefaultDockerClient
60-
import com.whisk.docker.impl.spotify.SpotifyDockerFactory
47+
import com.spotify.docker.client.{DefaultDockerClient, DockerClient}
6148
import com.whisk.docker.{DockerFactory, DockerKit}
6249

63-
trait MyDockerKit extends DockerKit {
64-
override implicit val dockerFactory: DockerFactory =
65-
new SpotifyDockerFactory(DefaultDockerClient.fromEnv().build())
66-
}
67-
```
50+
trait MyCustomDockerKitSpotify extends DockerKit {
6851

69-
with
52+
private val client: DockerClient = DefaultDockerClient.fromEnv().build()
53+
54+
override implicit val dockerFactory: DockerFactory = new SpotifyDockerFactory(client)
55+
}
7056

71-
```
72-
export DOCKER_HOST=unix:///var/run/docker.sock
7357
```
7458

75-
## Dependency
59+
Check [docker-client](https://github.com/spotify/docker-client) library project for configuration options.
7660

77-
Artifacts are available for Scala 2.10 and 2.11
61+
### Configuration
7862

79-
Include a dependency on one of the testkits of your choice to get started.
63+
You should be able to provide configuration purely through environment variables.
8064

81-
```scala
82-
libraryDependencies += "com.whisk" %% "docker-testkit-specs2" % "0.8.3" % "test"
83-
```
65+
Examples:
8466

85-
```scala
86-
libraryDependencies += "com.whisk" %% "docker-testkit-scalatest" % "0.8.3" % "test"
8767
```
88-
89-
If you want to configure via typesafe config (only for Scala 2.11), also include
90-
91-
```scala
92-
libraryDependencies += "com.whisk" %% "docker-testkit-config" % "0.8.3" % "test"
68+
export DOCKER_HOST=tcp://127.0.0.1:2375
9369
```
9470

95-
96-
### Unstable dependencies
97-
98-
```scala
99-
libraryDependencies ++= Seq(
100-
"com.whisk" %% "docker-testkit-scalatest" % "0.9.0-M3" % "test",
101-
"com.whisk" %% "docker-testkit-impl-spotify" % "0.9.0-M3" % "test")
71+
```
72+
export DOCKER_HOST=unix:///var/run/docker.sock
10273
```
10374

75+
10476
# Sample Services
10577

10678
- [Cassandra](https://github.com/whisklabs/docker-it-scala/blob/master/samples/src/main/scala/com/whisk/docker/DockerCassandraService.scala)
@@ -119,6 +91,8 @@ Code based definitions and via `typesafe-config`.
11991
## Code based definitions
12092

12193
```scala
94+
import com.whisk.docker.{DockerContainer, DockerKit, DockerReadyChecker}
95+
12296
trait DockerMongodbService extends DockerKit {
12397

12498
val DefaultMongodbPort = 27017
@@ -128,10 +102,13 @@ trait DockerMongodbService extends DockerKit {
128102
.withReadyChecker(DockerReadyChecker.LogLineContains("waiting for connections on port"))
129103
.withCommand("mongod", "--nojournal", "--smallfiles", "--syncdelay", "0")
130104

131-
abstract override def dockerContainers: List[DockerContainer] = mongodbContainer :: super.dockerContainers
105+
abstract override def dockerContainers: List[DockerContainer] =
106+
mongodbContainer :: super.dockerContainers
132107
}
133108
```
134109

110+
You can check [usage example](https://github.com/whisklabs/docker-it-scala/blob/master/scalatest/src/test/scala/com/whisk/docker/MongodbServiceSpec.scala)
111+
135112
## Typesafe Configuration
136113

137114
`docker-testkit-config` enables you to use a typesafe config to

0 commit comments

Comments
 (0)