@@ -4,6 +4,15 @@ We provide a [swiftenv image for
44Docker] ( https://hub.docker.com/r/kylef/swiftenv/ ) . You can pull it down to use
55Swiftenv and Swift in Docker or base your own images from the swiftenv image.
66
7+ Swiftenv provides multiple base docker images:
8+
9+ - ` latest ` - Image with swiftenv and all runtime dependencies to use Swift binaries.
10+ - ` build ` - Image with swiftenv and all build dependencies to be able to build Swift from source.
11+ - ` swift3 ` - Image with swiftenv and the latest stable version of Swift 3.
12+ - ` swift ` - Image with swiftenv and the latest stable version of Swift.
13+
14+ All of the docker images are based on top of Ubuntu 16.04 LTS (Xenial).
15+
716## Running the swiftenv image directly
817
918You can pull down the ` kylef/swiftenv ` docker image and run it.
@@ -15,18 +24,55 @@ $ docker run -i -t --entrypoint /bin/sh kylef/swiftenv
1524swiftenv 1.2.0
1625```
1726
18- Using the image, you can install any version of Swift you like and use it.
27+ Or for swiftenv with latest Swift:
1928
2029``` shell
21- # swiftenv install 3.0
30+ $ docker pull kylef/swiftenv:swift
31+ $ docker run -i -t --entrypoint /bin/sh kylef/swiftenv
32+ # swift --version
33+ swift 3.0.1
2234```
2335
2436## Building a docker image using swiftenv
2537
2638You may base your own Docker image from the swiftenv image, you may then
27- install any Swift version you desire.
39+ install any Swift version you desire in your container .
2840
2941```
3042FROM kylef/swiftenv
3143RUN swiftenv install 3.0
3244```
45+
46+ ## ` docker-compose `
47+
48+ Docker compose allows you to setup and run your project easier. It's a wrapper
49+ around ` docker ` .
50+
51+ For example, we can create a service called ` commander ` on top of the swift3
52+ swiftenv image which maps the source files into the docker container.
53+
54+ ``` yaml
55+ version : ' 2.0'
56+
57+ services :
58+ commander :
59+ image : kylef/swiftenv:swift3
60+ volumes :
61+ - ' ./Sources:/code/Sources'
62+ - ' ./Tests:/code/Tests'
63+ - ' ./Packages:/code/Packages'
64+ - ' ./Package.swift:/code/Package.swift'
65+ working_dir : /code
66+ command : swift build
67+ ` ` `
68+
69+ We can then use ` docker-compose` to run commands such as `swift test` inside
70+ our container.
71+
72+ ` ` ` shell
73+ $ docker-compose run commander swift test
74+ ` ` `
75+
76+ You can switch out the `image` line of your service for `build : .` to build a
77+ ` Dockerfile` found in your repository instead of going straight from the
78+ ` swift3` image. This allows you to pin to a specific version of Swift.
0 commit comments